Commit bda0b6e3 authored by hybrid's avatar hybrid

Merged SkinnedMesh branch 658:895 into trunk.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@896 dfc29bdd-3216-0410-991c-e03cc46cb475
parent f3a8858e
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
#include "IUnknown.h" #include "IUnknown.h"
#include "aabbox3d.h" #include "aabbox3d.h"
#include "IMesh.h"
namespace irr namespace irr
{ {
namespace scene namespace scene
{ {
class IMesh;
enum E_ANIMATED_MESH_TYPE enum E_ANIMATED_MESH_TYPE
{ {
...@@ -57,8 +57,8 @@ namespace scene ...@@ -57,8 +57,8 @@ namespace scene
//! be loaded directly by Irrlicht //! be loaded directly by Irrlicht
EAMT_OCT, EAMT_OCT,
//! Blitz Basic .b3d file, the file format by Mark Sibly //! genetic skinned mesh
EAMT_B3D EAMT_SKINNED
}; };
//! Interface for an animated mesh. //! Interface for an animated mesh.
...@@ -66,7 +66,7 @@ namespace scene ...@@ -66,7 +66,7 @@ namespace scene
you don't have to implement this interface on your own if you need to: you don't have to implement this interface on your own if you need to:
You might want to use irr::scene::SAnimatedMesh, irr::scene::SMesh, You might want to use irr::scene::SAnimatedMesh, irr::scene::SMesh,
irr::scene::SMeshBuffer etc. */ irr::scene::SMeshBuffer etc. */
class IAnimatedMesh : public virtual IUnknown class IAnimatedMesh : public IMesh
{ {
public: public:
......
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_ANIMATED_MESH_B3D_H_INCLUDED__
#define __I_ANIMATED_MESH_B3D_H_INCLUDED__
#include "IAnimatedMesh.h"
#include "irrArray.h"
#include "matrix4.h"
namespace irr
{
namespace scene
{
class ISceneNode;
class ISceneManager;
//! Interface for using some special functions of B3d meshes
/** Please note that the B3d Mesh's frame numbers are scaled by 100 */
class IAnimatedMeshB3d : public IAnimatedMesh
{
public:
//! Returns a pointer to a transformation matrix of a part of the
//! mesh based on a frame time. This is used for being able to attach
//! objects to parts of animated meshes. For example a weapon to an animated
//! hand.
//! \param jointNumber: Zero based index of joint. The last joint has the number
//! IAnimatedMeshB3d::getJointCount()-1;
//! \param frame: Frame of the animation.
//! \return Returns a pointer to the matrix of the mesh part or
//! null if an error occured.
virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame) = 0;
//! Returns a pointer to a local matrix of a Joint, can be used to control the animation
virtual core::matrix4* getLocalMatrixOfJoint(s32 jointNumber) = 0;
//! Returns a pointer to a matrix of a part of the mesh unanimated
virtual core::matrix4* getMatrixOfJointUnanimated(s32 jointNumber) = 0;
//! Move this Joint's local matrix when animating
//! \param jointNumber: Zero based index of joint. The last joint has the number
//! IAnimatedMeshB3d::getJointCount()-1;
//! \param On: False= Leave joint's local matrix, True= Animate
//! (not used yet)
virtual void setJointAnimation(s32 jointNumber, bool On) = 0;
//! Gets joint count.
//! \return Returns amount of joints in the skeletal animated mesh.
virtual s32 getJointCount() const = 0;
//! Gets the name of a joint.
//! \param number: Zero based index of joint. The last joint has the number
//! IAnimatedMeshB3d::getJointCount()-1;
//! \return Returns name of joint and null if an error happened.
virtual const c8* getJointName(s32 number) const = 0;
//! Gets a joint number from its name
//! \param name: Name of the joint.
//! \return Returns the number of the joint or -1 if not found.
virtual s32 getJointNumber(const c8* name) const = 0;
//!Update Normals when Animating
//!False= Don't (default)
//!True= Update normals, slower
virtual void updateNormalsWhenAnimating(bool on) = 0;
//!Sets Interpolation Mode
//!0- Constant
//!1- Linear (default)
virtual void setInterpolationMode(s32 mode) = 0;
//!Want should happen on when animating
//!0-Nothing
//!1-Update nodes only
//!2-Update skin only
//!3-Update both nodes and skin (default)
virtual void setAnimateMode(s32 mode) = 0;
//!Convert all mesh buffers to use tangent vertices
virtual void convertToTangents() =0;
virtual void recoverJointsFromMesh(core::array<ISceneNode*> &JointChildSceneNodes)=0;
virtual void tranferJointsToMesh(core::array<ISceneNode*> &JointChildSceneNodes)=0;
virtual void createJoints(core::array<ISceneNode*> &JointChildSceneNodes, ISceneNode* AnimatedMeshSceneNode, ISceneManager* SceneManager)=0;
};
} // end namespace scene
} // end namespace irr
#endif
// Copyright (C) 2002-2007 Nikolaus Gebhardt / Fabio Concas / Thomas Alten
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_ANIMATED_MESH_MS3D_H_INCLUDED__
#define __I_ANIMATED_MESH_MS3D_H_INCLUDED__
#include "IAnimatedMesh.h"
#include "matrix4.h"
namespace irr
{
namespace scene
{
//! Interface for using some special functions of MS3D meshes
class IAnimatedMeshMS3D : public IAnimatedMesh
{
public:
//! Returns a pointer to a transformation matrix of a part of the
//! mesh based on a frame time. This is used for being able to attach
//! objects to parts of animated meshes. For example a weapon to an animated
//! hand.
//! \param jointNumber: Zero based index of joint. The last joint has the number
//! IAnimatedMeshMS3D::getJointCount()-1;
//! \param frame: Frame of the animation.
//! \return Returns a pointer to the matrix of the mesh part or
//! null if an error occured.
virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame) = 0;
//! Gets joint count.
//! \return Returns amount of joints in the skeletal animated mesh.
virtual s32 getJointCount() const = 0;
//! Gets the name of a joint.
//! \param number: Zero based index of joint. The last joint has the number
//! IAnimatedMeshMS3D::getJointCount()-1;
//! \return Returns name of joint and null if an error happened.
virtual const c8* getJointName(s32 number) const = 0;
//! Gets a joint number from its name
//! \param name: Name of the joint.
//! \return Returns the number of the joint or -1 if not found.
virtual s32 getJointNumber(const c8* name) const = 0;
};
} // end namespace scene
} // end namespace irr
#endif
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define __I_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__ #define __I_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__
#include "ISceneNode.h" #include "ISceneNode.h"
#include "IBoneSceneNode.h"
#include "IAnimatedMeshMD2.h" #include "IAnimatedMeshMD2.h"
#include "IAnimatedMeshMD3.h" #include "IAnimatedMeshMD3.h"
#include "IShadowVolumeSceneNode.h" #include "IShadowVolumeSceneNode.h"
...@@ -54,7 +55,7 @@ namespace scene ...@@ -54,7 +55,7 @@ namespace scene
//! \param frame: Number of the frame to let the animation be started from. //! \param frame: Number of the frame to let the animation be started from.
//! The frame number must be a valid frame number of the IMesh used by this //! The frame number must be a valid frame number of the IMesh used by this
//! scene node. Set IAnimatedMesh::getMesh() for details. //! scene node. Set IAnimatedMesh::getMesh() for details.
virtual void setCurrentFrame(s32 frame) = 0; virtual void setCurrentFrame(f32 frame) = 0;
//! Sets the frame numbers between the animation is looped. //! Sets the frame numbers between the animation is looped.
//! The default is 0 - MaximalFrameCount of the mesh. //! The default is 0 - MaximalFrameCount of the mesh.
...@@ -84,6 +85,7 @@ namespace scene ...@@ -84,6 +85,7 @@ namespace scene
virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(s32 id=-1, virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(s32 id=-1,
bool zfailmethod=true, f32 infinity=10000.0f) = 0; bool zfailmethod=true, f32 infinity=10000.0f) = 0;
//! Returns a pointer to a child node, which has the same transformation as //! Returns a pointer to a child node, which has the same transformation as
//! the corresponding joint, if the mesh in this scene node is a ms3d mesh. //! the corresponding joint, if the mesh in this scene node is a ms3d mesh.
//! Otherwise 0 is returned. With this method it is possible to //! Otherwise 0 is returned. With this method it is possible to
...@@ -92,26 +94,26 @@ namespace scene ...@@ -92,26 +94,26 @@ namespace scene
//! animated model. This example shows how: //! animated model. This example shows how:
//! \code //! \code
//! ISceneNode* hand = //! ISceneNode* hand =
//! yourMS3DAnimatedMeshSceneNode->getMS3DJointNode("LeftHand"); //! yourAnimatedMeshSceneNode->getJointNode("LeftHand");
//! hand->addChild(weaponSceneNode); //! hand->addChild(weaponSceneNode);
//! \endcode //! \endcode
//! Please note that the SceneNode returned by this method may not exist //! Please note that the SceneNode returned by this method may not exist
//! before this call and is created by it. //! before this call and is created by it. (Todo: Rewrite)
//! \param jointName: Name of the joint. //! \param jointName: Name of the joint.
//! \return Returns a pointer to the scene node which represents the joint //! \return Returns a pointer to the scene node which represents the joint
//! with the specified name. Returns 0 if the contained mesh is not an //! with the specified name. Returns 0 if the contained mesh is not an
//! ms3d mesh or the name of the joint could not be found. //! ms3d mesh or the name of the joint could not be found.
virtual ISceneNode* getMS3DJointNode(const c8* jointName) = 0; virtual IBoneSceneNode* getJointNode(const c8* jointName)=0;
//! Returns a pointer to a child node, which has the same transformation as //! Returns a pointer to a child node, which has the same transformation as
//! the corresponding joint, if the mesh in this scene node is a x mesh. //! the corresponding joint, if the mesh in this scene node is a ms3d mesh.
//! Otherwise 0 is returned. With this method it is possible to //! Otherwise 0 is returned. With this method it is possible to
//! attach scene nodes to joints more easily. In this way, it is //! attach scene nodes to joints more easily. In this way, it is
//! for example possible to attach a weapon to the left hand of an //! for example possible to attach a weapon to the left hand of an
//! animated model. This example shows how: //! animated model. This example shows how:
//! \code //! \code
//! ISceneNode* hand = //! ISceneNode* hand =
//! yourMS3DAnimatedMeshSceneNode->getXJointNode("LeftHand"); //! yourMS3DAnimatedMeshSceneNode->getMS3DJointNode("LeftHand");
//! hand->addChild(weaponSceneNode); //! hand->addChild(weaponSceneNode);
//! \endcode //! \endcode
//! Please note that the SceneNode returned by this method may not exist //! Please note that the SceneNode returned by this method may not exist
...@@ -120,17 +122,17 @@ namespace scene ...@@ -120,17 +122,17 @@ namespace scene
//! \return Returns a pointer to the scene node which represents the joint //! \return Returns a pointer to the scene node which represents the joint
//! with the specified name. Returns 0 if the contained mesh is not an //! with the specified name. Returns 0 if the contained mesh is not an
//! ms3d mesh or the name of the joint could not be found. //! ms3d mesh or the name of the joint could not be found.
virtual ISceneNode* getXJointNode(const c8* jointName) = 0; virtual ISceneNode* getMS3DJointNode(const c8* jointName) = 0;
//! Returns a pointer to a child node, which has the same transformation as //! Returns a pointer to a child node, which has the same transformation as
//! the corresponding joint, if the mesh in this scene node is a b3d mesh. //! the corresponding joint, if the mesh in this scene node is a x mesh.
//! Otherwise 0 is returned. With this method it is possible to //! Otherwise 0 is returned. With this method it is possible to
//! attach scene nodes to joints more easily. In this way, it is //! attach scene nodes to joints more easily. In this way, it is
//! for example possible to attach a weapon to the left hand of an //! for example possible to attach a weapon to the left hand of an
//! animated model. This example shows how: //! animated model. This example shows how:
//! \code //! \code
//! ISceneNode* hand = //! ISceneNode* hand =
//! yourB3DAnimatedMeshSceneNode->getB3DJointNode("LeftHand"); //! yourMS3DAnimatedMeshSceneNode->getXJointNode("LeftHand");
//! hand->addChild(weaponSceneNode); //! hand->addChild(weaponSceneNode);
//! \endcode //! \endcode
//! Please note that the SceneNode returned by this method may not exist //! Please note that the SceneNode returned by this method may not exist
...@@ -139,7 +141,7 @@ namespace scene ...@@ -139,7 +141,7 @@ namespace scene
//! \return Returns a pointer to the scene node which represents the joint //! \return Returns a pointer to the scene node which represents the joint
//! with the specified name. Returns 0 if the contained mesh is not an //! with the specified name. Returns 0 if the contained mesh is not an
//! ms3d mesh or the name of the joint could not be found. //! ms3d mesh or the name of the joint could not be found.
virtual ISceneNode* getB3DJointNode(const c8* jointName) = 0; virtual ISceneNode* getXJointNode(const c8* jointName) = 0;
//! Starts a default MD2 animation. //! Starts a default MD2 animation.
//! With this method it is easily possible to start a Run, Attack, //! With this method it is easily possible to start a Run, Attack,
...@@ -165,7 +167,7 @@ namespace scene ...@@ -165,7 +167,7 @@ namespace scene
virtual bool setMD2Animation(const c8* animationName) = 0; virtual bool setMD2Animation(const c8* animationName) = 0;
//! Returns the current displayed frame number. //! Returns the current displayed frame number.
virtual s32 getFrameNr() const = 0; virtual f32 getFrameNr() const = 0;
//! Returns the current start frame number. //! Returns the current start frame number.
virtual s32 getStartFrame() const = 0; virtual s32 getStartFrame() const = 0;
//! Returns the current end frame number. //! Returns the current end frame number.
...@@ -199,6 +201,16 @@ namespace scene ...@@ -199,6 +201,16 @@ namespace scene
// or the absolutetransformation if it's a normal scenenode // or the absolutetransformation if it's a normal scenenode
virtual const SMD3QuaterionTag& getMD3TagTransformation( const core::stringc & tagname) = 0; virtual const SMD3QuaterionTag& getMD3TagTransformation( const core::stringc & tagname) = 0;
//! Set the joint update mode (0-unused, 1-get joints only, 2-set joints only, 3-move and set)
virtual void setJointMode(s32 mode)=0;
//! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2)
//! you must call animateJoints(), or the mesh will not animate
virtual void setTransitionTime(f32 Time) =0;
//! updates the joint positions of this mesh
virtual void animateJoints() = 0;
}; };
} // end namespace scene } // end namespace scene
......
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_ANIMATED_MESH_X_H_INCLUDED__
#define __I_ANIMATED_MESH_X_H_INCLUDED__
#include "IAnimatedMesh.h"
#include "irrArray.h"
#include "matrix4.h"
namespace irr
{
namespace scene
{
//! Interface for using some special functions of X meshes
class IAnimatedMeshX : public IAnimatedMesh
{
public:
//! Returns a pointer to a transformation matrix of a part of the
//! mesh based on a frame time. This is used for being able to attach
//! objects to parts of animated meshes. For example a weapon to an animated
//! hand.
//! \param jointNumber: Zero based index of joint. The last joint has the number
//! IAnimatedMeshX::getJointCount()-1;
//! \param frame: Frame of the animation.
//! \return Returns a pointer to the matrix of the mesh part or
//! null if an error occured.
virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame) = 0;
//! Gets joint count.
//! \return Returns amount of joints in the skeletal animated mesh.
virtual s32 getJointCount() const = 0;
//! Gets the name of a joint.
//! \param number: Zero based index of joint. The last joint has the number
//! IAnimatedMeshX::getJointCount()-1;
//! \return Returns name of joint and null if an error happened.
virtual const c8* getJointName(s32 number) const = 0;
//! Gets a joint number from its name
//! \param name: Name of the joint.
//! \return Returns the number of the joint or -1 if not found.
virtual s32 getJointNumber(const c8* name) const = 0;
//! Returns a pointer to list of points containing the skeleton.
//! Draw a line between point 1 and 2, and 3 and 4 and 5 and 6
//! and so on to visualize this. Only for debug purposes. If you
//! use an .x-File with the IAnimatedMeshSceneNode and turn DebugDataVisible
//! to true, the Scene node will visualize the skeleton using this
//! method.
virtual const core::array<core::vector3df>* getDrawableSkeleton(s32 frame) = 0;
//! Returns amount of animations in .X-file.
virtual s32 getAnimationCount() const = 0;
//! Returns the name of an animation.
//! \param idx: Zero based Index of the animation. Must be a value between
//! 0 and getAnimationCount()-1;
//! \return Returns pointer to the string of the name of the animation.
//! Returns 0 if an animation with this index does not exist.
virtual const c8* getAnimationName(s32 idx) const = 0;
//! Sets an animation as animation to play back.
//! \param idx: Zero based Index of the animation. Must be a value between
//! 0 and getAnimationCount()-1;
virtual void setCurrentAnimation(s32 idx) = 0;
//! Sets an animation as animation to play back.
//! \param name: Name of the animtion.
//! \return Returns true if successful, and false if the specified animation
//! does not exist.
virtual bool setCurrentAnimation(const c8* name) = 0;
};
} // end namespace scene
} // end namespace irr
#endif
#ifndef __I_BONE_SCENE_NODE_H_INCLUDED__
#define __I_BONE_SCENE_NODE_H_INCLUDED__
// Used with SkinnedMesh and IAnimatedMeshSceneNode, for boned meshes
#include "ISceneNode.h"
namespace irr
{
namespace scene
{
//! Enumeration for different bone animation modes
enum E_BONE_ANIMATION_MODE
{
//! The bone is usually animated, unless it's parent is not animated
EBAM_AUTOMATIC=0,
//! The bone is animated by the skin, if it's parent is not animated
//! then animation will resume from this bone onward
EBAM_ANIMATED,
//! The bone is not animated by the skin
EBAM_UNANIMATED,
//! Not an animation mode, just here to count the available modes
EBAM_COUNT
};
//! Names for bone animation modes
const c8* const BoneAnimationModeNames[] =
{
"automatic",
"animated",
"unanimated",
0,
};
class IBoneSceneNode : public ISceneNode
{
public:
IBoneSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id=-1) :
ISceneNode(parent, mgr, id),positionHint(-1),scaleHint(-1),rotationHint(-1) { }
//! Returns the name of the bone
virtual const c8* getBoneName() const = 0;
//! Returns the index of the bone
virtual u32 getBoneIndex() const = 0;
//! Sets the animation mode of the bone. Returns true if successful.
virtual bool setAnimationMode(E_BONE_ANIMATION_MODE mode) = 0;
//! Gets the current animation mode of the bone
virtual E_BONE_ANIMATION_MODE getAnimationMode() const = 0;
//! returns the axis aligned bounding box of this node
virtual const core::aabbox3d<f32>& getBoundingBox() const = 0;
//! Returns the relative transformation of the scene node.
//virtual core::matrix4 getRelativeTransformation() const = 0;
virtual void OnAnimate(u32 timeMs) =0;
//! Does nothing as bones are not visible
virtual void render() { };
virtual void setAbsoluteTransformation(core::matrix4 transformation)
{
AbsoluteTransformation=transformation;
}
//! updates the absolute position based on the relative and the parents position
virtual void updateAbsolutePositionOfAllChildren()=0;
s32 positionHint;
s32 scaleHint;
s32 rotationHint;
};
} // end namespace scene
} // end namespace irr
#endif
// Copyright (C) 2002-2006 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_SKINNED_MESH_H_INCLUDED__
#define __I_SKINNED_MESH_H_INCLUDED__
#include "irrArray.h"
#include "IBoneSceneNode.h"
#include "IAnimatedMesh.h"
#include "SSkinMeshBuffer.h"
namespace irr
{
namespace scene
{
enum E_INTERPOLATION_MODE
{
// constant interpolation
EIM_CONSTANT = 0,
// linear interpolation
EIM_LINEAR,
//! count of all available interpolation modes
EIM_COUNT
};
//! Interface for using some special functions of Skinned meshes
class ISkinnedMesh : public IAnimatedMesh
{
public:
//! Gets joint count.
//! \return Returns amount of joints in the skeletal animated mesh.
virtual s32 getJointCount() const = 0;
//! Gets the name of a joint.
//! \param number: Zero based index of joint. The last joint has the number
//! IAnimatedMeshB3d::getJointCount()-1;
//! \return Returns name of joint and null if an error happened.
virtual const c8* getJointName(s32 number) const = 0;
//! Gets a joint number from its name
//! \param name: Name of the joint.
//! \return Returns the number of the joint or -1 if not found.
virtual s32 getJointNumber(const c8* name) const = 0;
//! uses animation from another mesh
//! the animation is linked (not copied) based on joint names (so make sure they are unique)
//! \return Returns true if all joints in this mesh were matched up (empty names will not be matched, and it's case sensitive)
//! unmatched joints will not be animated
virtual bool useAnimationFrom(ISkinnedMesh *mesh) = 0;
//!Update Normals when Animating
//!False= Don't (default)
//!True= Update normals, slower
virtual void updateNormalsWhenAnimating(bool on) = 0;
//!Sets Interpolation Mode
virtual void setInterpolationMode(E_INTERPOLATION_MODE mode) = 0;
//! Animates this mesh's joints based on frame input
virtual void animateMesh(f32 frame, f32 blend)=0;
//! Preforms a software skin on this mesh based of joint positions
virtual void skinMesh() = 0;
//!Recovers the joints from the mesh
virtual void recoverJointsFromMesh(core::array<IBoneSceneNode*> &JointChildSceneNodes) = 0;
//!Tranfers the joint data to the mesh
virtual void tranferJointsToMesh(core::array<IBoneSceneNode*> &JointChildSceneNodes) = 0;
//!Creates an array of joints from this mesh
virtual void createJoints(core::array<IBoneSceneNode*> &JointChildSceneNodes,
IAnimatedMeshSceneNode* AnimatedMeshSceneNode, ISceneManager* SceneManager) = 0;
virtual void convertMeshToTangents() = 0;
//! A vertex weight
struct SWeight
{
//! Index of the mesh buffer
u16 buffer_id; //I doubt 32bits is needed
//! Index of the vertex
u32 vertex_id; //Store global ID here
//! Weight Strength/Percentage (0-1)
f32 strength;
private:
//! Internal members used by CSkinnedMesh
friend class CSkinnedMesh;
bool *Moved;
core::vector3df StaticPos;
core::vector3df StaticNormal;
};
//! Animation keyframe which describes a new position, scale or rotation
struct SPositionKey
{
f32 frame;
core::vector3df position;
};
struct SScaleKey
{
f32 frame;
core::vector3df scale;
};
struct SRotationKey
{
f32 frame;
core::quaternion rotation;
};
//! Joints
struct SJoint
{
SJoint() :
Name(""), LocalMatrix(),
Children(), PositionKeys(), ScaleKeys(), RotationKeys(), Weights(),
UseAnimationFrom(0), LocalAnimatedMatrix_Animated(false),positionHint(-1),scaleHint(-1),rotationHint(-1)
{
}
//! The name of this joint
core::stringc Name;
//! Local matrix of this joint
core::matrix4 LocalMatrix;
//! List of child joints
core::array<SJoint*> Children;
//! Animation keys causing translation change
core::array<SPositionKey> PositionKeys;
//! Animation keys causing scale change
core::array<SScaleKey> ScaleKeys;
//! Animation keys causing rotation change
core::array<SRotationKey> RotationKeys;
//! Skin weights
core::array<SWeight> Weights;
//! Unnecessary for loaders, will be overwritten on finalize
core::matrix4 GlobalMatrix;
core::matrix4 GlobalAnimatedMatrix;
core::matrix4 LocalAnimatedMatrix;
core::vector3df Animatedposition;
core::vector3df Animatedscale;
core::quaternion Animatedrotation;
core::matrix4 GlobalInversedMatrix; //the x format pre-calculates this
private:
//! Internal members used by CSkinnedMesh
friend class CSkinnedMesh;
SJoint *UseAnimationFrom;
bool LocalAnimatedMatrix_Animated;
s32 positionHint;
s32 scaleHint;
s32 rotationHint;
};
//Interface for the mesh loaders (finalize should lock these functions, and they should have some prefix like loader_
//these functions will use the needed arrays, set vaules, etc to help the loaders
//! exposed for loaders to add mesh buffers
virtual core::array<SSkinMeshBuffer*> &getMeshBuffers() = 0;
//! alternative method for adding joints
virtual core::array<SJoint*> &getAllJoints() = 0;
//! loaders should call this after populating the mesh
virtual void finalize() = 0;
virtual SSkinMeshBuffer *createBuffer() = 0;
virtual SJoint *createJoint(SJoint *parent=0) = 0;
virtual SPositionKey *createPositionKey(SJoint *joint) = 0;
virtual SScaleKey *createScaleKey(SJoint *joint) = 0;
virtual SRotationKey *createRotationKey(SJoint *joint) = 0;
virtual SWeight *createWeight(SJoint *joint) = 0;
};
} // end namespace scene
} // end namespace irr
#endif
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define __IRR_COMPILE_CONFIG_H_INCLUDED__ #define __IRR_COMPILE_CONFIG_H_INCLUDED__
//! Irrlicht SDK Version //! Irrlicht SDK Version
#define IRRLICHT_SDK_VERSION "1.3.1" #define IRRLICHT_SDK_VERSION "1.4RC"
//! The defines for different operating system are: //! The defines for different operating system are:
//! _IRR_XBOX_PLATFORM_ for XBox //! _IRR_XBOX_PLATFORM_ for XBox
...@@ -213,6 +213,46 @@ Note that the engine will run in D3D REF for this, which is a lot slower than HA ...@@ -213,6 +213,46 @@ Note that the engine will run in D3D REF for this, which is a lot slower than HA
//#define BURNINGVIDEO_RENDERER_ULTRA_FAST //#define BURNINGVIDEO_RENDERER_ULTRA_FAST
//! Define _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_ if you want to use bone based
/** animated meshes. If you compile without this, you will be unable to load
B3D, MS3D or X meshes */
#define _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_
#ifdef _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_
//! Define _IRR_COMPILE_WITH_B3D_LOADER_ if you want to use Blitz3D files
#define _IRR_COMPILE_WITH_B3D_LOADER_
//! Define _IRR_COMPILE_WITH_B3D_LOADER_ if you want to Milkshape files
#define _IRR_COMPILE_WITH_MS3D_LOADER_
//! Define _IRR_COMPILE_WITH_X_LOADER_ if you want to use Microsoft X files
#define _IRR_COMPILE_WITH_X_LOADER_
#endif
//! Define _IRR_COMPILE_WITH_MD2_LOADER_ if you want to load Quake 2 animated files
#define _IRR_COMPILE_WITH_MD2_LOADER_
//! Define _IRR_COMPILE_WITH_MD3_LOADER_ if you want to load Quake 3 animated files
#define _IRR_COMPILE_WITH_MD3_LOADER_
//! Define _IRR_COMPILE_WITH_3DS_LOADER_ if you want to load 3D Studio Max files
#define _IRR_COMPILE_WITH_3DS_LOADER_
//! Define _IRR_COMPILE_WITH_COLLADA_LOADER_ if you want to load Collada files
#define _IRR_COMPILE_WITH_COLLADA_LOADER_
//! Define _IRR_COMPILE_WITH_CSM_LOADER_ if you want to load Cartography Shop files
#define _IRR_COMPILE_WITH_CSM_LOADER_
//! Define _IRR_COMPILE_WITH_BSP_LOADER_ if you want to load Quake 3 BSP files
#define _IRR_COMPILE_WITH_BSP_LOADER_
//! Define _IRR_COMPILE_WITH_DMF_LOADER_ if you want to load DeleD files
#define _IRR_COMPILE_WITH_DMF_LOADER_
//! Define _IRR_COMPILE_WITH_LMTS_LOADER_ if you want to load LMTools files
#define _IRR_COMPILE_WITH_LMTS_LOADER_
//! Define _IRR_COMPILE_WITH_MY3D_LOADER_ if you want to load MY3D files
#define _IRR_COMPILE_WITH_MY3D_LOADER_
//! Define _IRR_COMPILE_WITH_OBJ_LOADER_ if you want to load Wavefront OBJ files
#define _IRR_COMPILE_WITH_OBJ_LOADER_
//! Define _IRR_COMPILE_WITH_OCT_LOADER_ if you want to load FSRad OCT files
#define _IRR_COMPILE_WITH_OCT_LOADER_
//! Define _IRR_COMPILE_WITH_OGRE_LOADER_ if you want to load Ogre 3D files
#define _IRR_COMPILE_WITH_OGRE_LOADER_
//! Set FPU settings //! Set FPU settings
/** Irrlicht should use approximate float and integer fpu techniques /** Irrlicht should use approximate float and integer fpu techniques
precision will be lower but speed higher. currently X86 only precision will be lower but speed higher. currently X86 only
......
...@@ -110,13 +110,39 @@ namespace scene ...@@ -110,13 +110,39 @@ namespace scene
Box.addInternalBox(Meshes[i]->getBoundingBox()); Box.addInternalBox(Meshes[i]->getBoundingBox());
} }
//! Returns the type of the animated mesh. //! Returns the type of the animated mesh.
virtual E_ANIMATED_MESH_TYPE getMeshType() const virtual E_ANIMATED_MESH_TYPE getMeshType() const
{ {
return Type; return Type;
} }
//! returns amount of mesh buffers.
virtual u32 getMeshBufferCount() const
{
return 0;
}
//! returns pointer to a mesh buffer
virtual IMeshBuffer* getMeshBuffer(u32 nr) const
{
return 0;
}
//! Returns pointer to a mesh buffer which fits a material
/** \param material: material to search for
\return Returns the pointer to the mesh buffer or
NULL if there is no such mesh buffer. */
virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const
{
return 0;
}
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
{
return;
}
core::aabbox3d<f32> Box; core::aabbox3d<f32> Box;
core::array<IMesh*> Meshes; core::array<IMesh*> Meshes;
E_ANIMATED_MESH_TYPE Type; E_ANIMATED_MESH_TYPE Type;
......
// Copyright (C) 2002-2006 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_SKIN_MESH_BUFFER_H_INCLUDED__
#define __I_SKIN_MESH_BUFFER_H_INCLUDED__
#include "IMeshBuffer.h"
#include "S3DVertex.h"
namespace irr
{
namespace scene
{
//! A mesh buffer able to choose between
//! S3DVertex2TCoords, S3DVertex and S3DVertexTangents at runtime
struct SSkinMeshBuffer : public IMeshBuffer
{
SSkinMeshBuffer(video::E_VERTEX_TYPE vt=video::EVT_STANDARD) : VertexType(vt)
{
#ifdef _DEBUG
setDebugName("SSkinMeshBuffer");
#endif
}
virtual ~SSkinMeshBuffer() {}
virtual const video::SMaterial& getMaterial() const
{
return Material;
}
virtual video::SMaterial& getMaterial()
{
return Material;
}
virtual video::S3DVertex *getVertex(u32 index)
{
switch (VertexType)
{
case video::EVT_2TCOORDS: return (video::S3DVertex*)&Vertices_2TCoords[index];
case video::EVT_TANGENTS: return (video::S3DVertex*)&Vertices_Tangents[index];
default: return &Vertices_Standard[index];
}
}
virtual const void* getVertices() const
{
switch (VertexType)
{
case video::EVT_2TCOORDS: return Vertices_2TCoords.const_pointer();
case video::EVT_TANGENTS: return Vertices_Tangents.const_pointer();
default: return Vertices_Standard.const_pointer();
}
}
virtual void* getVertices()
{
switch (VertexType)
{
case video::EVT_2TCOORDS: return Vertices_2TCoords.pointer();
case video::EVT_TANGENTS: return Vertices_Tangents.pointer();
default: return Vertices_Standard.pointer();
}
}
virtual u32 getVertexCount() const
{
switch (VertexType)
{
case video::EVT_2TCOORDS: return Vertices_2TCoords.size();
case video::EVT_TANGENTS: return Vertices_Tangents.size();
default: return Vertices_Standard.size();
}
}
virtual const u16* getIndices() const
{
return Indices.const_pointer();
}
virtual u16* getIndices()
{
return Indices.pointer();
}
virtual u32 getIndexCount() const
{
return Indices.size();
}
virtual const core::aabbox3d<f32>& getBoundingBox() const
{
return BoundingBox;
}
virtual void setBoundingBox( const core::aabbox3df& box)
{
BoundingBox = box;
}
virtual void recalculateBoundingBox()
{
switch (VertexType)
{
case video::EVT_STANDARD:
{
if (Vertices_Standard.empty())
BoundingBox.reset(0,0,0);
else
{
BoundingBox.reset(Vertices_Standard[0].Pos);
for (u32 i=1; i<Vertices_Standard.size(); ++i)
BoundingBox.addInternalPoint(Vertices_Standard[i].Pos);
}
break;
}
case video::EVT_2TCOORDS:
{
if (Vertices_2TCoords.empty())
BoundingBox.reset(0,0,0);
else
{
BoundingBox.reset(Vertices_2TCoords[0].Pos);
for (u32 i=1; i<Vertices_2TCoords.size(); ++i)
BoundingBox.addInternalPoint(Vertices_2TCoords[i].Pos);
}
break;
}
case video::EVT_TANGENTS:
{
if (Vertices_Tangents.empty())
BoundingBox.reset(0,0,0);
else
{
BoundingBox.reset(Vertices_Tangents[0].Pos);
for (u32 i=1; i<Vertices_Tangents.size(); ++i)
BoundingBox.addInternalPoint(Vertices_Tangents[i].Pos);
}
break;
}
}
}
virtual video::E_VERTEX_TYPE getVertexType() const
{
return VertexType;
}
//! returns the byte size (stride, pitch) of the vertex
virtual u32 getVertexPitch() const
{
switch (VertexType)
{
case video::EVT_2TCOORDS: return sizeof(video::S3DVertex2TCoords);
case video::EVT_TANGENTS: return sizeof(video::S3DVertexTangents);
default: return sizeof(video::S3DVertex);
}
}
virtual void MoveTo_2TCoords()
{
if (VertexType==video::EVT_STANDARD)
{
for(u32 n=0;n<Vertices_Standard.size();++n)
{
video::S3DVertex2TCoords Vertex;
Vertex.Color=Vertices_Standard[n].Color;
Vertex.Pos=Vertices_Standard[n].Pos;
Vertex.Normal=Vertices_Standard[n].Normal;
Vertex.TCoords=Vertices_Standard[n].TCoords;
Vertices_2TCoords.push_back(Vertex);
}
Vertices_Standard.clear();
VertexType=video::EVT_2TCOORDS;
}
}
virtual void MoveTo_Tangents()
{
if (VertexType==video::EVT_STANDARD)
{
for(u32 n=0;n<Vertices_Standard.size();++n)
{
video::S3DVertexTangents Vertex;
Vertex.Color=Vertices_Standard[n].Color;
Vertex.Pos=Vertices_Standard[n].Pos;
Vertex.Normal=Vertices_Standard[n].Normal;
Vertex.TCoords=Vertices_Standard[n].TCoords;
Vertices_Tangents.push_back(Vertex);
}
Vertices_Standard.clear();
VertexType=video::EVT_TANGENTS;
}
else if (VertexType==video::EVT_2TCOORDS)
{
for(u32 n=0;n<Vertices_2TCoords.size();++n)
{
video::S3DVertexTangents Vertex;
Vertex.Color=Vertices_2TCoords[n].Color;
Vertex.Pos=Vertices_2TCoords[n].Pos;
Vertex.Normal=Vertices_2TCoords[n].Normal;
Vertex.TCoords=Vertices_2TCoords[n].TCoords;
Vertices_Tangents.push_back(Vertex);
}
Vertices_2TCoords.clear();
VertexType=video::EVT_TANGENTS;
}
}
//! append the vertices and indices to the current buffer
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {}
//! append the meshbuffer to the current buffer
virtual void append(const IMeshBuffer* const other) {}
video::SMaterial Material;
video::E_VERTEX_TYPE VertexType;
core::array<video::S3DVertexTangents> Vertices_Tangents;
core::array<video::S3DVertex2TCoords> Vertices_2TCoords;
core::array<video::S3DVertex> Vertices_Standard;
core::array<u16> Indices;
core::aabbox3d<f32> BoundingBox;
};
} // end namespace scene
} // end namespace irr
#endif
...@@ -43,13 +43,10 @@ ...@@ -43,13 +43,10 @@
#include "IAnimatedMesh.h" #include "IAnimatedMesh.h"
#include "IAnimatedMeshMD2.h" #include "IAnimatedMeshMD2.h"
#include "IAnimatedMeshMD3.h" #include "IAnimatedMeshMD3.h"
#include "IAnimatedMeshMS3D.h"
#include "IAnimatedMeshMS3D.h"
#include "IQ3LevelMesh.h" #include "IQ3LevelMesh.h"
#include "IAnimatedMeshX.h"
#include "IAnimatedMeshB3d.h"
#include "IAnimatedMeshSceneNode.h" #include "IAnimatedMeshSceneNode.h"
#include "IBillboardSceneNode.h" #include "IBillboardSceneNode.h"
#include "IBoneSceneNode.h"
#include "ICameraSceneNode.h" #include "ICameraSceneNode.h"
#include "IDummyTransformationSceneNode.h" #include "IDummyTransformationSceneNode.h"
#include "IEventReceiver.h" #include "IEventReceiver.h"
...@@ -104,6 +101,7 @@ ...@@ -104,6 +101,7 @@
#include "ISceneNodeAnimatorCollisionResponse.h" #include "ISceneNodeAnimatorCollisionResponse.h"
#include "IShaderConstantSetCallBack.h" #include "IShaderConstantSetCallBack.h"
#include "IParticleSystemSceneNode.h" // also includes all emitters and attractors #include "IParticleSystemSceneNode.h" // also includes all emitters and attractors
#include "ISkinnedMesh.h"
#include "ITerrainSceneNode.h" #include "ITerrainSceneNode.h"
#include "ITextSceneNode.h" #include "ITextSceneNode.h"
#include "ITexture.h" #include "ITexture.h"
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_3DS_LOADER_
#include "C3DSMeshFileLoader.h" #include "C3DSMeshFileLoader.h"
#include "os.h" #include "os.h"
#include "SMeshBuffer.h" #include "SMeshBuffer.h"
...@@ -1262,3 +1265,4 @@ void C3DSMeshFileLoader::readString(io::IReadFile* file, ChunkData& data, core:: ...@@ -1262,3 +1265,4 @@ void C3DSMeshFileLoader::readString(io::IReadFile* file, ChunkData& data, core::
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
#endif // _IRR_COMPILE_WITH_3DS_LOADER_
This diff is collapsed.
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_MD2_LOADER_
#include "CAnimatedMeshMD2.h" #include "CAnimatedMeshMD2.h"
#include "os.h" #include "os.h"
#include "SColor.h" #include "SColor.h"
...@@ -758,3 +761,4 @@ const c8* CAnimatedMeshMD2::getAnimationName(s32 nr) const ...@@ -758,3 +761,4 @@ const c8* CAnimatedMeshMD2::getAnimationName(s32 nr) const
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
#endif // _IRR_COMPILE_WITH_MD2_LOADER_
...@@ -18,7 +18,7 @@ namespace irr ...@@ -18,7 +18,7 @@ namespace irr
namespace scene namespace scene
{ {
class CAnimatedMeshMD2 : public IAnimatedMeshMD2, public IMesh class CAnimatedMeshMD2 : public IAnimatedMeshMD2
{ {
public: public:
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_MD3_LOADER_
#include "CAnimatedMeshMD3.h" #include "CAnimatedMeshMD3.h"
#include "os.h" #include "os.h"
...@@ -411,3 +414,4 @@ E_ANIMATED_MESH_TYPE CAnimatedMeshMD3::getMeshType() const ...@@ -411,3 +414,4 @@ E_ANIMATED_MESH_TYPE CAnimatedMeshMD3::getMeshType() const
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
#endif // _IRR_COMPILE_WITH_MD3_LOADER_
...@@ -43,6 +43,43 @@ namespace scene ...@@ -43,6 +43,43 @@ namespace scene
virtual const core::aabbox3d<f32>& getBoundingBox() const; virtual const core::aabbox3d<f32>& getBoundingBox() const;
virtual E_ANIMATED_MESH_TYPE getMeshType() const; virtual E_ANIMATED_MESH_TYPE getMeshType() const;
//link?
//! returns amount of mesh buffers.
virtual u32 getMeshBufferCount() const
{
return 0;
}
//! returns pointer to a mesh buffer
virtual IMeshBuffer* getMeshBuffer(u32 nr) const
{
return 0;
}
//! Returns pointer to a mesh buffer which fits a material
/** \param material: material to search for
\return Returns the pointer to the mesh buffer or
NULL if there is no such mesh buffer. */
virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const
{
return 0;
}
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
{
return;
}
//! set user axis aligned bounding box
virtual void setBoundingBox( const core::aabbox3df& box)
{
return;
}
private: private:
//! animates one frame //! animates one frame
inline void Animate (u32 frame); inline void Animate (u32 frame);
......
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_ANIMATED_MESH_MS3D_H_INCLUDED__
#define __C_ANIMATED_MESH_MS3D_H_INCLUDED__
#include "IAnimatedMeshMS3D.h"
#include "IMesh.h"
#include "IReadFile.h"
#include "S3DVertex.h"
#include "irrString.h"
#include "SSharedMeshBuffer.h"
namespace irr
{
namespace video
{
class IVideoDriver;
} // end namespace video
namespace scene
{
class CAnimatedMeshMS3D : public IAnimatedMeshMS3D, public IMesh
{
public:
//! constructor
CAnimatedMeshMS3D(video::IVideoDriver* driver);
//! destructor
virtual ~CAnimatedMeshMS3D();
//! loads an md2 file
virtual bool loadFile(io::IReadFile* file);
//! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh.
virtual s32 getFrameCount();
//! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level.
virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1);
//! returns amount of mesh buffers.
virtual u32 getMeshBufferCount() const;
//! returns pointer to a mesh buffer
virtual IMeshBuffer* getMeshBuffer(u32 nr) const;
//! Returns pointer to a mesh buffer which fits a material
/** \param material: material to search for
\return Returns the pointer to the mesh buffer or
NULL if there is no such mesh buffer. */
virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const;
//! returns an axis aligned bounding box
virtual const core::aabbox3d<f32>& getBoundingBox() const;
//! set user axis aligned bounding box
virtual void setBoundingBox( const core::aabbox3df& box);
//! sets a flag of all contained materials to a new value
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue);
//! Returns the type of the animated mesh.
virtual E_ANIMATED_MESH_TYPE getMeshType() const;
//! Returns a pointer to a transformation matrix of a part of the
//! mesh based on a frame time.
virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame);
//! Gets joint count.
virtual s32 getJointCount() const;
//! Gets the name of a joint.
virtual const c8* getJointName(s32 number) const;
//! Gets a joint number from its name
virtual s32 getJointNumber(const c8* name) const;
private:
struct SKeyframe
{
f32 timeindex;
core::vector3df data; // translation or rotation
};
struct SJoint
{
core::stringc Name;
s32 Index;
core::vector3df Rotation;
core::vector3df Translation;
core::matrix4 RelativeTransformation;
core::matrix4 AbsoluteTransformation;
core::matrix4 AbsoluteTransformationAnimated;
core::array<SKeyframe> TranslationKeys;
core::array<SKeyframe> RotationKeys;
core::array<u16> VertexIds;
s32 Parent;
core::stringc ParentName;
};
struct SGroup
{
core::stringc Name;
core::array<u16> VertexIds;
u16 MaterialIdx;
};
void animate(s32 frame);
void getKeyframeData(const core::array<SKeyframe>& keys, f32 time, core::vector3df& outdata) const;
void getKeyframeRotation(const core::array<SKeyframe>& keys, f32 time, core::vector3df& outdata) const;
core::aabbox3d<f32> BoundingBox;
core::array<video::S3DVertex> Vertices;
core::array<video::S3DVertex> AnimatedVertices;
core::array<u16> Indices;
core::array<SJoint> Joints;
core::array<SGroup> Groups;
core::array<SSharedMeshBuffer> Buffers;
f32 totalTime;
bool HasAnimation;
s32 lastCalculatedFrame;
video::IVideoDriver* Driver;
};
} // end namespace scene
} // end namespace irr
#endif
This diff is collapsed.
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
#include "IAnimatedMeshSceneNode.h" #include "IAnimatedMeshSceneNode.h"
#include "IAnimatedMesh.h" #include "IAnimatedMesh.h"
#include "matrix4.h"
namespace irr namespace irr
{ {
namespace scene namespace scene
...@@ -28,7 +31,7 @@ namespace scene ...@@ -28,7 +31,7 @@ namespace scene
virtual ~CAnimatedMeshSceneNode(); virtual ~CAnimatedMeshSceneNode();
//! sets the current frame. from now on the animation is played from this frame. //! sets the current frame. from now on the animation is played from this frame.
virtual void setCurrentFrame(s32 frame); virtual void setCurrentFrame(f32 frame);
//! frame //! frame
virtual void OnRegisterSceneNode(); virtual void OnRegisterSceneNode();
...@@ -72,6 +75,10 @@ namespace scene ...@@ -72,6 +75,10 @@ namespace scene
virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(s32 id, virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(s32 id,
bool zfailmethod=true, f32 infinity=10000.0f); bool zfailmethod=true, f32 infinity=10000.0f);
//! Returns a pointer to a child node, which has the same transformation as
//! the corrsesponding joint, if the mesh in this scene node is a skinned mesh.
virtual IBoneSceneNode* getJointNode(const c8* jointName);
//! Returns a pointer to a child node, which has the same transformation as //! Returns a pointer to a child node, which has the same transformation as
//! the corrsesponding joint, if the mesh in this scene node is a ms3d mesh. //! the corrsesponding joint, if the mesh in this scene node is a ms3d mesh.
virtual ISceneNode* getMS3DJointNode(const c8* jointName); virtual ISceneNode* getMS3DJointNode(const c8* jointName);
...@@ -80,10 +87,6 @@ namespace scene ...@@ -80,10 +87,6 @@ namespace scene
//! the corrsesponding joint, if the mesh in this scene node is a x mesh. //! the corrsesponding joint, if the mesh in this scene node is a x mesh.
virtual ISceneNode* getXJointNode(const c8* jointName); virtual ISceneNode* getXJointNode(const c8* jointName);
//! Returns a pointer to a child node, which has the same transformation as
//! the corresponding joint, if the mesh in this scene node is a b3d mesh.
virtual ISceneNode* getB3DJointNode(const c8* jointName);
//! Removes a child from this scene node. //! Removes a child from this scene node.
//! Implemented here, to be able to remove the shadow properly, if there is one, //! Implemented here, to be able to remove the shadow properly, if there is one,
//! or to remove attached childs. //! or to remove attached childs.
...@@ -96,7 +99,7 @@ namespace scene ...@@ -96,7 +99,7 @@ namespace scene
virtual bool setMD2Animation(const c8* animationName); virtual bool setMD2Animation(const c8* animationName);
//! Returns the current displayed frame number. //! Returns the current displayed frame number.
virtual s32 getFrameNr() const; virtual f32 getFrameNr() const;
//! Returns the current start frame number. //! Returns the current start frame number.
virtual s32 getStartFrame() const; virtual s32 getStartFrame() const;
//! Returns the current end frame number. //! Returns the current end frame number.
...@@ -132,9 +135,24 @@ namespace scene ...@@ -132,9 +135,24 @@ namespace scene
//! updates the absolute position based on the relative and the parents position //! updates the absolute position based on the relative and the parents position
virtual void updateAbsolutePosition(); virtual void updateAbsolutePosition();
//! Set the joint update mode (0-unused, 1-get joints only, 2-set joints only, 3-move and set)
virtual void setJointMode(s32 mode);
//! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2)
//! you must call animateJoints(), or the mesh will not animate
virtual void setTransitionTime(f32 Time);
//! updates the joint positions of this mesh
virtual void animateJoints();
private: private:
u32 buildFrameNr( u32 timeMs); f32 buildFrameNr( u32 timeMs);
void checkJoints();
void beginTransition();
core::array<video::SMaterial> Materials; core::array<video::SMaterial> Materials;
core::aabbox3d<f32> Box; core::aabbox3d<f32> Box;
...@@ -145,7 +163,15 @@ namespace scene ...@@ -145,7 +163,15 @@ namespace scene
s32 EndFrame; s32 EndFrame;
f32 FramesPerSecond; f32 FramesPerSecond;
s32 CurrentFrameNr; f32 CurrentFrameNr;
s32 JointMode; //0-unused, 1-get joints only, 2-set joints only, 3-move and set
bool JointsUsed;
u32 TransitionTime; //Transition time in millisecs
f32 Transiting; //is mesh transiting (plus cache of TransitionTime)
f32 TransitingBlend; //0-1, calculated on buildFrameNr
bool Looping; bool Looping;
bool ReadOnlyMaterials; bool ReadOnlyMaterials;
...@@ -155,7 +181,9 @@ namespace scene ...@@ -155,7 +181,9 @@ namespace scene
IShadowVolumeSceneNode* Shadow; IShadowVolumeSceneNode* Shadow;
core::array<IDummyTransformationSceneNode* > JointChildSceneNodes; core::array<IBoneSceneNode* > JointChildSceneNodes;
core::array<core::matrix4> PretransitingSave;
struct SMD3Special struct SMD3Special
{ {
......
// B3D mesh loader
#include "IrrCompileConfig.h"
#ifndef __C_B3D_MESH_LOADER_H_INCLUDED__
#define __C_B3D_MESH_LOADER_H_INCLUDED__
#include "IMeshLoader.h"
#include "ISceneManager.h"
#include "CSkinnedMesh.h"
#include "IReadFile.h"
namespace irr
{
namespace scene
{
//! Meshloader for B3D format
class CB3DMeshFileLoader : public IMeshLoader
{
public:
//! Constructor
CB3DMeshFileLoader(scene::ISceneManager* smgr);
//! destructor
virtual ~CB3DMeshFileLoader();
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".bsp")
virtual bool isALoadableFileExtension(const c8* fileName);
//! creates/loads an animated mesh from the file.
//! \return Pointer to the created mesh. Returns 0 if loading failed.
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
//! See IUnknown::drop() for more information.
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
private:
struct SB3dChunkHeader
{
c8 name[4];
s32 size;
};
struct SB3dChunk
{
c8 name[4];
s32 length;
s32 startposition;
};
struct SB3dTexture
{
irr::video::ITexture* Texture;
s32 Flags;
s32 Blend;
f32 Xpos;
f32 Ypos;
f32 Xscale;
f32 Yscale;
f32 Angle;
};
struct SB3dMaterial
{
irr::video::SMaterial* Material;
f32 red, green, blue, alpha;
f32 shininess;
s32 blend,fx;
SB3dTexture *Textures[2];
};
bool load();
bool readChunkNODE(CSkinnedMesh::SJoint* InJoint);
bool readChunkMESH(CSkinnedMesh::SJoint* InJoint);
bool readChunkVRTS(CSkinnedMesh::SJoint* InJoint, scene::SSkinMeshBuffer *MeshBuffer, s32 Vertices_Start);
bool readChunkTRIS(CSkinnedMesh::SJoint* InJoint, scene::SSkinMeshBuffer *MeshBuffer, u32 MeshBufferID, s32 Vertices_Start);
bool readChunkBONE(CSkinnedMesh::SJoint* InJoint);
bool readChunkKEYS(CSkinnedMesh::SJoint* InJoint);
bool readChunkANIM(CSkinnedMesh::SJoint* InJoint);
bool readChunkTEXS();
bool readChunkBRUS();
core::stringc readString();
core::stringc stripPathFromString(core::stringc string, bool returnPath=false);
void readFloats(f32* vec, u32 count);
core::array<SB3dChunk> B3dStack;
bool NormalsInFile;
core::array<SB3dMaterial> Materials;
core::array<SB3dTexture> Textures;
core::array<s32> AnimatedVertices_VertexID;
core::array<s32> AnimatedVertices_BufferID;
core::array<video::S3DVertex2TCoords*> BaseVertices;
core::array<scene::SSkinMeshBuffer*> *Buffers;
core::array<CSkinnedMesh::SJoint*> *AllJoints;
//
ISceneManager* SceneManager;
CSkinnedMesh* AnimatedMesh;
io::IReadFile* file;
};
} // end namespace scene
} // end namespace irr
#endif // __C_B3D_MESH_LOADER_H_INCLUDED__
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_DEFAULT_MESH_FORMAT_LOADER_H_INCLUDED__ #ifndef __C_BSP_MESH_FILE_LOADER_H_INCLUDED__
#define __C_DEFAULT_MESH_FORMAT_LOADER_H_INCLUDED__ #define __C_BSP_MESH_FILE_LOADER_H_INCLUDED__
#include "IMeshLoader.h" #include "IMeshLoader.h"
#include "IFileSystem.h" #include "IFileSystem.h"
...@@ -15,17 +15,16 @@ namespace irr ...@@ -15,17 +15,16 @@ namespace irr
namespace scene namespace scene
{ {
//! Meshloader capable of loading all Irrlicht default build in formats. //! Meshloader capable of loading Quake 3 BSP files and shaders
/** Which are: Quake 3 Bsp level, Quake 2 MD2 model, Milkshape .ms3d model. */ class CBSPMeshFileLoader : public IMeshLoader
class CDefaultMeshFormatLoader : public IMeshLoader
{ {
public: public:
//! Constructor //! Constructor
CDefaultMeshFormatLoader(io::IFileSystem* fs, video::IVideoDriver* driver, scene::ISceneManager* smgr); CBSPMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver, scene::ISceneManager* smgr);
//! destructor //! destructor
virtual ~CDefaultMeshFormatLoader(); virtual ~CBSPMeshFileLoader();
//! returns true if the file maybe is able to be loaded by this class //! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".bsp") //! based on the file extension (e.g. ".bsp")
......
This diff is collapsed.
This diff is collapsed.
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
// This file was written by Saurav Mohapatra and modified by Nikolaus Gebhardt. // This file was written by Saurav Mohapatra and modified by Nikolaus Gebhardt.
// See CCSMLoader.h for details. // See CCSMLoader.h for details.
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_CSM_LOADER_
#include "CCSMLoader.h" #include "CCSMLoader.h"
#include "os.h" #include "os.h"
#include "IFileSystem.h" #include "IFileSystem.h"
...@@ -871,3 +874,4 @@ namespace scene ...@@ -871,3 +874,4 @@ namespace scene
} // end namespace } // end namespace
} // end namespace } // end namespace
#endif // _IRR_COMPILE_WITH_CSM_LOADER_
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_COLLADA_LOADER_
#include "CColladaFileLoader.h" #include "CColladaFileLoader.h"
#include "os.h" #include "os.h"
#include "IXMLReader.h" #include "IXMLReader.h"
...@@ -1564,3 +1567,4 @@ void CColladaFileLoader::uriToId(core::stringc& str) ...@@ -1564,3 +1567,4 @@ void CColladaFileLoader::uriToId(core::stringc& str)
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
#endif // _IRR_COMPILE_WITH_COLLADA_LOADER_
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
See the header file for additional information including use and distribution rights. See the header file for additional information including use and distribution rights.
*/ */
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_DMF_LOADER_
#include "CDMFLoader.h" #include "CDMFLoader.h"
#include "ISceneManager.h" #include "ISceneManager.h"
#include "IAttributes.h" #include "IAttributes.h"
...@@ -441,3 +444,5 @@ bool CDMFLoader::isALoadableFileExtension(const c8* filename) ...@@ -441,3 +444,5 @@ bool CDMFLoader::isALoadableFileExtension(const c8* filename)
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
#endif // _IRR_COMPILE_WITH_DMF_LOADER_
...@@ -74,6 +74,9 @@ Version 1.0 - 29 July 2004 ...@@ -74,6 +74,9 @@ Version 1.0 - 29 July 2004
*/ */
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_LMTS_LOADER_
#include "SMeshBufferLightMap.h" #include "SMeshBufferLightMap.h"
#include "SAnimatedMesh.h" #include "SAnimatedMesh.h"
#include "SMeshBuffer.h" #include "SMeshBuffer.h"
...@@ -354,3 +357,5 @@ void CLMTSMeshFileLoader::loadTextures() ...@@ -354,3 +357,5 @@ void CLMTSMeshFileLoader::loadTextures()
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
#endif // _IRR_COMPILE_WITH_LMTS_LOADER_
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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