OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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-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 
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;
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,
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,
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;
529  ShadowRenderableList mShadowRenderables;
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:
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 #endif
571 
572 
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
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:270
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:233
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:553
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:73
size_t mEstIndexCount
Estimated index count.
ShadowTechnique
An enumeration of broad shadow techniques.
Definition: OgreCommon.h:193
#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:688
Specialisation of SharedPtr to allow SharedPtr to be assigned to MeshPtr.
Definition: OgreMesh.h:875
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...