EntityDirection.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <OgreHardwareBufferManager.h>
  16. #include "core/EntityDirection.h"
  17. EntityDirection::EntityDirection(){
  18. mRenderOp.vertexData = new Ogre::VertexData();
  19. mRenderOp.indexData = 0;
  20. mRenderOp.vertexData->vertexCount = 2;
  21. mRenderOp.vertexData->vertexStart = 0;
  22. mRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST;
  23. mRenderOp.useIndexes = false;
  24. Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
  25. Ogre::VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;
  26. decl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
  27. Ogre::HardwareVertexBufferSharedPtr vbuf0
  28. = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
  29. decl->getVertexSize(0),
  30. mRenderOp.vertexData->vertexCount,
  31. Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY
  32. );
  33. bind->setBinding(0, vbuf0);
  34. float* pPos
  35. = static_cast<float*>(vbuf0->lock(Ogre::HardwareBuffer::HBL_DISCARD));
  36. *pPos ++ = 0.0f; *pPos ++ = 0.0f; *pPos ++ = 0.0f;
  37. *pPos ++ = 0.0f; *pPos ++ = -1.0f; *pPos ++ = 0.0f;
  38. vbuf0->unlock();
  39. Ogre::AxisAlignedBox aabb;
  40. aabb.setInfinite();
  41. setBoundingBox(aabb);
  42. }
  43. EntityDirection::~EntityDirection(){delete mRenderOp.vertexData;}
  44. Ogre::Real EntityDirection::getSquaredViewDepth(const Ogre::Camera* cam) const{
  45. return 0.0f;
  46. }
  47. Ogre::Real EntityDirection::getBoundingRadius() const{return 0.0f;}