40 #ifndef _LINEGROUP_cpp
41 #define _LINEGROUP_cpp
43 #include "linegroup.h"
44 #include "Graphics/scenemanager.h"
77 : Position(Pos), Colour(Col) { }
88 class Line3D :
public Ogre::SimpleRenderable
172 Ogre::SceneNode*
GetNode()
const;
176 : ParentWorld(ParentWorldArg)
178 mRenderOp.vertexData =
new Ogre::VertexData();
182 mRenderOp.indexData = 0;
183 mRenderOp.vertexData->vertexCount = 1024;
184 mRenderOp.vertexData->vertexStart = 0;
185 mRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST;
186 mRenderOp.useIndexes =
false;
188 Ogre::VertexDeclaration* VDecl = mRenderOp.vertexData->vertexDeclaration;
189 Ogre::VertexBufferBinding* VBind = mRenderOp.vertexData->vertexBufferBinding;
193 VDecl->addElement(0,0,Ogre::VET_FLOAT3,Ogre::VES_POSITION);
194 Offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
197 VDecl->addElement(0,Offset,Ogre::VET_FLOAT4,Ogre::VES_DIFFUSE);
198 Offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT4);
200 this->
VertexBuffer = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
201 VDecl->getVertexSize(0),
202 mRenderOp.vertexData->vertexCount,
203 Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
208 this->setMaterial(
"BaseWhiteNoLighting");
214 delete mRenderOp.vertexData;
218 {
return this->
SelfNode->_getDerivedOrientation(); }
221 {
return this->
SelfNode->_getDerivedPosition(); }
225 if(RequestedSize > this->
VertexBuffer->getNumVertices() ) {
227 Whole NewVertexBufferSize = 1;
228 while(NewVertexBufferSize < RequestedSize)
229 NewVertexBufferSize <<= 1;
231 this->
VertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
232 this->mRenderOp.vertexData->vertexDeclaration->getVertexSize(0),
234 Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
237 this->mRenderOp.vertexData->vertexStart = 0;
238 this->mRenderOp.vertexData->vertexBufferBinding->setBinding(0,this->
VertexBuffer);
249 assert(Index < this->
Points.size() &&
"Point index is out of bounds!!");
251 return this->
Points[Index].Position;
256 return this->
Points.size();
261 assert(Index < this->
Points.size() &&
"Point index is out of bounds!!");
263 this->
Points[Index].Position = NewValue;
281 if( NumPoints > 0 ) {
302 for(
Whole Index = 0 ; Index < NumPoints ; ++Index )
333 this->mRenderOp.vertexData->vertexCount = NumPoints;
341 Ogre::Vector3 vMin, vMax, vMid, vDist;
342 vMin = mBox.getMinimum();
343 vMax = mBox.getMaximum();
344 vMid = ((vMin - vMax) * 0.5) + vMin;
345 vDist = Cam->getDerivedPosition() - vMid;
347 return vDist.squaredLength();
351 {
return Ogre::Math::Sqrt(std::max(mBox.getMaximum().squaredLength(), mBox.getMinimum().squaredLength())); }
362 : ParentWorld(ParentWorld)
370 delete this->LineData;
374 { this->LineData->
AddPoint(NewPoint,Colour); }
383 {
return this->LineData->
UpdatePoint(Index,NewValue); }
389 { this->LineData->
DrawLine(Start,End,Colour); }
396 if( this->LineData->isAttached() == false )
397 this->LineData->
GetNode()->attachObject(this->LineData);
402 if( this->LineData->isAttached() == true )
403 this->LineData->
GetNode()->detachObject(this->LineData);
ColourValue Colour
Vertex colour.
void DrawLine(const Vector3 &Start, const Vector3 &End, const ColourValue &Colour)
This adds Two points to the list.
WorldManager * GetManager(const Whole ManagerToGet)
This is will find the manager of a given type.
const Ogre::Quaternion getWorldOrientation(void) const
Gets how rotated this is currently.
This class contains utilities and functions to allow the manipulation of the Graphical scene...
Real X
Coordinate on the X vector.
Real Z
Coordinate on the Z vector.
void UpdatePoint(const Whole Index, const Vector3 &NewValue)
This changes a specific point.
Ogre::SceneNode * SelfNode
Pointer to the node that will be used exclusively for this renderable.
void AddToWorld()
Configures this LineGroup to render in the scene.
const Ogre::Vector3 getWorldPosition(void) const
Get the position of this Line3d.
Ogre::SceneNode * GetNode() const
Retrieves the scene node that will be used to attach this object to the scenegraph.
void DrawLines()
Updates the internal buffers as necessary for rendering.
void AddPoint(const Vector3 &NewPoint, const ColourValue &Colour)
This add Either a start pointing, or a line segment to the next point.
Real getBoundingRadius(void) const
How big would a circle need to be to encapsulate this.
void DrawLines()
Updates the render buffers with the needed data to draw the lines in this LineGroup.
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
Whole GetNumPoints() const
How many points are in this Line3D.
~LineGroup()
Default Destructor.
void ClearLines()
Clears all data pertaining to points in this line group.
const Vector3 & GetPoint(const Whole Index) const
Access a specific point by index.
float Real
A Datatype used to represent a real floating point number.
void RemoveFromWorld()
Unhooks this LineGroup from the scene, stopping it from rendering.
LineGroup(World *ParentWorld)
Basic Constructor.
Real GreenChannel
Value from 0.0 to 1.0 representing the amount of green present in the colour. 1.0 if very green...
const Vector3 GetPoint(const Whole Index) const
Access points by order they were added.
void ClearPoints()
Clears all data pertaining to points in this line group.
Real AlphaChannel
Value from 0.0 to 1.0 representing the transparency of the colours. 1.0 is opaque and 0...
void AddPoint(const Vector3 &NewPoint, const ColourValue &Colour)
This adds a point to the list of what should be rendered.
Ogre::Vector3 GetOgreVector3() const
Gets a Ogre vector3.
Real Y
Coordinate on the Y vector.
Real GetBoundingRadius() const
How big would a circle need to be to encapsulate this.
~LineVertex()
Class destructor.
Line3D(World *ParentWorld)
Default Constructor.
Real getSquaredViewDepth(const Ogre::Camera *Cam) const
Not Used.
void UpdatePoint(const Whole Index, const Vector3 &NewValue)
This changes a specific point.
This is used to represent a point in space, or a vector through space.
void ResizeVertexBuffer(const Whole RequestedSize)
Resizes the Vertex Buffer.
Vector3 Position
Vertex position.
World * ParentWorld
Parent World to locate SceneManager.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
This class represents a world for objects to interact within.
Real BlueChannel
Value from 0.0 to 1.0 representing the amount of blue present in the colour. 1.0 if very blue...
void DrawLine(const Vector3 &Start, const Vector3 &End, const ColourValue &Colour)
This adds Two points to the list.
LineVertex(const Vector3 &Pos, const ColourValue &Col)
Class constructor.
Does the bulk of the work that that the Mezzanine::LineGroup performs.
Real RedChannel
Value from 0.0 to 1.0 representing the amount of red present in the colour. 1.0 if very red...
Ogre::HardwareVertexBufferSharedPtr VertexBuffer
Internal pointer to the vertex buffer for this object.
std::vector< LineVertex > Points
This is a vector which stores the point data.
Whole GetNumPoints() const
Get the amount of points used to define Line Segments.
A small declaration of what our vertexs look like for when we write to the buffers.