Commit ca0c0850 authored by Rogerborg's avatar Rogerborg

http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=32277

Expose CGeometryCreator (as IGeometryCreator) through ISceneManager.  Test app added.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2205 dfc29bdd-3216-0410-991c-e03cc46cb475
parent e97eba6d
......@@ -16,6 +16,7 @@
#include "ESceneNodeAnimatorTypes.h"
#include "EMeshWriterEnums.h"
#include "SceneParameters.h"
#include "IGeometryCreator.h"
namespace irr
{
......@@ -1433,6 +1434,11 @@ namespace scene
/** \param[in] lightManager: the new callbacks manager. You may pass 0 to remove the
current callbacks manager and restore the default behaviour. */
virtual void setLightManager(ILightManager* lightManager) = 0;
//! Get an instance of a geometry creator.
/** The geometry creator provides some helper methods to create various types of
basic geometry. This can be useful for custom scene nodes. */
virtual const IGeometryCreator* getGeometryCreator(void) const = 0;
};
......
......@@ -21,7 +21,7 @@ IMesh* CGeometryCreator::createHillPlaneMesh(
const core::dimension2d<f32>& tileSize,
const core::dimension2d<u32>& tc, video::SMaterial* material,
f32 hillHeight, const core::dimension2d<f32>& ch,
const core::dimension2d<f32>& textureRepeatCount)
const core::dimension2d<f32>& textureRepeatCount) const
{
core::dimension2d<u32> tileCount = tc;
core::dimension2d<f32> countHills = ch;
......@@ -120,7 +120,7 @@ IMesh* CGeometryCreator::createTerrainMesh(video::IImage* texture,
video::IImage* heightmap, const core::dimension2d<f32>& stretchSize,
f32 maxHeight, video::IVideoDriver* driver,
const core::dimension2d<u32>& maxVtxBlockSize,
bool debugBorders)
bool debugBorders) const
{
if (!texture || !heightmap)
return 0;
......@@ -265,7 +265,7 @@ IMesh* CGeometryCreator::createArrowMesh(const u32 tesselationCylinder,
const f32 width0,
const f32 width1,
const video::SColor vtxColor0,
const video::SColor vtxColor1)
const video::SColor vtxColor1) const
{
SMesh* mesh = (SMesh*)createCylinderMesh(width0, cylinderHeight, tesselationCylinder, vtxColor0, false);
......@@ -284,7 +284,7 @@ IMesh* CGeometryCreator::createArrowMesh(const u32 tesselationCylinder,
/* A sphere with proper normals and texture coords */
IMesh* CGeometryCreator::createSphereMesh(f32 radius, u32 polyCountX, u32 polyCountY)
IMesh* CGeometryCreator::createSphereMesh(f32 radius, u32 polyCountX, u32 polyCountY) const
{
SMeshBuffer* buffer = new SMeshBuffer();
......@@ -456,7 +456,9 @@ IMesh* CGeometryCreator::createSphereMesh(f32 radius, u32 polyCountX, u32 polyCo
/* A cylinder with proper normals and texture coords */
IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length, u32 tesselation, const video::SColor& color, bool closeTop, f32 oblique)
IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length,
u32 tesselation, const video::SColor& color,
bool closeTop, f32 oblique) const
{
SMeshBuffer* buffer = new SMeshBuffer();
......@@ -589,7 +591,9 @@ IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length, u32 tesselat
/* A cone with proper normals and texture coords */
IMesh* CGeometryCreator::createConeMesh(f32 radius, f32 length, u32 tesselation, const video::SColor& colorTop, const video::SColor& colorBottom, f32 oblique)
IMesh* CGeometryCreator::createConeMesh(f32 radius, f32 length, u32 tesselation,
const video::SColor& colorTop,
const video::SColor& colorBottom, f32 oblique) const
{
SMeshBuffer* buffer = new SMeshBuffer();
......
......@@ -5,49 +5,45 @@
#ifndef __C_GEOMETRY_CREATOR_H_INCLUDED__
#define __C_GEOMETRY_CREATOR_H_INCLUDED__
#include "IMesh.h"
#include "IImage.h"
#include "IGeometryCreator.h"
namespace irr
{
namespace video
{
class IVideoDriver;
class SMaterial;
}
namespace scene
{
//! class for creating geometry on the fly
class CGeometryCreator
class CGeometryCreator : public IGeometryCreator
{
public:
static IMesh* createHillPlaneMesh(
IMesh* createHillPlaneMesh(
const core::dimension2d<f32>& tileSize, const core::dimension2d<u32>& tileCount,
video::SMaterial* material, f32 hillHeight, const core::dimension2d<f32>& countHills,
const core::dimension2d<f32>& textureRepeatCount);
const core::dimension2d<f32>& textureRepeatCount) const;
static IMesh* createTerrainMesh(video::IImage* texture,
IMesh* createTerrainMesh(video::IImage* texture,
video::IImage* heightmap, const core::dimension2d<f32>& stretchSize,
f32 maxHeight, video::IVideoDriver* driver,
const core::dimension2d<u32>& defaultVertexBlockSize,
bool debugBorders=false);
bool debugBorders=false) const;
static IMesh* createArrowMesh(const u32 tesselationCylinder,
IMesh* createArrowMesh(const u32 tesselationCylinder,
const u32 tesselationCone, const f32 height,
const f32 cylinderHeight, const f32 width0,
const f32 width1, const video::SColor vtxColor0,
const video::SColor vtxColor1);
const video::SColor vtxColor1) const;
static IMesh* createSphereMesh(f32 radius, u32 polyCountX, u32 polyCountY);
IMesh* createSphereMesh(f32 radius, u32 polyCountX, u32 polyCountY) const;
static IMesh* createCylinderMesh(f32 radius, f32 length, u32 tesselation, const video::SColor& color=video::SColor(0xffffffff), bool closeTop=true, f32 oblique=0.f);
IMesh* createCylinderMesh(f32 radius, f32 length, u32 tesselation,
const video::SColor& color=video::SColor(0xffffffff),
bool closeTop=true, f32 oblique=0.f) const;
static IMesh* createConeMesh(f32 radius, f32 length, u32 tesselation, const video::SColor& colorTop=video::SColor(0xffffffff), const video::SColor& colorBottom=video::SColor(0xffffffff), f32 oblique=0.f);
IMesh* createConeMesh(f32 radius, f32 length, u32 tesselation,
const video::SColor& colorTop=video::SColor(0xffffffff),
const video::SColor& colorBottom=video::SColor(0xffffffff), f32 oblique=0.f) const;
};
......
......@@ -17,8 +17,6 @@
#include "os.h"
#include "CGeometryCreator.h"
#ifdef _IRR_COMPILE_WITH_IRR_MESH_LOADER_
#include "CIrrMeshFileLoader.h"
#endif
......@@ -902,7 +900,7 @@ IAnimatedMesh* CSceneManager::addHillPlaneMesh(const core::string<c16>& name,
if (MeshCache->isMeshLoaded(name))
return MeshCache->getMeshByFilename(name);
IMesh* mesh = CGeometryCreator::createHillPlaneMesh(tileSize,
IMesh* mesh = GeometryCreator.createHillPlaneMesh(tileSize,
tileCount, material, hillHeight, countHills,
textureRepeatCount);
if (!mesh)
......@@ -936,7 +934,7 @@ IAnimatedMesh* CSceneManager::addTerrainMesh(const core::string<c16>& name,
if (MeshCache->isMeshLoaded(name))
return MeshCache->getMeshByFilename(name);
IMesh* mesh = CGeometryCreator::createTerrainMesh(texture, heightmap,
IMesh* mesh = GeometryCreator.createTerrainMesh(texture, heightmap,
stretchSize, maxHeight, getVideoDriver(),
defaultVertexBlockSize);
if (!mesh)
......@@ -969,7 +967,7 @@ IAnimatedMesh* CSceneManager::addArrowMesh(const core::string<c16>& name,
if (MeshCache->isMeshLoaded(name))
return MeshCache->getMeshByFilename(name);
IMesh* mesh = CGeometryCreator::createArrowMesh( tesselationCylinder,
IMesh* mesh = GeometryCreator.createArrowMesh( tesselationCylinder,
tesselationCone, height, cylinderHeight, width0,width1,
vtxColor0, vtxColor1);
if (!mesh)
......@@ -1000,7 +998,7 @@ IAnimatedMesh* CSceneManager::addSphereMesh(const core::string<c16>& name,
if (MeshCache->isMeshLoaded(name))
return MeshCache->getMeshByFilename(name);
IMesh* mesh = CGeometryCreator::createSphereMesh(radius, polyCountX, polyCountY);
IMesh* mesh = GeometryCreator.createSphereMesh(radius, polyCountX, polyCountY);
if (!mesh)
return 0;
......
......@@ -13,6 +13,7 @@
#include "IMeshLoader.h"
#include "CAttributes.h"
#include "ILightManager.h"
#include "CGeometryCreator.h"
namespace irr
{
......@@ -475,6 +476,9 @@ namespace scene
//! Register a custom callbacks manager which gets callbacks during scene rendering.
virtual void setLightManager(ILightManager* lightManager);
//! Get an instance of a geometry creator.
virtual const IGeometryCreator* getGeometryCreator(void) const { return &GeometryCreator; }
private:
//! returns if node is culled
......@@ -618,6 +622,8 @@ namespace scene
const core::stringw IRR_XML_FORMAT_SCENE;
const core::stringw IRR_XML_FORMAT_NODE;
const core::stringw IRR_XML_FORMAT_NODE_ATTR_TYPE;
CGeometryCreator GeometryCreator;
};
} // end namespace video
......
......@@ -5,7 +5,6 @@
#include "CSphereSceneNode.h"
#include "IVideoDriver.h"
#include "ISceneManager.h"
#include "CGeometryCreator.h"
#include "S3DVertex.h"
#include "os.h"
......@@ -24,7 +23,7 @@ CSphereSceneNode::CSphereSceneNode(f32 radius, u32 polyCountX, u32 polyCountY, I
setDebugName("CSphereSceneNode");
#endif
Mesh = CGeometryCreator::createSphereMesh(radius, polyCountX, polyCountY);
Mesh = SceneManager->getGeometryCreator()->createSphereMesh(radius, polyCountX, polyCountY);
}
......@@ -128,7 +127,7 @@ void CSphereSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttribute
{
if (Mesh)
Mesh->drop();
Mesh = CGeometryCreator::createSphereMesh(Radius, PolyCountX, PolyCountY);
Mesh = SceneManager->getGeometryCreator()->createSphereMesh(Radius, PolyCountX, PolyCountY);
}
ISceneNode::deserializeAttributes(in, options);
......
......@@ -87,6 +87,7 @@ int main(int argumentCount, char * arguments[])
TEST(writeImageToFile);
TEST(flyCircleAnimator);
TEST(enumerateImageManipulators);
TEST(testGeometryCreator);
const unsigned int numberOfTests = tests.size();
......
Test suite pass at GMT Mon Feb 09 19:22:13 2009
Test suite pass at GMT Mon Feb 09 20:04:31 2009
......@@ -62,6 +62,7 @@
<Unit filename="softwareDevice.cpp" />
<Unit filename="terrainSceneNode.cpp" />
<Unit filename="testDimension2d.cpp" />
<Unit filename="testGeometryCreator.cpp" />
<Unit filename="testUtils.cpp" />
<Unit filename="testVector2d.cpp" />
<Unit filename="testVector3d.cpp" />
......
......@@ -269,6 +269,10 @@
RelativePath=".\testDimension2d.cpp"
>
</File>
<File
RelativePath=".\testGeometryCreator.cpp"
>
</File>
<File
RelativePath=".\testUtils.cpp"
>
......
......@@ -266,6 +266,10 @@
RelativePath=".\testDimension2d.cpp"
>
</File>
<File
RelativePath=".\testGeometryCreator.cpp"
>
</File>
<File
RelativePath=".\testUtils.cpp"
>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment