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 {
106  class _OgreExport ManualObject : public MovableObject
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;
389  void _updateRenderQueue(RenderQueue* queue);
391  EdgeData* getEdgeList(void);
393  bool hasEdgeList(void);
395  ShadowRenderableListIterator getShadowVolumeRenderableIterator(
396  ShadowTechnique shadowTechnique, const Light* light,
397  HardwareIndexBufferSharedPtr* indexBuffer, size_t* indexBufferUsedSize,
398  bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
399 
400 
402  class _OgreExport ManualObjectSection : public Renderable, public MovableAlloc
403  {
404  protected:
411 
412 
413  public:
414  ManualObjectSection(ManualObject* parent, const String& materialName,
416  virtual ~ManualObjectSection();
417 
419  RenderOperation* getRenderOperation(void);
421  const String& getMaterialName(void) const { return mMaterialName; }
423  const String& getMaterialGroup(void) const { return mGroupName; }
425  void setMaterialName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME );
427  void set32BitIndices(bool n32) { m32BitIndices = n32; }
429  bool get32BitIndices() const { return m32BitIndices; }
430 
431  // Renderable overrides
433  const MaterialPtr& getMaterial(void) const;
435  void getRenderOperation(RenderOperation& op);
437  void getWorldTransforms(Matrix4* xform) const;
439  Real getSquaredViewDepth(const Ogre::Camera *) 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 
475  void visitRenderables(Renderable::Visitor* visitor,
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 
552  class _OgreExport ManualObjectFactory : public MovableObjectFactory
553  {
554  protected:
555  MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
556  public:
559 
561 
562  const String& getType(void) const;
563  void destroyInstance( MovableObject* obj);
564 
565  };
568 }
569 
570 #include "OgreHeaderSuffix.h"
571 
572 #endif
573 
574 
OgreHeaderSuffix.h
Ogre::HashedVector< Light * >
Ogre::ManualObject::TempVertex
Temporary vertex structure.
Definition: OgreManualObject.h:489
Ogre::ManualObject::mFirstVertex
bool mFirstVertex
First vertex indicator.
Definition: OgreManualObject.h:501
Ogre::ManualObject::ManualObjectSection::mMaterial
MaterialPtr mMaterial
Definition: OgreManualObject.h:408
Ogre::ManualObject::ManualObjectSection::mMaterialName
String mMaterialName
Definition: OgreManualObject.h:406
Ogre::ManualObject::mTempIndexSize
size_t mTempIndexSize
System memory allocation size, in bytes.
Definition: OgreManualObject.h:511
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::ManualObject::ManualObjectSectionShadowRenderable::mParent
ManualObject * mParent
Definition: OgreManualObject.h:450
Ogre::ManualObject::ManualObjectSection::get32BitIndices
bool get32BitIndices() const
Get whether we need 32-bit indices.
Definition: OgreManualObject.h:429
Ogre::ShadowCaster::ShadowRenderableList
vector< ShadowRenderable * >::type ShadowRenderableList
Definition: OgreShadowCaster.h:136
Ogre::ushort
unsigned short ushort
Definition: OgrePrerequisites.h:113
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
Ogre::ManualObject::mDynamic
bool mDynamic
Dynamic?
Definition: OgreManualObject.h:481
Ogre::ManualObject::mTexCoordIndex
ushort mTexCoordIndex
Current texture coordinate.
Definition: OgreManualObject.h:519
Ogre::ManualObject::mRadius
Real mRadius
Bounding sphere.
Definition: OgreManualObject.h:523
Ogre::ManualObject::mAnyIndexed
bool mAnyIndexed
Any indexed geometry on any sections?
Definition: OgreManualObject.h:525
Ogre::ShadowRenderable
Class which represents the renderable aspects of a set of shadow volume faces.
Definition: OgreShadowCaster.h:52
Ogre::ShadowTechnique
ShadowTechnique
An enumeration of broad shadow techniques.
Definition: OgreCommon.h:190
Ogre::Light
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:73
Ogre::ManualObject::ManualObjectSection::mGroupName
String mGroupName
Definition: OgreManualObject.h:407
Ogre::ManualObject::getUseIdentityView
bool getUseIdentityView(void) const
Returns whether or not to use an 'identity' view.
Definition: OgreManualObject.h:346
Ogre::MovableObject
Abstract class defining a movable object in a scene.
Definition: OgreMovableObject.h:60
Ogre::HardwareIndexBufferSharedPtr
Shared pointer implementation used to share index buffers.
Definition: OgreHardwareIndexBuffer.h:79
Ogre::ManualObject::ManualObjectSectionShadowRenderable
Nested class to allow shadows.
Definition: OgreManualObject.h:447
Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
Definition: OgreResourceGroupManager.h:270
Ogre::ManualObject::mEdgeList
EdgeData * mEdgeList
Edge list, used if stencil shadow casting is enabled.
Definition: OgreManualObject.h:527
Ogre::ManualObject
Class providing a much simplified interface to generating manual objects with custom geometry.
Definition: OgreManualObject.h:106
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::ManualObject::mTempVertexBuffer
char * mTempVertexBuffer
System-memory buffer whilst we establish the size required.
Definition: OgreManualObject.h:505
Ogre::ManualObject::ManualObjectSection::getMaterialGroup
const String & getMaterialGroup(void) const
Retrieve the material group in use.
Definition: OgreManualObject.h:423
Ogre::ManualObject::ManualObjectSectionShadowRenderable::getPositionBuffer
HardwareVertexBufferSharedPtr getPositionBuffer(void)
Definition: OgreManualObject.h:463
Ogre::ManualObject::ManualObjectSectionShadowRenderable::mPositionBuffer
HardwareVertexBufferSharedPtr mPositionBuffer
Definition: OgreManualObject.h:452
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::ManualObjectFactory::~ManualObjectFactory
~ManualObjectFactory()
Definition: OgreManualObject.h:558
Ogre::MovableObjectFactory
Interface definition for a factory class which produces a certain kind of MovableObject,...
Definition: OgreMovableObject.h:578
Ogre::ManualObject::getKeepDeclarationOrder
bool getKeepDeclarationOrder() const
Gets whether or not the declaration order is to be kept or not.
Definition: OgreManualObject.h:379
Ogre::ManualObject::mEstVertexCount
size_t mEstVertexCount
Estimated vertex count.
Definition: OgreManualObject.h:515
Ogre::RenderOperation::OT_TRIANGLE_LIST
@ OT_TRIANGLE_LIST
A list of triangles, 3 vertices per triangle.
Definition: OgreRenderOperation.h:56
OgreResourceGroupManager.h
Ogre::ManualObject::mCurrentUpdating
bool mCurrentUpdating
Are we updating?
Definition: OgreManualObject.h:487
Ogre::NameValuePairList
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
Ogre::ManualObject::mCurrentSection
ManualObjectSection * mCurrentSection
Current section.
Definition: OgreManualObject.h:485
Ogre::ManualObject::ManualObjectSectionShadowRenderable::mWBuffer
HardwareVertexBufferSharedPtr mWBuffer
Definition: OgreManualObject.h:454
Ogre::ManualObject::ManualObjectSection
Built, renderable section of geometry.
Definition: OgreManualObject.h:402
Ogre::VertexData
Summary class collecting together vertex source information.
Definition: OgreVertexIndexData.h:49
Ogre::ManualObject::mKeepDeclarationOrder
bool mKeepDeclarationOrder
Keep declaration order or let the queue optimize it.
Definition: OgreManualObject.h:535
Ogre::ManualObject::getDynamic
virtual bool getDynamic() const
Gets whether this object is marked as dynamic.
Definition: OgreManualObject.h:161
OGRE_MAX_TEXTURE_COORD_SETS
#define OGRE_MAX_TEXTURE_COORD_SETS
Define number of texture coordinate sets allowed per vertex.
Definition: OgreConfig.h:68
OgreHeaderPrefix.h
Ogre::ManualObjectFactory::FACTORY_TYPE_NAME
static String FACTORY_TYPE_NAME
Definition: OgreManualObject.h:560
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
Ogre::ManualObject::ManualObjectSection::set32BitIndices
void set32BitIndices(bool n32)
Set whether we need 32-bit indices.
Definition: OgreManualObject.h:427
Ogre::ManualObject::getUseIdentityProjection
bool getUseIdentityProjection(void) const
Returns whether or not to use an 'identity' projection.
Definition: OgreManualObject.h:324
Ogre::ManualObject::TempVertex::position
Vector3 position
Definition: OgreManualObject.h:491
Ogre::ManualObject::mUseIdentityProjection
bool mUseIdentityProjection
Whether to use identity projection for sections.
Definition: OgreManualObject.h:531
OgrePrerequisites.h
Ogre::HardwareVertexBufferSharedPtr
Shared pointer implementation used to share vertex buffers.
Definition: OgreHardwareVertexBuffer.h:86
Ogre::ManualObject::mSectionList
SectionList mSectionList
List of subsections.
Definition: OgreManualObject.h:483
Ogre::ManualObject::mTempVertexSize
size_t mTempVertexSize
System memory allocation size, in bytes.
Definition: OgreManualObject.h:507
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
static String DEFAULT_RESOURCE_GROUP_NAME
Default resource group name.
Definition: OgreResourceGroupManager.h:266
Ogre::ManualObject::ManualObjectSection::getMaterialName
const String & getMaterialName(void) const
Retrieve the material name in use.
Definition: OgreManualObject.h:421
Ogre::ManualObject::mDeclSize
size_t mDeclSize
Current declaration vertex size.
Definition: OgreManualObject.h:513
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:54
Ogre::ManualObject::setBoundingBox
void setBoundingBox(const AxisAlignedBox &box)
Sets the bounding box.
Definition: OgreManualObject.h:355
Ogre::ManualObject::ManualObjectSection::mRenderOperation
RenderOperation mRenderOperation
Definition: OgreManualObject.h:409
Ogre::ManualObjectFactory
Factory object for creating ManualObject instances.
Definition: OgreManualObject.h:552
Ogre::ManualObject::mEstIndexCount
size_t mEstIndexCount
Estimated index count.
Definition: OgreManualObject.h:517
Ogre::ManualObject::TempVertex::colour
ColourValue colour
Definition: OgreManualObject.h:496
Ogre::ManualObject::mAABB
AxisAlignedBox mAABB
Bounding box.
Definition: OgreManualObject.h:521
Ogre::SharedPtr< Mesh >
OgreRenderable.h
Ogre::ManualObject::mShadowRenderables
ShadowRenderableList mShadowRenderables
List of shadow renderables.
Definition: OgreManualObject.h:529
OgreMovableObject.h
Ogre::ManualObjectFactory::ManualObjectFactory
ManualObjectFactory()
Definition: OgreManualObject.h:557
Ogre::ColourValue
Class representing colour.
Definition: OgreColourValue.h:57
Ogre::Vector4
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Ogre::Vector2
Standard 2-dimensional vector.
Definition: OgreVector2.h:51
Ogre::Renderable::Visitor
Visitor object that can be used to iterate over a collection of Renderable instances abstractly.
Definition: OgreRenderable.h:377
Ogre::Renderable
Abstract class defining the interface all renderable objects must implement.
Definition: OgreRenderable.h:63
Ogre::ManualObject::mUseIdentityView
bool mUseIdentityView
Whether to use identity view for sections.
Definition: OgreManualObject.h:533
Ogre::ManualObject::setKeepDeclarationOrder
void setKeepDeclarationOrder(bool keepOrder)
Sets whether or not to keep the original declaration order when queuing the renderables.
Definition: OgreManualObject.h:373
Ogre::ManualObject::SectionList
vector< ManualObjectSection * >::type SectionList
Definition: OgreManualObject.h:472
Ogre::ManualObject::TempVertex::normal
Vector3 normal
Definition: OgreManualObject.h:492
Ogre::ManualObject::TempVertex::tangent
Vector3 tangent
Definition: OgreManualObject.h:493
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::EdgeData
This class contains the information required to describe the edge connectivity of a given set of vert...
Definition: OgreEdgeListBuilder.h:52
Ogre::ManualObject::mTempVertexPending
bool mTempVertexPending
Temp vertex data to copy?
Definition: OgreManualObject.h:503
Ogre::RenderOperation::OperationType
OperationType
The rendering operation type to perform.
Definition: OgreRenderOperation.h:48
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::ManualObject::setDynamic
virtual void setDynamic(bool dyn)
Use before defining geometry to indicate that you intend to update the geometry regularly and want th...
Definition: OgreManualObject.h:159
Ogre::ManualObject::ManualObjectSectionShadowRenderable::getWBuffer
HardwareVertexBufferSharedPtr getWBuffer(void)
Definition: OgreManualObject.h:464
Ogre::ManualObject::mTempVertex
TempVertex mTempVertex
Temp storage.
Definition: OgreManualObject.h:499
Ogre::ManualObject::ManualObjectSection::mParent
ManualObject * mParent
Definition: OgreManualObject.h:405
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Ogre::RenderOperation
'New' rendering operation using vertex buffers.
Definition: OgreRenderOperation.h:45
Ogre::RenderQueue
Class to manage the scene object rendering queue.
Definition: OgreRenderQueue.h:92
Ogre::ManualObject::ManualObjectSection::m32BitIndices
bool m32BitIndices
Definition: OgreManualObject.h:410
Ogre::ManualObject::mTempIndexBuffer
uint32 * mTempIndexBuffer
System-memory buffer whilst we establish the size required.
Definition: OgreManualObject.h:509

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Tue Apr 13 2021 08:53:15