40 #ifndef _LINEGROUP_cpp
41 #define _LINEGROUP_cpp
43 #include "linegroup.h"
44 #include "Graphics/scenemanager.h"
87 class Line3D:
public Ogre::SimpleRenderable
144 Ogre::SceneNode*
GetNode()
const;
169 mRenderOp.vertexData =
new Ogre::VertexData();
173 mRenderOp.indexData = 0;
174 mRenderOp.vertexData->vertexCount = 1024;
175 mRenderOp.vertexData->vertexStart = 0;
176 mRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST;
177 mRenderOp.useIndexes =
false;
179 Ogre::VertexDeclaration* VDecl = mRenderOp.vertexData->vertexDeclaration;
180 Ogre::VertexBufferBinding* VBind = mRenderOp.vertexData->vertexBufferBinding;
184 VDecl->addElement(0,0,Ogre::VET_FLOAT3,Ogre::VES_POSITION);
185 Offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
188 VDecl->addElement(0,Offset,Ogre::VET_FLOAT4,Ogre::VES_DIFFUSE);
189 Offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT4);
191 this->
VertexBuffer = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
192 VDecl->getVertexSize(0),
193 mRenderOp.vertexData->vertexCount,
194 Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
199 this->setMaterial(
"BaseWhiteNoLighting");
205 delete mRenderOp.vertexData;
215 assert(Index < this->
Points.size() &&
"Point index is out of bounds!!");
217 return this->
Points[Index].Position;
222 return this->
Points.size();
227 assert(Index < this->
Points.size() &&
"Point index is out of bounds!!");
229 this->
Points[Index].Position = NewValue;
249 if( mRenderOp.vertexData->vertexCount < NumPoints )
251 Whole NewVertexBufferSize = 1;
252 while(NewVertexBufferSize < NumPoints)
253 NewVertexBufferSize <<= 1;
255 this->
VertexBuffer = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
256 mRenderOp.vertexData->vertexDeclaration->getVertexSize(0),
258 Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
261 mRenderOp.vertexData->vertexBufferBinding->setBinding(0,this->
VertexBuffer);
262 mRenderOp.vertexData->vertexCount = NewVertexBufferSize;
263 mRenderOp.vertexData->vertexStart = 0;
270 for(
Whole Index = 0 ; Index < NumPoints ; ++Index )
308 Ogre::Vector3 vMin, vMax, vMid, vDist;
309 vMin = mBox.getMinimum();
310 vMax = mBox.getMaximum();
311 vMid = ((vMin - vMax) * 0.5) + vMin;
312 vDist = Cam->getDerivedPosition() - vMid;
314 return vDist.squaredLength();
319 return Ogre::Math::Sqrt(std::max(mBox.getMaximum().squaredLength(), mBox.getMinimum().squaredLength()));
330 return this->
SelfNode->_getDerivedOrientation();
335 return this->
SelfNode->_getDerivedPosition();
351 delete this->LineData;
356 this->LineData->
AddPoint(NewPoint,Colour);
372 return this->LineData->
UpdatePoint(Index,NewValue);
382 this->LineData->
DrawLine(Start,End,Colour);
392 if( this->LineData->isAttached() == false )
393 this->LineData->
GetNode()->attachObject(this->LineData);
398 if( this->LineData->isAttached() != false )
399 this->LineData->
GetNode()->detachObject(this->LineData);