OgreManualObject.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 
29 #ifndef __OgreManualObject_H__
30 #define __OgreManualObject_H__
31 
32 #include "OgrePrerequisites.h"
33 #include "OgreMovableObject.h"
34 #include "OgreRenderable.h"
36 #include "OgreHeaderPrefix.h"
37 
38 namespace Ogre
39 {
107  {
108  public:
109  ManualObject(const String& name);
110  virtual ~ManualObject();
111 
112  //pre-declare ManualObjectSection
113  class ManualObjectSection;
114 
124  virtual void clear(void);
125 
133  virtual void estimateVertexCount(size_t vcount);
134 
142  virtual void estimateIndexCount(size_t icount);
143 
153  virtual void begin(const String& materialName,
155 
159  virtual void setDynamic(bool dyn) { mDynamic = dyn; }
161  virtual bool getDynamic() const { return mDynamic; }
162 
174  virtual void beginUpdate(size_t sectionIndex);
182  virtual void position(const Vector3& pos);
184  virtual void position(Real x, Real y, Real z);
185 
191  virtual void normal(const Vector3& norm);
193  virtual void normal(Real x, Real y, Real z);
194 
202  virtual void tangent(const Vector3& tan);
204  virtual void tangent(Real x, Real y, Real z);
205 
214  virtual void textureCoord(Real u);
216  virtual void textureCoord(Real u, Real v);
218  virtual void textureCoord(Real u, Real v, Real w);
220  virtual void textureCoord(Real x, Real y, Real z, Real w);
222  virtual void textureCoord(const Vector2& uv);
224  virtual void textureCoord(const Vector3& uvw);
226  virtual void textureCoord(const Vector4& xyzw);
227 
230  virtual void colour(const ColourValue& col);
234  virtual void colour(Real r, Real g, Real b, Real a = 1.0f);
235 
247  virtual void index(uint32 idx);
256  virtual void triangle(uint32 i1, uint32 i2, uint32 i3);
265  virtual void quad(uint32 i1, uint32 i2, uint32 i3, uint32 i4);
266 
268  virtual size_t getCurrentVertexCount() const;
269 
271  virtual size_t getCurrentIndexCount() const;
272 
277  virtual ManualObjectSection* end(void);
278 
288  virtual void setMaterialName(size_t subIndex, const String& name, const String & group = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
289 
301  virtual MeshPtr convertToMesh(const String& meshName,
303 
313  void setUseIdentityProjection(bool useIdentityProjection);
314 
324  bool getUseIdentityProjection(void) const { return mUseIdentityProjection; }
325 
335  void setUseIdentityView(bool useIdentityView);
336 
346  bool getUseIdentityView(void) const { return mUseIdentityView; }
347 
355  void setBoundingBox(const AxisAlignedBox& box) { mAABB = box; }
356 
359  ManualObjectSection* getSection(unsigned int index) const;
360 
363  unsigned int getNumSections(void) const;
373  void setKeepDeclarationOrder(bool keepOrder) { mKeepDeclarationOrder = keepOrder; }
374 
379  bool getKeepDeclarationOrder() const { return mKeepDeclarationOrder; }
380  // MovableObject overrides
381 
383  const String& getMovableType(void) const;
385  const AxisAlignedBox& getBoundingBox(void) const;
387  Real getBoundingRadius(void) const;
393  bool hasEdgeList(void);
396  ShadowTechnique shadowTechnique, const Light* light,
397  HardwareIndexBufferSharedPtr* indexBuffer, size_t* indexBufferUsedSize,
398  bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
399 
400 
403  {
404  protected:
411 
412 
413  public:
414  ManualObjectSection(ManualObject* parent, const String& materialName,
417 
421  const String& getMaterialName(void) const { return mMaterialName; }
423  const String& getMaterialGroup(void) const { return mGroupName; }
427  void set32BitIndices(bool n32) { m32BitIndices = n32; }
429  bool get32BitIndices() const { return m32BitIndices; }
430 
431  // Renderable overrides
433  const MaterialPtr& getMaterial(void) const;
437  void getWorldTransforms(Matrix4* xform) const;
441  const LightList &getLights(void) const;
442 
443 
444 
445  };
448  {
449  protected:
451  // Shared link to position buffer
453  // Shared link to w-coord buffer (optional)
455 
456  public:
458  HardwareIndexBufferSharedPtr* indexBuffer, const VertexData* vertexData,
459  bool createSeparateLightCap, bool isLightCap = false);
462  void getWorldTransforms(Matrix4* xform) const;
463  HardwareVertexBufferSharedPtr getPositionBuffer(void) { return mPositionBuffer; }
464  HardwareVertexBufferSharedPtr getWBuffer(void) { return mWBuffer; }
466  virtual void rebindIndexBuffer(const HardwareIndexBufferSharedPtr& indexBuffer);
467 
468 
469 
470  };
471 
473 
476  bool debugRenderables = false);
477 
478 
479  protected:
481  bool mDynamic;
489  struct TempVertex
490  {
497  };
513  size_t mDeclSize;
536 
537 
539  virtual void resetTempAreas(void);
541  virtual void resizeTempVertexBufferIfNeeded(size_t numVerts);
543  virtual void resizeTempIndexBufferIfNeeded(size_t numInds);
544 
546  virtual void copyTempVertexToBuffer(void);
547 
548  };
549 
550 
553  {
554  protected:
556  public:
559 
561 
562  const String& getType(void) const;
564 
565  };
568 }
569 
570 #include "OgreHeaderSuffix.h"
571 
572 #endif
573 
574 
#define OGRE_MAX_TEXTURE_COORD_SETS
Define number of texture coordinate sets allowed per vertex.
Definition: OgreConfig.h:68
#define _OgreExport
Definition: OgrePlatform.h:257
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
A 3D box aligned with the x/y/z axes.
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:87
Class representing colour.
This class contains the information required to describe the edge connectivity of a given set of vert...
Shared pointer implementation used to share index buffers.
Shared pointer implementation used to share vertex buffers.
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:74
Factory object for creating ManualObject instances.
MovableObject * createInstanceImpl(const String &name, const NameValuePairList *params)
Internal implementation of create method - must be overridden.
const String & getType(void) const
Get the type of the object to be created.
void destroyInstance(MovableObject *obj)
Destroy an instance of the object.
void getWorldTransforms(Matrix4 *xform) const
Overridden from ShadowRenderable.
HardwareVertexBufferSharedPtr getPositionBuffer(void)
ManualObjectSectionShadowRenderable(ManualObject *parent, HardwareIndexBufferSharedPtr *indexBuffer, const VertexData *vertexData, bool createSeparateLightCap, bool isLightCap=false)
virtual void rebindIndexBuffer(const HardwareIndexBufferSharedPtr &indexBuffer)
Overridden from ShadowRenderable.
Built, renderable section of geometry.
void setMaterialName(const String &name, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME)
update the material name in use
const MaterialPtr & getMaterial(void) const
const String & getMaterialGroup(void) const
Retrieve the material group in use.
void getRenderOperation(RenderOperation &op)
bool get32BitIndices() const
Get whether we need 32-bit indices.
RenderOperation * getRenderOperation(void)
Retrieve render operation for manipulation.
void set32BitIndices(bool n32)
Set whether we need 32-bit indices.
const LightList & getLights(void) const
const String & getMaterialName(void) const
Retrieve the material name in use.
Real getSquaredViewDepth(const Ogre::Camera *) const
void getWorldTransforms(Matrix4 *xform) const
ManualObjectSection(ManualObject *parent, const String &materialName, RenderOperation::OperationType opType, const String &groupName=ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME)
Class providing a much simplified interface to generating manual objects with custom geometry.
virtual ~ManualObject()
bool getUseIdentityView(void) const
Returns whether or not to use an 'identity' view.
virtual void textureCoord(const Vector4 &xyzw)
Add a texture coordinate to the current vertex.
const String & getMovableType(void) const
virtual void beginUpdate(size_t sectionIndex)
Start the definition of an update to a part of the object.
bool mAnyIndexed
Any indexed geometry on any sections?
ManualObjectSection * mCurrentSection
Current section.
virtual void quad(uint32 i1, uint32 i2, uint32 i3, uint32 i4)
Add a set of 4 vertex indices to construct a quad (out of 2 triangles); this is a shortcut to calling...
virtual void textureCoord(Real u)
Add a texture coordinate to the current vertex.
const AxisAlignedBox & getBoundingBox(void) const
bool mUseIdentityProjection
Whether to use identity projection for sections.
virtual void normal(Real x, Real y, Real z)
Add a vertex normal to the current vertex.
void setBoundingBox(const AxisAlignedBox &box)
Sets the bounding box.
uint32 * mTempIndexBuffer
System-memory buffer whilst we establish the size required.
virtual ManualObjectSection * end(void)
Finish defining the object and compile the final renderable version.
bool mUseIdentityView
Whether to use identity view for sections.
virtual void copyTempVertexToBuffer(void)
Copy current temp vertex into buffer.
virtual void tangent(const Vector3 &tan)
Add a vertex tangent to the current vertex.
virtual void triangle(uint32 i1, uint32 i2, uint32 i3)
Add a set of 3 vertex indices to construct a triangle; this is a shortcut to calling index() 3 times.
virtual void position(Real x, Real y, Real z)
Add a vertex position, starting a new vertex at the same time.
virtual void estimateIndexCount(size_t icount)
Estimate the number of indices ahead of time.
virtual void normal(const Vector3 &norm)
Add a vertex normal to the current vertex.
ushort mTexCoordIndex
Current texture coordinate.
EdgeData * getEdgeList(void)
Implement this method to enable stencil shadows.
virtual MeshPtr convertToMesh(const String &meshName, const String &groupName=ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME)
Convert this object to a Mesh.
void setUseIdentityView(bool useIdentityView)
Sets whether or not to use an 'identity' view.
virtual void begin(const String &materialName, RenderOperation::OperationType opType=RenderOperation::OT_TRIANGLE_LIST, const String &groupName=ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME)
Start defining a part of the object.
bool hasEdgeList(void)
Overridden member from ShadowCaster.
bool mCurrentUpdating
Are we updating?
virtual void colour(const ColourValue &col)
Add a vertex colour to a vertex.
virtual void colour(Real r, Real g, Real b, Real a=1.0f)
Add a vertex colour to a vertex.
virtual void textureCoord(Real x, Real y, Real z, Real w)
Add a texture coordinate to the current vertex.
virtual void resizeTempIndexBufferIfNeeded(size_t numInds)
Resize the temp index buffer?
void setUseIdentityProjection(bool useIdentityProjection)
Sets whether or not to use an 'identity' projection.
ShadowRenderableList mShadowRenderables
List of shadow renderables.
bool getKeepDeclarationOrder() const
Gets whether or not the declaration order is to be kept or not.
virtual void setDynamic(bool dyn)
Use before defining geometry to indicate that you intend to update the geometry regularly and want th...
virtual void tangent(Real x, Real y, Real z)
Add a vertex tangent to the current vertex.
ShadowRenderableListIterator getShadowVolumeRenderableIterator(ShadowTechnique shadowTechnique, const Light *light, HardwareIndexBufferSharedPtr *indexBuffer, size_t *indexBufferUsedSize, bool extrudeVertices, Real extrusionDist, unsigned long flags=0)
Implement this method to enable stencil shadows.
ManualObject(const String &name)
virtual void textureCoord(Real u, Real v, Real w)
Add a texture coordinate to the current vertex.
size_t mTempIndexSize
System memory allocation size, in bytes.
virtual void estimateVertexCount(size_t vcount)
Estimate the number of vertices ahead of time.
unsigned int getNumSections(void) const
Retrieves the number of ManualObjectSection objects making up this ManualObject.
virtual void position(const Vector3 &pos)
Add a vertex position, starting a new vertex at the same time.
bool mTempVertexPending
Temp vertex data to copy?
virtual size_t getCurrentIndexCount() const
Get the number of indices in the section currently being defined (returns 0 if no section is in progr...
ManualObjectSection * getSection(unsigned int index) const
Gets a pointer to a ManualObjectSection, i.e.
Real getBoundingRadius(void) const
bool getUseIdentityProjection(void) const
Returns whether or not to use an 'identity' projection.
virtual bool getDynamic() const
Gets whether this object is marked as dynamic.
void setKeepDeclarationOrder(bool keepOrder)
Sets whether or not to keep the original declaration order when queuing the renderables.
virtual void textureCoord(const Vector2 &uv)
Add a texture coordinate to the current vertex.
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables=false)
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject ...
virtual size_t getCurrentVertexCount() const
Get the number of vertices in the section currently being defined (returns 0 if no section is in prog...
virtual void resetTempAreas(void)
Delete temp buffers and reset init counts.
EdgeData * mEdgeList
Edge list, used if stencil shadow casting is enabled.
SectionList mSectionList
List of subsections.
virtual void textureCoord(Real u, Real v)
Add a texture coordinate to the current vertex.
bool mKeepDeclarationOrder
Keep declaration order or let the queue optimize it.
virtual void index(uint32 idx)
Add a vertex index to construct faces / lines / points via indexing rather than just by a simple list...
virtual void clear(void)
Completely clear the contents of the object.
size_t mDeclSize
Current declaration vertex size.
Real mRadius
Bounding sphere.
virtual void setMaterialName(size_t subIndex, const String &name, const String &group=ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME)
Alter the material for a subsection of this object after it has been specified.
virtual void textureCoord(const Vector3 &uvw)
Add a texture coordinate to the current vertex.
bool mFirstVertex
First vertex indicator.
size_t mEstIndexCount
Estimated index count.
AxisAlignedBox mAABB
Bounding box.
size_t mTempVertexSize
System memory allocation size, in bytes.
void _updateRenderQueue(RenderQueue *queue)
TempVertex mTempVertex
Temp storage.
vector< ManualObjectSection * >::type SectionList
size_t mEstVertexCount
Estimated vertex count.
virtual void resizeTempVertexBufferIfNeeded(size_t numVerts)
Resize the temp vertex buffer?
char * mTempVertexBuffer
System-memory buffer whilst we establish the size required.
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
Interface definition for a factory class which produces a certain kind of MovableObject,...
Abstract class defining a movable object in a scene.
'New' rendering operation using vertex buffers.
OperationType
The rendering operation type to perform.
@ OT_TRIANGLE_LIST
A list of triangles, 3 vertices per triangle.
Class to manage the scene object rendering queue.
Visitor object that can be used to iterate over a collection of Renderable instances abstractly.
Abstract class defining the interface all renderable objects must implement.
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
static String DEFAULT_RESOURCE_GROUP_NAME
Default resource group name.
vector< ShadowRenderable * >::type ShadowRenderableList
Class which represents the renderable aspects of a set of shadow volume faces.
Standard 2-dimensional vector.
Definition: OgreVector2.h:52
Standard 3-dimensional vector.
Definition: OgreVector3.h:52
4-dimensional homogeneous vector.
Definition: OgreVector4.h:46
Concrete IteratorWrapper for nonconst access to the underlying container.
Summary class collecting together vertex source information.
ShadowTechnique
An enumeration of broad shadow techniques.
Definition: OgreCommon.h:191
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
float Real
Software floating point type.
unsigned int uint32
Definition: OgrePlatform.h:359
_StringBase String
unsigned short ushort
Temporary vertex structure.

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.