Commit f91ece5e authored by hybrid's avatar hybrid

volume light mesh creation methods, provided by iondune

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2342 dfc29bdd-3216-0410-991c-e03cc46cb475
parent d7cde7f6
...@@ -20,14 +20,14 @@ namespace video ...@@ -20,14 +20,14 @@ namespace video
namespace scene namespace scene
{ {
//! Helper class for creating geometry on the fly. //! Helper class for creating geometry on the fly.
/** You can get an instance of this class through ISceneManager::getGeometryCreator() */ /** You can get an instance of this class through ISceneManager::getGeometryCreator() */
class IGeometryCreator : public IReferenceCounted class IGeometryCreator : public IReferenceCounted
{ {
public: public:
//! Create a psuedo-random mesh representing a hilly terrain. //! Create a psuedo-random mesh representing a hilly terrain.
/** /**
\param tileSize The size of each time. \param tileSize The size of each time.
\param tileCount The number of tiles in each dimension. \param tileCount The number of tiles in each dimension.
\param material The material to apply to the mesh. \param material The material to apply to the mesh.
...@@ -36,37 +36,44 @@ public: ...@@ -36,37 +36,44 @@ public:
\param textureRepeatCount The number of times to repeat the material texture along each dimension. \param textureRepeatCount The number of times to repeat the material texture along each dimension.
*/ */
virtual IMesh* createHillPlaneMesh( virtual IMesh* createHillPlaneMesh(
const core::dimension2d<f32>& tileSize, const core::dimension2d<u32>& tileCount, const core::dimension2d<f32>& tileSize,
video::SMaterial* material, f32 hillHeight, const core::dimension2d<f32>& countHills, const core::dimension2d<u32>& tileCount,
const core::dimension2d<f32>& textureRepeatCount) const = 0; video::SMaterial* material, f32 hillHeight,
const core::dimension2d<f32>& countHills,
const core::dimension2d<f32>& textureRepeatCount) const =0;
//! Create a terrain mesh from an image representing a heightfield. //! Create a terrain mesh from an image representing a heightfield.
/** /**
\param texture The texture to apply to the terrain. \param texture The texture to apply to the terrain.
\param heightmap An image that will be interpreted as a heightmap. The brightness \param heightmap An image that will be interpreted as a heightmap. The
(average colour) of each pixel is interpreted as a height, with a 255 brightness brightness (average colour) of each pixel is interpreted as a height,
pixel producing the maximum height. with a 255 brightness pixel producing the maximum height.
\param stretchSize The size that each pixel will produce, i.e. a 512x512 heightmap \param stretchSize The size that each pixel will produce, i.e. a
and a stretchSize of (10.f, 20.f) will produce a mesh of size 5120.f x 10240.f 512x512 heightmap
and a stretchSize of (10.f, 20.f) will produce a mesh of size
5120.f x 10240.f
\param maxHeight The maximum height of the terrain. \param maxHeight The maximum height of the terrain.
\param driver The current video driver. \param driver The current video driver.
\param defaultVertexBlockSize (to be documented) \param defaultVertexBlockSize (to be documented)
\param debugBorders (to be documented) \param debugBorders (to be documented)
*/ */
virtual IMesh* createTerrainMesh(video::IImage* texture, virtual IMesh* createTerrainMesh(video::IImage* texture,
video::IImage* heightmap, const core::dimension2d<f32>& stretchSize, video::IImage* heightmap,
f32 maxHeight, video::IVideoDriver* driver, const core::dimension2d<f32>& stretchSize,
const core::dimension2d<u32>& defaultVertexBlockSize, f32 maxHeight, video::IVideoDriver* driver,
bool debugBorders=false) const = 0; const core::dimension2d<u32>& defaultVertexBlockSize,
bool debugBorders=false) const =0;
//! Create an arrow mesh, composed of a cylinder and a cone. //! Create an arrow mesh, composed of a cylinder and a cone.
/** /**
\param tesselationCylinder Number of quads composing the cylinder. \param tesselationCylinder Number of quads composing the cylinder.
\param tesselationCone Number of triangles composing the cone's roof. \param tesselationCone Number of triangles composing the cone's roof.
\param height Total height of the arrow \param height Total height of the arrow
\param cylinderHeight Total height of the cylinder, should be lesser than total height \param cylinderHeight Total height of the cylinder, should be lesser
than total height
\param widthCylinder Diameter of the cylinder \param widthCylinder Diameter of the cylinder
\param widthCone Diameter of the cone's base, should be not smaller than the cylinder's diameter \param widthCone Diameter of the cone's base, should be not smaller
than the cylinder's diameter
\param colorCylinder color of the cylinder \param colorCylinder color of the cylinder
\param colorCone color of the cone \param colorCone color of the cone
*/ */
...@@ -74,7 +81,7 @@ public: ...@@ -74,7 +81,7 @@ public:
const u32 tesselationCone = 8, const f32 height = 1.f, const u32 tesselationCone = 8, const f32 height = 1.f,
const f32 cylinderHeight = 0.6f, const f32 widthCylinder = 0.05f, const f32 cylinderHeight = 0.6f, const f32 widthCylinder = 0.05f,
const f32 widthCone = 0.3f, const video::SColor colorCylinder = 0xFFFFFFFF, const f32 widthCone = 0.3f, const video::SColor colorCylinder = 0xFFFFFFFF,
const video::SColor colorCone = 0xFFFFFFFF) const = 0; const video::SColor colorCone = 0xFFFFFFFF) const =0;
//! Create a sphere mesh. //! Create a sphere mesh.
...@@ -83,8 +90,8 @@ public: ...@@ -83,8 +90,8 @@ public:
\param polyCountX Number of quads used for the horizontal tiling \param polyCountX Number of quads used for the horizontal tiling
\param polyCountY Number of quads used for the vertical tiling \param polyCountY Number of quads used for the vertical tiling
*/ */
virtual IMesh* createSphereMesh(f32 radius = 5.f, u32 polyCountX = 16, virtual IMesh* createSphereMesh(f32 radius = 5.f,
u32 polyCountY = 16) const = 0; u32 polyCountX = 16, u32 polyCountY = 16) const =0;
//! Create a cylinder mesh. //! Create a cylinder mesh.
/** /**
...@@ -95,9 +102,10 @@ public: ...@@ -95,9 +102,10 @@ public:
\param closeTop If true, close the ends of the cylinder, otherwise leave them open. \param closeTop If true, close the ends of the cylinder, otherwise leave them open.
\param oblique (to be documented) \param oblique (to be documented)
*/ */
virtual IMesh* createCylinderMesh(f32 radius, f32 length, u32 tesselation, virtual IMesh* createCylinderMesh(f32 radius, f32 length,
const video::SColor& color=video::SColor(0xffffffff), u32 tesselation,
bool closeTop=true, f32 oblique=0.f) const = 0; const video::SColor& color=video::SColor(0xffffffff),
bool closeTop=true, f32 oblique=0.f) const =0;
//! Create a cone mesh. //! Create a cone mesh.
/** /**
...@@ -108,10 +116,21 @@ public: ...@@ -108,10 +116,21 @@ public:
\param colorBottom The color of the bottom of the cone. \param colorBottom The color of the bottom of the cone.
\param oblique (to be documented) \param oblique (to be documented)
*/ */
virtual IMesh* createConeMesh(f32 radius, f32 length, u32 tesselation, virtual IMesh* createConeMesh(f32 radius, f32 length, u32 tesselation,
const video::SColor& colorTop=video::SColor(0xffffffff), const video::SColor& colorTop=video::SColor(0xffffffff),
const video::SColor& colorBottom=video::SColor(0xffffffff), const video::SColor& colorBottom=video::SColor(0xffffffff),
f32 oblique=0.f) const = 0; f32 oblique=0.f) const =0;
//! Create a volume light mesh.
/**
\param SubdivideU Horizontal patch count.
\param SubdivideV Vertical patch count.
\param FootColor Color at the bottom of the light.
\param TailColor Color at the mid of the light.
*/
virtual IMesh* createVolumeLightMesh(const u32 SubdivideU, const u32 SubdivideV,
const video::SColor FootColor,
const video::SColor TailColor) const =0;
}; };
......
...@@ -164,7 +164,7 @@ namespace scene ...@@ -164,7 +164,7 @@ namespace scene
* <TR> * <TR>
* <TD>3D Studio (.3ds)</TD> * <TD>3D Studio (.3ds)</TD>
* <TD>Loader for 3D-Studio files which lots of 3D packages * <TD>Loader for 3D-Studio files which lots of 3D packages
* are able to export. Only static meshes are currently * are able to export. Only static meshes are currently
* supported by this importer. </TD> * supported by this importer. </TD>
* </TR> * </TR>
* <TR> * <TR>
...@@ -178,7 +178,7 @@ namespace scene ...@@ -178,7 +178,7 @@ namespace scene
* architecture and calculating lighting. Irrlicht can * architecture and calculating lighting. Irrlicht can
* directly import .csm files thanks to the IrrCSM library * directly import .csm files thanks to the IrrCSM library
* created by Saurav Mohapatra which is now integrated * created by Saurav Mohapatra which is now integrated
* directly in Irrlicht. If you are using this loader, * directly in Irrlicht. If you are using this loader,
* please note that you'll have to set the path of the * please note that you'll have to set the path of the
* textures before loading .csm files. You can do this * textures before loading .csm files. You can do this
* using * using
...@@ -188,7 +188,7 @@ namespace scene ...@@ -188,7 +188,7 @@ namespace scene
* <TR> * <TR>
* <TD>COLLADA (.dae, .xml)</TD> * <TD>COLLADA (.dae, .xml)</TD>
* <TD>COLLADA is an open Digital Asset Exchange Schema for * <TD>COLLADA is an open Digital Asset Exchange Schema for
* the interactive 3D industry. There are exporters and * the interactive 3D industry. There are exporters and
* importers for this format available for most of the * importers for this format available for most of the
* big 3d packagesat http://collada.org. Irrlicht can * big 3d packagesat http://collada.org. Irrlicht can
* import COLLADA files by using the * import COLLADA files by using the
...@@ -208,7 +208,7 @@ namespace scene ...@@ -208,7 +208,7 @@ namespace scene
* scene will be added into the scene manager with the * scene will be added into the scene manager with the
* following naming scheme: * following naming scheme:
* path/to/file/file.dea#meshname. The loading of such * path/to/file/file.dea#meshname. The loading of such
* meshes is logged. Currently, this loader is able to * meshes is logged. Currently, this loader is able to
* create meshes (made of only polygons), lights, and * create meshes (made of only polygons), lights, and
* cameras. Materials and animations are currently not * cameras. Materials and animations are currently not
* supported but this will change with future releases. * supported but this will change with future releases.
...@@ -220,7 +220,7 @@ namespace scene ...@@ -220,7 +220,7 @@ namespace scene
* combined into one and is specifically designed for 3D * combined into one and is specifically designed for 3D
* game-development. With this loader, it is possible to * game-development. With this loader, it is possible to
* directly load all geometry is as well as textures and * directly load all geometry is as well as textures and
* lightmaps from .dmf files. To set texture and * lightmaps from .dmf files. To set texture and
* material paths, see scene::DMF_USE_MATERIALS_DIRS and * material paths, see scene::DMF_USE_MATERIALS_DIRS and
* scene::DMF_TEXTURE_PATH. It is also possible to flip * scene::DMF_TEXTURE_PATH. It is also possible to flip
* the alpha texture by setting * the alpha texture by setting
...@@ -242,7 +242,7 @@ namespace scene ...@@ -242,7 +242,7 @@ namespace scene
* and there are several tools for them available, e.g. * and there are several tools for them available, e.g.
* the Maya exporter included in the DX SDK. * the Maya exporter included in the DX SDK.
* .x files can include skeletal animations and Irrlicht * .x files can include skeletal animations and Irrlicht
* is able to play and display them. Currently, Irrlicht * is able to play and display them. Currently, Irrlicht
* only supports uncompressed .x files.</TD> * only supports uncompressed .x files.</TD>
* </TR> * </TR>
* <TR> * <TR>
...@@ -257,7 +257,7 @@ namespace scene ...@@ -257,7 +257,7 @@ namespace scene
* <TD>.MS3D files contain models and sometimes skeletal * <TD>.MS3D files contain models and sometimes skeletal
* animations from the Milkshape 3D modeling and animation * animations from the Milkshape 3D modeling and animation
* software. This importer for Irrlicht can display and/or * software. This importer for Irrlicht can display and/or
* animate these files. </TD> * animate these files. </TD>
* </TR> * </TR>
* <TR> * <TR>
* <TD>My3D (.my3d)</TD> * <TD>My3D (.my3d)</TD>
...@@ -268,7 +268,7 @@ namespace scene ...@@ -268,7 +268,7 @@ namespace scene
* loader was written by Zhuck Dimitry who also created * loader was written by Zhuck Dimitry who also created
* the whole My3DTools package. If you are using this * the whole My3DTools package. If you are using this
* loader, please note that you can set the path of the * loader, please note that you can set the path of the
* textures before loading .my3d files. You can do this * textures before loading .my3d files. You can do this
* using * using
* SceneManager-&gt;getParameters()-&gt;setAttribute(scene::MY3D_TEXTURE_PATH, * SceneManager-&gt;getParameters()-&gt;setAttribute(scene::MY3D_TEXTURE_PATH,
* &quot;path/to/your/textures&quot;); * &quot;path/to/your/textures&quot;);
...@@ -298,11 +298,11 @@ namespace scene ...@@ -298,11 +298,11 @@ namespace scene
* <TR> * <TR>
* <TD>Pulsar LMTools (.lmts)</TD> * <TD>Pulsar LMTools (.lmts)</TD>
* <TD>LMTools is a set of tools (Windows &amp; Linux) for * <TD>LMTools is a set of tools (Windows &amp; Linux) for
* creating lightmaps. Irrlicht can directly read .lmts * creating lightmaps. Irrlicht can directly read .lmts
* files thanks to<br> the importer created by Jonas * files thanks to<br> the importer created by Jonas
* Petersen. If you are using this loader, please note * Petersen. If you are using this loader, please note
* that you can set the path of the textures before * that you can set the path of the textures before
* loading .lmts files. You can do this using * loading .lmts files. You can do this using
* SceneManager-&gt;getParameters()-&gt;setAttribute(scene::LMTS_TEXTURE_PATH, * SceneManager-&gt;getParameters()-&gt;setAttribute(scene::LMTS_TEXTURE_PATH,
* &quot;path/to/your/textures&quot;); * &quot;path/to/your/textures&quot;);
* Notes for<br> this version of the loader:<br> * Notes for<br> this version of the loader:<br>
...@@ -376,10 +376,10 @@ namespace scene ...@@ -376,10 +376,10 @@ namespace scene
//! adds Volume Lighting Scene Node. //! adds Volume Lighting Scene Node.
/** Example Usage: /** Example Usage:
scene::IVolumeLightSceneNode * n = smgr->addVolumeLightSceneNode(NULL, -1, scene::IVolumeLightSceneNode * n = smgr->addVolumeLightSceneNode(0, -1,
32, 32, //Subdivide U/V 32, 32, //Subdivide U/V
video::SColor(0, 180, 180, 180), //foot color video::SColor(0, 180, 180, 180), //foot color
video::SColor(0, 0, 0, 0) //tail color video::SColor(0, 0, 0, 0) //tail color
); );
if (n) if (n)
{ {
...@@ -396,7 +396,6 @@ namespace scene ...@@ -396,7 +396,6 @@ namespace scene
const core::vector3df& rotation = core::vector3df(0,0,0), const core::vector3df& rotation = core::vector3df(0,0,0),
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0;
//! Adds a test scene node for test purposes to the scene. //! Adds a test scene node for test purposes to the scene.
/** It is a simple cube of (1,1,1) size. /** It is a simple cube of (1,1,1) size.
\param size: Size of the cube. \param size: Size of the cube.
...@@ -557,15 +556,17 @@ namespace scene ...@@ -557,15 +556,17 @@ namespace scene
f32 translationSpeed = 1500.0f, s32 id=-1) = 0; f32 translationSpeed = 1500.0f, s32 id=-1) = 0;
//! Adds a camera scene node with an animator which provides mouse and keyboard control appropriate for first person shooters (FPS). //! Adds a camera scene node with an animator which provides mouse and keyboard control appropriate for first person shooters (FPS).
/** This FPS camera is intended to provide a demonstration of a camera that behaves /** This FPS camera is intended to provide a demonstration of a
like a typical First Person Shooter. It is useful for simple demos and prototyping but is not camera that behaves like a typical First Person Shooter. It is
intended to provide a full solution for a production quality game. It binds the camera scene node useful for simple demos and prototyping but is not intended to
rotation to the look-at target; @see ICameraSceneNode::bindTargetAndRotation(). provide a full solution for a production quality game. It binds
With this camera, you look with the mouse, and move with cursor keys. If you want to the camera scene node rotation to the look-at target; @see
change the key layout, you can specify your own keymap. For example to make the camera ICameraSceneNode::bindTargetAndRotation(). With this camera,
be controlled by the cursor keys AND the keys W,A,S, and D, do something you look with the mouse, and move with cursor keys. If you want
like this: to change the key layout, you can specify your own keymap. For
\code example to make the camera be controlled by the cursor keys AND
the keys W,A,S, and D, do something like this:
\code
SKeyMap keyMap[8]; SKeyMap keyMap[8];
keyMap[0].Action = EKA_MOVE_FORWARD; keyMap[0].Action = EKA_MOVE_FORWARD;
keyMap[0].KeyCode = KEY_UP; keyMap[0].KeyCode = KEY_UP;
...@@ -594,23 +595,27 @@ namespace scene ...@@ -594,23 +595,27 @@ namespace scene
rotated. This can be done only with the mouse. rotated. This can be done only with the mouse.
\param moveSpeed: Speed in units per millisecond with which \param moveSpeed: Speed in units per millisecond with which
the camera is moved. Movement is done with the cursor keys. the camera is moved. Movement is done with the cursor keys.
\param id: id of the camera. This id can be used to identify the camera. \param id: id of the camera. This id can be used to identify
\param keyMapArray: Optional pointer to an array of a keymap, specifying what the camera.
keys should be used to move the camera. If this is null, the default keymap \param keyMapArray: Optional pointer to an array of a keymap,
is used. You can define actions more then one time in the array, to bind specifying what keys should be used to move the camera. If this
multiple keys to the same action. is null, the default keymap is used. You can define actions
more then one time in the array, to bind multiple keys to the
same action.
\param keyMapSize: Amount of items in the keymap array. \param keyMapSize: Amount of items in the keymap array.
\param noVerticalMovement: Setting this to true makes the \param noVerticalMovement: Setting this to true makes the
camera only move within a horizontal plane, and disables camera only move within a horizontal plane, and disables
vertical movement as known from most ego shooters. Default is vertical movement as known from most ego shooters. Default is
'false', with which it is possible to fly around in space, if 'false', with which it is possible to fly around in space, if
no gravity is there. no gravity is there.
\param jumpSpeed: Speed with which the camera is moved when jumping. \param jumpSpeed: Speed with which the camera is moved when
\param invertMouse: Setting this to true makes the camera look up when jumping.
the mouse is moved down and down when the mouse is moved up, the default \param invertMouse: Setting this to true makes the camera look
is 'false' which means it will follow the movement of the mouse cursor. up when the mouse is moved down and down when the mouse is
\return Pointer to the interface of the camera if successful, otherwise 0. moved up, the default is 'false' which means it will follow the
This pointer should not be dropped. See movement of the mouse cursor.
\return Pointer to the interface of the camera if successful,
otherwise 0. This pointer should not be dropped. See
IReferenceCounted::drop() for more information. */ IReferenceCounted::drop() for more information. */
virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0,
f32 rotateSpeed = 100.0f, f32 moveSpeed = 0.5f, s32 id=-1, f32 rotateSpeed = 100.0f, f32 moveSpeed = 0.5f, s32 id=-1,
...@@ -851,11 +856,11 @@ namespace scene ...@@ -851,11 +856,11 @@ namespace scene
ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0), ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0),
s32 id=-1) = 0; s32 id=-1) = 0;
//! Adds a text scene node, which uses billboards. The node, and the text on it, will scale with distance. //! Adds a text scene node, which uses billboards. The node, and the text on it, will scale with distance.
/** /**
\param font The font to use on the billboard. Pass 0 to use the GUI environment's default font. \param font The font to use on the billboard. Pass 0 to use the GUI environment's default font.
\param text The text to display on the billboard. \param text The text to display on the billboard.
\param parent The billboard's parent. Pass 0 to use the root scene node. \param parent The billboard's parent. Pass 0 to use the root scene node.
\param size The billboard's width and height. \param size The billboard's width and height.
\param position The billboards position relative to its parent. \param position The billboards position relative to its parent.
\param id: An id of the node. This id can be used to identify the node. \param id: An id of the node. This id can be used to identify the node.
...@@ -961,6 +966,16 @@ namespace scene ...@@ -961,6 +966,16 @@ namespace scene
f32 radius=5.f, u32 polyCountX = 16, f32 radius=5.f, u32 polyCountX = 16,
u32 polyCountY = 16) = 0; u32 polyCountY = 16) = 0;
//! Add a volume light mesh to the meshpool
/** \param name Name of the mesh
\return Pointer to the volume light mesh if successful, otherwise 0.
This pointer should not be dropped. See IReferenceCounted::drop() for more information.
*/
virtual IAnimatedMesh* addVolumeLightMesh(const core::string<c16>& name,
const u32 SubdivideU = 32, const u32 SubdivideV = 32,
const video::SColor FootColor = video::SColor(51, 0, 230, 180),
const video::SColor TailColor = video::SColor(0, 0, 0, 0)) = 0;
//! Gets the root scene node. //! Gets the root scene node.
/** This is the scene node which is parent /** This is the scene node which is parent
of all scene nodes. The root scene node is a special scene node which of all scene nodes. The root scene node is a special scene node which
...@@ -1060,9 +1075,9 @@ namespace scene ...@@ -1060,9 +1075,9 @@ namespace scene
\param speed: The orbital speed, in radians per millisecond. \param speed: The orbital speed, in radians per millisecond.
\param direction: Specifies the upvector used for alignment of the mesh. \param direction: Specifies the upvector used for alignment of the mesh.
\param startPosition: The position on the circle where the animator will \param startPosition: The position on the circle where the animator will
begin. Value is in multiples of a circle, i.e. 0.5 is half way around. (phase) begin. Value is in multiples of a circle, i.e. 0.5 is half way around. (phase)
\param radiusEllipsoid: if radiusEllipsoid != 0 then radius2 froms a ellipsoid \param radiusEllipsoid: if radiusEllipsoid != 0 then radius2 froms a ellipsoid
begin. Value is in multiples of a circle, i.e. 0.5 is half way around. (phase) begin. Value is in multiples of a circle, i.e. 0.5 is half way around. (phase)
\return The animator. Attach it to a scene node with ISceneNode::addAnimator() \return The animator. Attach it to a scene node with ISceneNode::addAnimator()
and the animator will animate it. and the animator will animate it.
If you no longer need the animator, you should call ISceneNodeAnimator::drop(). If you no longer need the animator, you should call ISceneNodeAnimator::drop().
...@@ -1116,7 +1131,7 @@ namespace scene ...@@ -1116,7 +1131,7 @@ namespace scene
ISceneManager::createTriangleSelector(); ISceneManager::createTriangleSelector();
\param sceneNode: SceneNode which should be manipulated. After you added this animator \param sceneNode: SceneNode which should be manipulated. After you added this animator
to the scene node, the scene node will not be able to move through walls and is to the scene node, the scene node will not be able to move through walls and is
affected by gravity. If you need to teleport the scene node to a new position without affected by gravity. If you need to teleport the scene node to a new position without
it being effected by the collision geometry, then call sceneNode->setPosition(); then it being effected by the collision geometry, then call sceneNode->setPosition(); then
animator->setTargetNode(sceneNode); animator->setTargetNode(sceneNode);
\param ellipsoidRadius: Radius of the ellipsoid with which collision detection and \param ellipsoidRadius: Radius of the ellipsoid with which collision detection and
...@@ -1431,13 +1446,13 @@ namespace scene ...@@ -1431,13 +1446,13 @@ namespace scene
virtual const video::SColorf& getAmbientLight() const = 0; virtual const video::SColorf& getAmbientLight() const = 0;
//! Register a custom callbacks manager which gets callbacks during scene rendering. //! Register a custom callbacks manager which gets callbacks during scene rendering.
/** \param[in] lightManager: the new callbacks manager. You may pass 0 to remove the /** \param[in] lightManager: the new callbacks manager. You may pass 0 to remove the
current callbacks manager and restore the default behaviour. */ current callbacks manager and restore the default behaviour. */
virtual void setLightManager(ILightManager* lightManager) = 0; virtual void setLightManager(ILightManager* lightManager) = 0;
//! Get an instance of a geometry creator. //! Get an instance of a geometry creator.
/** The geometry creator provides some helper methods to create various types of /** The geometry creator provides some helper methods to create various types of
basic geometry. This can be useful for custom scene nodes. */ basic geometry. This can be useful for custom scene nodes. */
virtual const IGeometryCreator* getGeometryCreator(void) const = 0; virtual const IGeometryCreator* getGeometryCreator(void) const = 0;
}; };
......
...@@ -680,6 +680,160 @@ IMesh* CGeometryCreator::createConeMesh(f32 radius, f32 length, u32 tesselation, ...@@ -680,6 +680,160 @@ IMesh* CGeometryCreator::createConeMesh(f32 radius, f32 length, u32 tesselation,
} }
void CGeometryCreator::addToBuffer(const video::S3DVertex& v, SMeshBuffer* Buffer) const
{
const s32 tnidx = Buffer->Vertices.linear_reverse_search(v);
const bool alreadyIn = (tnidx != -1);
u16 nidx = (u16)tnidx;
if (!alreadyIn)
{
nidx = (u16)Buffer->Vertices.size();
Buffer->Indices.push_back(nidx);
Buffer->Vertices.push_back(v);
}
else
Buffer->Indices.push_back(nidx);
}
IMesh* CGeometryCreator::createVolumeLightMesh(
const u32 SubdivideU, const u32 SubdivideV,
const video::SColor FootColor, const video::SColor TailColor) const
{
const f32 LPDistance = 8.0f;
const core::vector3df LightDimensions = core::vector3df(1.0f, 1.2f, 1.0f) ;
SMeshBuffer* Buffer = new SMeshBuffer();
Buffer->setHardwareMappingHint(EHM_STATIC);
const core::vector3df lightPoint(0, -(LPDistance*LightDimensions.Y), 0);
const f32 ax = LightDimensions.X * 0.5f; // X Axis
const f32 az = LightDimensions.Z * 0.5f; // Z Axis
Buffer->Vertices.clear();
Buffer->Vertices.reallocate(6+12*(SubdivideU+SubdivideV));
Buffer->Indices.clear();
Buffer->Indices.reallocate(6+12*(SubdivideU+SubdivideV));
//draw the bottom foot.. the glowing region
addToBuffer(video::S3DVertex(-ax, 0, az, 0,0,0, FootColor, 0, 1),Buffer);
addToBuffer(video::S3DVertex( ax, 0, az, 0,0,0, FootColor, 1, 1),Buffer);
addToBuffer(video::S3DVertex( ax, 0,-az, 0,0,0, FootColor, 1, 0),Buffer);
addToBuffer(video::S3DVertex( ax, 0,-az, 0,0,0, FootColor, 1, 0),Buffer);
addToBuffer(video::S3DVertex(-ax, 0,-az, 0,0,0, FootColor, 0, 0),Buffer);
addToBuffer(video::S3DVertex(-ax, 0, az, 0,0,0, FootColor, 0, 1),Buffer);
f32 tu = 0.f;
const f32 tuStep = 1.f/SubdivideU;
f32 bx = -ax;
const f32 bxStep = LightDimensions.X * tuStep;
// Slices in X/U space
for (u32 i = 0; i <= SubdivideU; ++i)
{
// These are the two endpoints for a slice at the foot
core::vector3df end1(bx, 0.0f, -az);
core::vector3df end2(bx, 0.0f, az);
end1 -= lightPoint; // get a vector from point to lightsource
end1.normalize(); // normalize vector
end1 *= LightDimensions.Y; // multiply it out by shootlength
end1.X += bx; // Add the original point location to the vector
end1.Z -= az;
// Do it again for the other point.
end2 -= lightPoint;
end2.normalize();
end2 *= LightDimensions.Y;
end2.X += bx;
end2.Z += az;
addToBuffer(video::S3DVertex(bx , 0, az, 0,0,0, FootColor, tu, 1),Buffer);
addToBuffer(video::S3DVertex(bx , 0, -az, 0,0,0, FootColor, tu, 0),Buffer);
addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, TailColor, tu, 1),Buffer);
addToBuffer(video::S3DVertex(bx , 0, -az, 0,0,0, FootColor, tu, 0),Buffer);
addToBuffer(video::S3DVertex(end1.X , end1.Y, end1.Z, 0,0,0, TailColor, tu, 0),Buffer);
addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, TailColor, tu, 1),Buffer);
//back side
addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, TailColor, tu, 1),Buffer);
addToBuffer(video::S3DVertex(-bx , 0, -az, 0,0,0, FootColor, tu, 1),Buffer);
addToBuffer(video::S3DVertex(-bx , 0, az, 0,0,0, FootColor, tu, 0),Buffer);
addToBuffer(video::S3DVertex(-bx , 0, az, 0,0,0, FootColor, tu, 0),Buffer);
addToBuffer(video::S3DVertex(-end1.X , end1.Y, -end1.Z, 0,0,0, TailColor, tu, 0),Buffer);
addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, TailColor, tu, 1),Buffer);
tu += tuStep;
bx += bxStep;
}
f32 tv = 0.f;
const f32 tvStep = 1.f/SubdivideV;
f32 bz = -az;
const f32 bzStep = LightDimensions.Z * tvStep;
// Slices in Z/V space
for(u32 i = 0; i <= SubdivideV; ++i)
{
// These are the two endpoints for a slice at the foot
core::vector3df end1(-ax, 0.0f, bz);
core::vector3df end2(ax, 0.0f, bz);
end1 -= lightPoint; // get a vector from point to lightsource
end1.normalize(); // normalize vector
end1 *= LightDimensions.Y; // multiply it out by shootlength
end1.X -= ax; // Add the original point location to the vector
end1.Z += bz;
// Do it again for the other point.
end2 -= lightPoint;
end2.normalize();
end2 *= LightDimensions.Y;
end2.X += ax;
end2.Z += bz;
addToBuffer(video::S3DVertex(-ax , 0, bz, 0,0,0, FootColor, 0, tv),Buffer);
addToBuffer(video::S3DVertex(ax , 0, bz, 0,0,0, FootColor, 1, tv),Buffer);
addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, TailColor, 1, tv),Buffer);
addToBuffer(video::S3DVertex(end2.X , end2.Y, end2.Z, 0,0,0, TailColor, 1, tv),Buffer);
addToBuffer(video::S3DVertex(end1.X , end1.Y, end1.Z, 0,0,0, TailColor, 0, tv),Buffer);
addToBuffer(video::S3DVertex(-ax , 0, bz, 0,0,0, FootColor, 0, tv),Buffer);
//back side
addToBuffer(video::S3DVertex(ax , 0, -bz, 0,0,0, FootColor, 0, tv),Buffer);
addToBuffer(video::S3DVertex(-ax , 0, -bz, 0,0,0, FootColor, 1, tv),Buffer);
addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, TailColor, 1, tv),Buffer);
addToBuffer(video::S3DVertex(-end2.X , end2.Y, -end2.Z, 0,0,0, TailColor, 1, tv),Buffer);
addToBuffer(video::S3DVertex(-end1.X , end1.Y, -end1.Z, 0,0,0, TailColor, 0, tv),Buffer);
addToBuffer(video::S3DVertex(ax , 0, -bz, 0,0,0, FootColor, 0, tv),Buffer);
tv += tvStep;
bz += bzStep;
}
Buffer->recalculateBoundingBox();
Buffer->Material.MaterialType = video::EMT_ONETEXTURE_BLEND;
Buffer->Material.MaterialTypeParam = pack_texureBlendFunc( video::EBF_SRC_COLOR, video::EBF_SRC_ALPHA, video::EMFN_MODULATE_1X );
Buffer->Material.Lighting = false;
Buffer->Material.ZWriteEnable = false;
Buffer->setDirty(EBT_VERTEX_AND_INDEX);
Buffer->recalculateBoundingBox();
SMesh* mesh = new SMesh();
mesh->addMeshBuffer(Buffer);
Buffer->drop();
mesh->recalculateBoundingBox();
return mesh;
}
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define __C_GEOMETRY_CREATOR_H_INCLUDED__ #define __C_GEOMETRY_CREATOR_H_INCLUDED__
#include "IGeometryCreator.h" #include "IGeometryCreator.h"
#include "SMeshBuffer.h"
namespace irr namespace irr
{ {
...@@ -16,6 +17,7 @@ namespace scene ...@@ -16,6 +17,7 @@ namespace scene
//! class for creating geometry on the fly //! class for creating geometry on the fly
class CGeometryCreator : public IGeometryCreator class CGeometryCreator : public IGeometryCreator
{ {
void addToBuffer(const video::S3DVertex& v, SMeshBuffer* Buffer) const;
public: public:
IMesh* createHillPlaneMesh( IMesh* createHillPlaneMesh(
...@@ -44,6 +46,10 @@ public: ...@@ -44,6 +46,10 @@ public:
IMesh* createConeMesh(f32 radius, f32 length, u32 tesselation, IMesh* createConeMesh(f32 radius, f32 length, u32 tesselation,
const video::SColor& colorTop=video::SColor(0xffffffff), const video::SColor& colorTop=video::SColor(0xffffffff),
const video::SColor& colorBottom=video::SColor(0xffffffff), f32 oblique=0.f) const; const video::SColor& colorBottom=video::SColor(0xffffffff), f32 oblique=0.f) const;
IMesh* createVolumeLightMesh(const u32 SubdivideU, const u32 SubdivideV,
const video::SColor FootColor,
const video::SColor TailColor) const;
}; };
......
...@@ -504,12 +504,14 @@ IMeshSceneNode* CSceneManager::addQuake3SceneNode(IMeshBuffer* meshBuffer, ...@@ -504,12 +504,14 @@ IMeshSceneNode* CSceneManager::addQuake3SceneNode(IMeshBuffer* meshBuffer,
#endif #endif
} }
//! adds Volume Lighting Scene Node. //! adds Volume Lighting Scene Node.
//! the returned pointer must not be dropped. //! the returned pointer must not be dropped.
IVolumeLightSceneNode* CSceneManager::addVolumeLightSceneNode(ISceneNode* parent, s32 id, IVolumeLightSceneNode* CSceneManager::addVolumeLightSceneNode(
const u32 subdivU, const u32 subdivV, ISceneNode* parent, s32 id,
const video::SColor foot, const video::SColor tail, const u32 subdivU, const u32 subdivV,
const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) const video::SColor foot, const video::SColor tail,
const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale)
{ {
if (!parent) if (!parent)
parent = this; parent = this;
...@@ -520,6 +522,7 @@ IVolumeLightSceneNode* CSceneManager::addVolumeLightSceneNode(ISceneNode* parent ...@@ -520,6 +522,7 @@ IVolumeLightSceneNode* CSceneManager::addVolumeLightSceneNode(ISceneNode* parent
return node; return node;
} }
//! adds a test scene node for test purposes to the scene. It is a simple cube of (1,1,1) size. //! adds a test scene node for test purposes to the scene. It is a simple cube of (1,1,1) size.
//! the returned pointer must not be dropped. //! the returned pointer must not be dropped.
IMeshSceneNode* CSceneManager::addCubeSceneNode(f32 size, ISceneNode* parent, IMeshSceneNode* CSceneManager::addCubeSceneNode(f32 size, ISceneNode* parent,
...@@ -1037,6 +1040,36 @@ IAnimatedMesh* CSceneManager::addSphereMesh(const core::string<c16>& name, ...@@ -1037,6 +1040,36 @@ IAnimatedMesh* CSceneManager::addSphereMesh(const core::string<c16>& name,
//! Adds a static volume light mesh to the mesh pool.
IAnimatedMesh* CSceneManager::addVolumeLightMesh(const core::string<c16>& name,
const u32 SubdivideU, const u32 SubdivideV,
const video::SColor FootColor, const video::SColor TailColor)
{
if (MeshCache->isMeshLoaded(name))
return MeshCache->getMeshByFilename(name);
IMesh* mesh = GeometryCreator->createVolumeLightMesh(SubdivideU, SubdivideV, FootColor, TailColor);
if (!mesh)
return 0;
SAnimatedMesh* animatedMesh = new SAnimatedMesh();
if (!animatedMesh)
{
mesh->drop();
return 0;
}
animatedMesh->addMesh(mesh);
mesh->drop();
animatedMesh->recalculateBoundingBox();
MeshCache->addMesh(name, animatedMesh);
animatedMesh->drop();
return animatedMesh;
}
//! Returns the root scene node. This is the scene node wich is parent //! Returns the root scene node. This is the scene node wich is parent
//! of all scene nodes. The root scene node is a special scene node which //! of all scene nodes. The root scene node is a special scene node which
//! only exists to manage all scene nodes. It is not rendered and cannot //! only exists to manage all scene nodes. It is not rendered and cannot
......
...@@ -226,6 +226,12 @@ namespace scene ...@@ -226,6 +226,12 @@ namespace scene
IAnimatedMesh* addSphereMesh(const core::string<c16>& name, IAnimatedMesh* addSphereMesh(const core::string<c16>& name,
f32 radius=5.f, u32 polyCountX=16, u32 polyCountY=16); f32 radius=5.f, u32 polyCountX=16, u32 polyCountY=16);
//! Adds a static volume light mesh to the mesh pool.
IAnimatedMesh* addVolumeLightMesh(const core::string<c16>& name,
const u32 SubdivideU = 32, const u32 SubdivideV = 32,
const video::SColor FootColor = video::SColor(51, 0, 230, 180),
const video::SColor TailColor = video::SColor(0, 0, 0, 0));
//! Adds a particle system scene node. //! Adds a particle system scene node.
virtual IParticleSystemSceneNode* addParticleSystemSceneNode( virtual IParticleSystemSceneNode* addParticleSystemSceneNode(
bool withDefaultEmitter=true, ISceneNode* parent=0, s32 id=-1, bool withDefaultEmitter=true, ISceneNode* parent=0, s32 id=-1,
......
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