OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-2011 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 
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 
271  virtual ManualObjectSection* end(void);
272 
282  virtual void setMaterialName(size_t subindex, const String& name, const String & group = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
283 
295  virtual MeshPtr convertToMesh(const String& meshName,
297 
307  void setUseIdentityProjection(bool useIdentityProjection);
308 
318  bool getUseIdentityProjection(void) const { return mUseIdentityProjection; }
319 
329  void setUseIdentityView(bool useIdentityView);
330 
340  bool getUseIdentityView(void) const { return mUseIdentityView; }
341 
349  void setBoundingBox(const AxisAlignedBox& box) { mAABB = box; }
350 
353  ManualObjectSection* getSection(unsigned int index) const;
354 
357  unsigned int getNumSections(void) const;
367  void setKeepDeclarationOrder(bool keepOrder) { mKeepDeclarationOrder = keepOrder; }
368 
373  bool getKeepDeclarationOrder() const { return mKeepDeclarationOrder; }
374  // MovableObject overrides
375 
377  const String& getMovableType(void) const;
379  const AxisAlignedBox& getBoundingBox(void) const;
381  Real getBoundingRadius(void) const;
383  void _updateRenderQueue(RenderQueue* queue);
385  EdgeData* getEdgeList(void);
387  bool hasEdgeList(void);
389  ShadowRenderableListIterator getShadowVolumeRenderableIterator(
390  ShadowTechnique shadowTechnique, const Light* light,
391  HardwareIndexBufferSharedPtr* indexBuffer,
392  bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
393 
394 
397  {
398  protected:
405 
406 
407  public:
408  ManualObjectSection(ManualObject* parent, const String& materialName,
410  virtual ~ManualObjectSection();
411 
413  RenderOperation* getRenderOperation(void);
415  const String& getMaterialName(void) const { return mMaterialName; }
417  const String& getMaterialGroup(void) const { return mGroupName; }
419  void setMaterialName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME );
421  void set32BitIndices(bool n32) { m32BitIndices = n32; }
423  bool get32BitIndices() const { return m32BitIndices; }
424 
425  // Renderable overrides
427  const MaterialPtr& getMaterial(void) const;
429  void getRenderOperation(RenderOperation& op);
431  void getWorldTransforms(Matrix4* xform) const;
433  Real getSquaredViewDepth(const Ogre::Camera *) const;
435  const LightList &getLights(void) const;
436 
437 
438 
439  };
442  {
443  protected:
445  // Shared link to position buffer
447  // Shared link to w-coord buffer (optional)
449 
450  public:
452  HardwareIndexBufferSharedPtr* indexBuffer, const VertexData* vertexData,
453  bool createSeparateLightCap, bool isLightCap = false);
456  void getWorldTransforms(Matrix4* xform) const;
457  HardwareVertexBufferSharedPtr getPositionBuffer(void) { return mPositionBuffer; }
458  HardwareVertexBufferSharedPtr getWBuffer(void) { return mWBuffer; }
459 
460  };
461 
463 
465  void visitRenderables(Renderable::Visitor* visitor,
466  bool debugRenderables = false);
467 
468 
469  protected:
471  bool mDynamic;
479  struct TempVertex
480  {
487  };
503  size_t mDeclSize;
519  ShadowRenderableList mShadowRenderables;
526 
527 
529  virtual void resetTempAreas(void);
531  virtual void resizeTempVertexBufferIfNeeded(size_t numVerts);
533  virtual void resizeTempIndexBufferIfNeeded(size_t numInds);
534 
536  virtual void copyTempVertexToBuffer(void);
537 
538  };
539 
540 
543  {
544  protected:
545  MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
546  public:
549 
551 
552  const String& getType(void) const;
553  void destroyInstance( MovableObject* obj);
554 
555  };
558 }
559 
560 #endif
561 
562 
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:85
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
bool mDynamic
Dynamic?
bool getKeepDeclarationOrder() const
Gets whether or not the declaration order is to be kept or not.
virtual bool getDynamic() const
Gets whether this object is marked as dynamic.
float Real
Software floating point type.
unsigned int uint32
Definition: OgrePlatform.h:246
void setKeepDeclarationOrder(bool keepOrder)
Sets whether or not to keep the original declaration order when queuing the renderables.
vector< ManualObjectSection * >::type SectionList
#define _OgreExport
Definition: OgrePlatform.h:203
uint32 * mTempIndexBuffer
System-memory buffer whilst we establish the size required.
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:524
Class providing a much simplified interface to generating manual objects with custom geometry...
const String & getMaterialName(void) const
Retrieve the material name in use.
size_t mEstVertexCount
Estimated vertex count.
Class representing colour.
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
bool getUseIdentityProjection(void) const
Returns whether or not to use an 'identity' projection.
ushort mTexCoordIndex
Current texture coordinate.
Shared pointer implementation used to share index buffers.
A 3D box aligned with the x/y/z axes.
bool mAnyIndexed
Any indexed geometry on any sections?
const String & getMaterialGroup(void) const
Retrieve the material group in use.
Interface definition for a factory class which produces a certain kind of MovableObject, and can be registered with Root in order to allow all clients to produce new instances of this object, integrated with the standard Ogre processing.
Abstract class defining a movable object in a scene.
bool mKeepDeclarationOrder
Keep declaration order or let the queue optimize it.
HardwareVertexBufferSharedPtr getPositionBuffer(void)
Temporary vertex structure.
Abstract class defining the interface all renderable objects must implement.
void setBoundingBox(const AxisAlignedBox &box)
Sets the bounding box.
TempVertex mTempVertex
Temp storage.
Shared pointer implementation used to share index buffers.
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:72
size_t mEstIndexCount
Estimated index count.
ShadowTechnique
An enumeration of broad shadow techniques.
Definition: OgreCommon.h:191
#define OGRE_MAX_TEXTURE_COORD_SETS
Define number of texture coordinate sets allowed per vertex.
Definition: OgreConfig.h:66
void set32BitIndices(bool n32)
Set whether we need 32-bit indices.
Real mRadius
Bounding sphere.
static OGRE_AUTO_MUTEX String DEFAULT_RESOURCE_GROUP_NAME
Default resource group name.
bool get32BitIndices() const
Get whether we need 32-bit indices.
Built, renderable section of geometry.
AxisAlignedBox mAABB
Bounding box.
ManualObjectSection * mCurrentSection
Current section.
Class which represents the renderable aspects of a set of shadow volume faces.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Standard 2-dimensional vector.
Definition: OgreVector2.h:51
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
bool mTempVertexPending
Temp vertex data to copy?
bool mUseIdentityView
Whether to use identity view for sections.
size_t mTempIndexSize
System memory allocation size, in bytes.
bool mFirstVertex
First vertex indicator.
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
unsigned short ushort
bool getUseIdentityView(void) const
Returns whether or not to use an 'identity' view.
Summary class collecting together vertex source information.
Factory object for creating ManualObject instances.
'New' rendering operation using vertex buffers.
bool mUseIdentityProjection
Whether to use identity projection for sections.
bool mCurrentUpdating
Are we updating?
ShadowRenderableList mShadowRenderables
List of shadow renderables.
SectionList mSectionList
List of subsections.
char * mTempVertexBuffer
System-memory buffer whilst we establish the size required.
Class to manage the scene object rendering queue.
This class contains the information required to describe the edge connectivity of a given set of vert...
size_t mTempVertexSize
System memory allocation size, in bytes.
_StringBase String
A list of triangles, 3 vertices per triangle.
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Specialisation of SharedPtr to allow SharedPtr to be assigned to MaterialPtr.
Definition: OgreMaterial.h:677
Specialisation of SharedPtr to allow SharedPtr to be assigned to MeshPtr.
Definition: OgreMesh.h:894
size_t mDeclSize
Current declaration vertex size.
OperationType
The rendering operation type to perform.
EdgeData * mEdgeList
Edge list, used if stencil shadow casting is enabled.
virtual void setDynamic(bool dyn)
Use before defining geometry to indicate that you intend to update the geometry regularly and want th...