OGRE  2.0
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-2014 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 "OgreRenderOperation.h"
37 #include "OgreHeaderPrefix.h"
38 
39 namespace Ogre
40 {
108  {
109  public:
110  ManualObject( IdType id, ObjectMemoryManager *objectMemoryManager );
111  virtual ~ManualObject();
112 
113  //pre-declare ManualObjectSection
114  class ManualObjectSection;
115 
125  virtual void clear(void);
126 
134  virtual void estimateVertexCount(size_t vcount);
135 
143  virtual void estimateIndexCount(size_t icount);
144 
154  virtual void begin(const String& materialName,
156 
160  virtual void setDynamic(bool dyn) { mDynamic = dyn; }
162  virtual bool getDynamic() const { return mDynamic; }
163 
175  virtual void beginUpdate(size_t sectionIndex);
183  virtual void position(const Vector3& pos);
185  virtual void position(Real x, Real y, Real z);
186 
192  virtual void normal(const Vector3& norm);
194  virtual void normal(Real x, Real y, Real z);
195 
203  virtual void tangent(const Vector3& tan);
205  virtual void tangent(Real x, Real y, Real z);
206 
215  virtual void textureCoord(Real u);
217  virtual void textureCoord(Real u, Real v);
219  virtual void textureCoord(Real u, Real v, Real w);
221  virtual void textureCoord(Real x, Real y, Real z, Real w);
223  virtual void textureCoord(const Vector2& uv);
225  virtual void textureCoord(const Vector3& uvw);
227  virtual void textureCoord(const Vector4& xyzw);
228 
231  virtual void colour(const ColourValue& col);
235  virtual void colour(Real r, Real g, Real b, Real a = 1.0f);
236 
248  virtual void index(uint32 idx);
257  virtual void triangle(uint32 i1, uint32 i2, uint32 i3);
266  virtual void quad(uint32 i1, uint32 i2, uint32 i3, uint32 i4);
267 
269  virtual size_t getCurrentVertexCount() const;
270 
272  virtual size_t getCurrentIndexCount() const;
273 
278  virtual ManualObjectSection* end(void);
279 
289  virtual void setMaterialName(size_t subIndex, const String& name, const String & group = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
290 
302  virtual MeshPtr convertToMesh(const String& meshName,
304 
314  void setUseIdentityProjection(bool useIdentityProjection);
315 
325  bool getUseIdentityProjection(void) const { return mUseIdentityProjection; }
326 
336  void setUseIdentityView(bool useIdentityView);
337 
347  bool getUseIdentityView(void) const { return mUseIdentityView; }
348 
351  ManualObjectSection* getSection(unsigned int index) const;
352 
355  unsigned int getNumSections(void) const;
365  void setKeepDeclarationOrder(bool keepOrder) { mKeepDeclarationOrder = keepOrder; }
366 
371  bool getKeepDeclarationOrder() const { return mKeepDeclarationOrder; }
372  // MovableObject overrides
373 
375  const String& getMovableType(void) const;
377  void _updateRenderQueue(RenderQueue* queue, Camera *camera, const Camera *lodCamera);
379  EdgeData* getEdgeList(void);
381  bool hasEdgeList(void);
382 
385  {
386  protected:
393 
394 
395  public:
396  ManualObjectSection(ManualObject* parent, const String& materialName,
398  virtual ~ManualObjectSection();
399 
401  RenderOperation* getRenderOperation(void);
403  const String& getMaterialName(void) const { return mMaterialName; }
405  const String& getMaterialGroup(void) const { return mGroupName; }
407  void setMaterialName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME );
409  void set32BitIndices(bool n32) { m32BitIndices = n32; }
411  bool get32BitIndices() const { return m32BitIndices; }
412 
413  // Renderable overrides
415  const MaterialPtr& getMaterial(void) const;
417  void getRenderOperation(RenderOperation& op);
419  void getWorldTransforms(Matrix4* xform) const;
421  Real getSquaredViewDepth(const Ogre::Camera *) const;
423  const LightList &getLights(void) const;
424 
425 
426 
427  };
428 
430 
432  void visitRenderables(Renderable::Visitor* visitor,
433  bool debugRenderables = false);
434 
435 
436  protected:
438  bool mDynamic;
446  struct TempVertex
447  {
454  };
470  size_t mDeclSize;
487 
488 
490  virtual void resetTempAreas(void);
492  virtual void resizeTempVertexBufferIfNeeded(size_t numVerts);
494  virtual void resizeTempIndexBufferIfNeeded(size_t numInds);
495 
497  virtual void copyTempVertexToBuffer(void);
498 
499  };
500 
501 
504  {
505  protected:
506  virtual MovableObject* createInstanceImpl( IdType id, ObjectMemoryManager *objectMemoryManager,
507  const NameValuePairList* params = 0 );
508  public:
511 
513 
514  const String& getType(void) const;
515  void destroyInstance( MovableObject* obj);
516 
517  };
520 }
521 
522 #include "OgreHeaderSuffix.h"
523 
524 #endif
525 
526 
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:82
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
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:420
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:255
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:580
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...
static String DEFAULT_RESOURCE_GROUP_NAME
Default resource group name.
bool getUseIdentityProjection(void) const
Returns whether or not to use an 'identity' projection.
ushort mTexCoordIndex
Current texture coordinate.
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.
Wrap-around class that contains multiple ArrayMemoryManager, one per render queue.
Abstract class defining a movable object in a scene.
bool mKeepDeclarationOrder
Keep declaration order or let the queue optimize it.
Temporary vertex structure.
Abstract class defining the interface all renderable objects must implement.
TempVertex mTempVertex
Temp storage.
size_t mEstIndexCount
Estimated index count.
#define OGRE_MAX_TEXTURE_COORD_SETS
Define number of texture coordinate sets allowed per vertex.
Definition: OgreConfig.h:68
void set32BitIndices(bool n32)
Set whether we need 32-bit indices.
Ogre::uint32 IdType
Big projects with lots, lots of units for very long periods of time (MMORPGs?) may want to define thi...
Definition: OgreId.h:36
bool get32BitIndices() const
Get whether we need 32-bit indices.
Built, renderable section of geometry.
ManualObjectSection * mCurrentSection
Current section.
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:50
unsigned short ushort
bool getUseIdentityView(void) const
Returns whether or not to use an 'identity' view.
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?
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
Definition: OgreCommon.h:53
A list of triangles, 3 vertices per triangle.
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
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...