Commit 451d5bca authored by hybrid's avatar hybrid

Merged from 1.4 branch revisions 1251:1271

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1272 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 89aa5dab
......@@ -14,11 +14,11 @@ namespace scene
{
//! Scene node which is a dynamic light.
/** You can switch the light on and off by
making it visible or not, and let it be animated by ordinary scene node animators.
If you set the light type to be directional, you will need to set the direction of the
light source manually in the SLight structure, the position of the scene node will have no
effect on this direction.
/** You can switch the light on and off by making it visible or not. It can be
animated by ordinary scene node animators.
If the light type is directional or spot, the direction of the light source
is defined by the rotation of the scene node (assuming (0,0,1) as the local
direction of the light).
*/
class ILightSceneNode : public ISceneNode
{
......@@ -30,6 +30,7 @@ public:
: ISceneNode(parent, mgr, id, position) {}
//! Sets the light data associated with this ILightSceneNode
//! \param light The new light data.
virtual void setLightData(const video::SLight& light) = 0;
//! Gets the light data associated with this ILightSceneNode
......
......@@ -25,11 +25,13 @@ namespace irr
namespace scene
{
//! Scene node interface.
/** A scene node is a node in the hirachical scene graph. Every scene node may have children,
which are other scene nodes. Children move relative the their parents position. If the parent of a node is not
visible, its children won't be visible too. In this way, it is for example easily possible
to attach a light to a moving car, or to place a walking character on a moving platform
on a moving ship. */
/** A scene node is a node in the hierarchical scene graph. Every scene
node may have children, which are also scene nodes. Children move
relative to their parent's position. If the parent of a node is not
visible, its children won't be visible either. In this way, it is for
example easily possible to attach a light to a moving car, or to place
a walking character on a moving platform on a moving ship.
*/
class ISceneNode : virtual public io::IAttributeExchangingObject
{
public:
......@@ -70,8 +72,8 @@ namespace scene
//! This method is called just before the rendering process of the whole scene.
/** Nodes may register themselves in the render pipeline during this call,
precalculate the geometry which should be renderered, and prevent their
children from being able to register them selfes if they are clipped by simply
not calling their OnRegisterSceneNode-Method.
children from being able to register themselves if they are clipped by simply
not calling their OnRegisterSceneNode method.
If you are implementing your own scene node, you should overwrite this method
with an implementation code looking like this:
\code
......@@ -94,10 +96,10 @@ namespace scene
//! OnAnimate() is called just before rendering the whole scene.
//! Nodes may calculate or store animations here, and may do other useful things,
//! dependent on what they are. Also, OnAnimate() should be called for all
//! depending on what they are. Also, OnAnimate() should be called for all
//! child scene nodes here. This method will be called once per frame, independent
//! of if the scene node is visible or not.
//! \param timeMs: Current time in milliseconds.
//! of whether the scene node is visible or not.
//! \param timeMs Current time in milliseconds.
virtual void OnAnimate(u32 timeMs)
{
if (IsVisible)
......@@ -125,7 +127,7 @@ namespace scene
//! Returns the name of the node.
//! \return Returns name as wide character string.
//! \return Name as character string.
virtual const c8* getName() const
{
return Name.c_str();
......@@ -133,7 +135,7 @@ namespace scene
//! Sets the name of the node.
//! \param name: New name of the scene node.
//! \param name New name of the scene node.
virtual void setName(const c8* name)
{
Name = name;
......@@ -141,16 +143,18 @@ namespace scene
//! Returns the axis aligned, not transformed bounding box of this node.
//! This means that if this node is a animated 3d character, moving in a room,
//! This means that if this node is an animated 3d character, moving in a room,
//! the bounding box will always be around the origin. To get the box in
//! real world coordinates, just transform it with the matrix you receive with
//! getAbsoluteTransformation() or simply use getTransformedBoundingBox(),
//! which does the same.
//! \return The non-transformed bounding box.
virtual const core::aabbox3d<f32>& getBoundingBox() const = 0;
//! Returns the axis aligned, transformed and animated absolute bounding box
//! of this node.
//! \return The transformed bounding box.
virtual const core::aabbox3d<f32> getTransformedBoundingBox() const
{
core::aabbox3d<f32> box = getBoundingBox();
......@@ -160,6 +164,7 @@ namespace scene
//! returns the absolute transformation of the node. Is recalculated every OnAnimate()-call.
//! \return The absolute transformation matrix.
virtual const core::matrix4& getAbsoluteTransformation() const
{
return AbsoluteTransformation;
......@@ -170,14 +175,14 @@ namespace scene
//! The relative transformation is stored internally as 3 vectors:
//! translation, rotation and scale. To get the relative transformation
//! matrix, it is calculated from these values.
//! \return Returns the relative transformation matrix.
//! \return The relative transformation matrix.
virtual core::matrix4 getRelativeTransformation() const
{
core::matrix4 mat;
mat.setRotationDegrees(RelativeRotation);
mat.setTranslation(RelativeTranslation);
if (RelativeScale != core::vector3df(1,1,1))
if (RelativeScale != core::vector3df(1.f,1.f,1.f))
{
core::matrix4 smat;
smat.setScale(RelativeScale);
......@@ -188,8 +193,9 @@ namespace scene
}
//! Returns true if the node is visible. This is only an option, set by the user and has
//! nothing to do with geometry culling
//! Returns true if the node is visible. This is only an option
//! set by the user, but has nothing to do with geometry culling
//! \return The visibility of the node, true means visible.
virtual bool isVisible() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
......@@ -197,7 +203,8 @@ namespace scene
}
//! Sets if the node should be visible or not. All children of this node won't be visible too.
//! Sets if the node should be visible or not. All children of this node won't be visible either, when set to true.
//! \param isVisisble If the node shall be visible.
virtual void setVisible(bool isVisible)
{
IsVisible = isVisible;
......@@ -205,13 +212,15 @@ namespace scene
//! Returns the id of the scene node. This id can be used to identify the node.
//! \return The id.
virtual s32 getID() const
{
return ID;
}
//! sets the id of the scene node. This id can be used to identify the node.
//! Sets the id of the scene node. This id can be used to identify the node.
//! \param id The new id.
virtual void setID(s32 id)
{
ID = id;
......@@ -219,7 +228,8 @@ namespace scene
//! Adds a child to this scene node. If the scene node already
//! has got a parent, it is removed from there as child.
//! has a parent it is first removed from the other parent.
//! \param child A pointer to the new child.
virtual void addChild(ISceneNode* child)
{
if (child && (child != this))
......@@ -233,7 +243,8 @@ namespace scene
//! Removes a child from this scene node.
//! \return Returns true if the child could be removed, and false if not.
//! \param child A pointer to the new child.
//! \return True if the child could be removed, and false if not.
virtual bool removeChild(ISceneNode* child)
{
core::list<ISceneNode*>::Iterator it = Children.begin();
......@@ -274,6 +285,7 @@ namespace scene
//! Adds an animator which should animate this node.
//! \param animator A pointer to the new animator.
virtual void addAnimator(ISceneNodeAnimator* animator)
{
if (animator)
......@@ -285,6 +297,7 @@ namespace scene
//! Returns a const reference to the list of all scene node animators.
//! \return The list of animators attached to this node.
const core::list<ISceneNodeAnimator*>& getAnimators() const
{
return Animators;
......@@ -292,6 +305,7 @@ namespace scene
//! Removes an animator from this scene node.
//! \param animator A pointer to the animator to be deleted.
virtual void removeAnimator(ISceneNodeAnimator* animator)
{
core::list<ISceneNodeAnimator*>::Iterator it = Animators.begin();
......@@ -318,11 +332,11 @@ namespace scene
//! Returns the material based on the zero based index i. To get the amount
//! of materials used by this scene node, use getMaterialCount().
//! This function is needed for inserting the node into the scene hirachy on a
//! This function is needed for inserting the node into the scene hierarchy at an
//! optimal position for minimizing renderstate changes, but can also be used
//! to directly modify the material of a scene node.
//! \param num: Zero based index. The maximal value is getMaterialCount() - 1.
//! \return Returns the material of that index.
//! \param num Zero based index. The maximal value is getMaterialCount() - 1.
//! \return The material at that index.
virtual video::SMaterial& getMaterial(u32 num)
{
return *((video::SMaterial*)0);
......@@ -330,17 +344,17 @@ namespace scene
//! Returns amount of materials used by this scene node.
//! \return Returns current count of materials used by this scene node.
//! \return Current amount of materials used by this scene node.
virtual u32 getMaterialCount() const
{
return 0;
}
//! Sets all material flags at once to a new value. Helpful for
//! example, if you want to be the the whole mesh to be lighted by
//! \param flag: Which flag of all materials to be set.
//! \param newvalue: New value of the flag.
//! Sets all material flags at once to a new value. Useful, for
//! example, if you want the whole mesh to be affected by light.
//! \param flag Which flag of all materials to be set.
//! \param newvalue New value of that flag.
void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
{
for (u32 i=0; i<getMaterialCount(); ++i)
......@@ -350,9 +364,9 @@ namespace scene
//! Sets the texture of the specified layer in all materials of this
//! scene node to the new texture.
//! \param textureLayer: Layer of texture to be set. Must be a value greater or
//! equal than 0 and smaller than MATERIAL_MAX_TEXTURES.
//! \param texture: Texture to be used.
//! \param textureLayer Layer of texture to be set. Must be a
//! value smaller than MATERIAL_MAX_TEXTURES.
//! \param texture New texture to be used.
void setMaterialTexture(u32 textureLayer, video::ITexture* texture)
{
if (textureLayer >= video::MATERIAL_MAX_TEXTURES)
......@@ -363,9 +377,9 @@ namespace scene
}
//! Sets the material type of all materials s32 this scene node
//! Sets the material type of all materials in this scene node
//! to a new material type.
//! \param newType: New type of material to be set.
//! \param newType New type of material to be set.
void setMaterialType(video::E_MATERIAL_TYPE newType)
{
for (u32 i=0; i<getMaterialCount(); ++i)
......@@ -373,16 +387,16 @@ namespace scene
}
//! Gets the scale of the scene node.
/** \return Returns the scale of the scene node. */
//! Gets the relative scale of the scene node.
/** \return The scale of the scene node. */
virtual const core::vector3df& getScale() const
{
return RelativeScale;
}
//! Sets the scale of the scene node.
/** \param scale: New scale of the node */
//! Sets the relative scale of the scene node.
/** \param scale New scale of the node */
virtual void setScale(const core::vector3df& scale)
{
RelativeScale = scale;
......@@ -400,7 +414,7 @@ namespace scene
//! Sets the rotation of the node.
/** This only modifies the relative rotation of the node.
\param rotation: New rotation of the node in degrees. */
\param rotation New rotation of the node in degrees. */
virtual void setRotation(const core::vector3df& rotation)
{
RelativeRotation = rotation;
......@@ -409,7 +423,7 @@ namespace scene
//! Gets the position of the node.
/** Note that the position is relative to the parent.
\return Returns the current position of the node relative to the parent. */
\return The current position of the node relative to the parent. */
virtual const core::vector3df& getPosition() const
{
return RelativeTranslation;
......@@ -418,7 +432,7 @@ namespace scene
//! Sets the position of the node.
/** Note that the position is relative to the parent.
\param newpos: New relative postition of the scene node. */
\param newpos New relative postition of the scene node. */
virtual void setPosition(const core::vector3df& newpos)
{
RelativeTranslation = newpos;
......@@ -426,8 +440,7 @@ namespace scene
//! Gets the abolute position of the node.
/** The position is absolute.
\return Returns the current absolute position of the scene node. */
//! \return The current absolute position of the scene node.
virtual core::vector3df getAbsolutePosition() const
{
return AbsoluteTransformation.getTranslation();
......@@ -436,10 +449,10 @@ namespace scene
//! Enables or disables automatic culling based on the bounding box.
/** Automatic culling is enabled by default. Note that not
all SceneNodes support culling (e.g. the billboard scene node)
and that some nodes always cull their geometry because it is their
only reason for existence, for example the OctreeSceneNode.
\param state: The culling state to be used. */
all SceneNodes support culling and that some nodes always cull
their geometry because it is their only reason for existence,
for example the OctreeSceneNode.
\param state The culling state to be used. */
void setAutomaticCulling( E_CULLING_TYPE state)
{
AutomaticCullingState = state;
......@@ -447,8 +460,7 @@ namespace scene
//! Gets the automatic culling state.
/** \return The node is culled based on its bounding box if this method
returns true, otherwise no culling is performed. */
/** \return The automatic culling state. */
E_CULLING_TYPE getAutomaticCulling() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
......@@ -457,16 +469,18 @@ namespace scene
//! Sets if debug data like bounding boxes should be drawn.
/** Please note that not all scene nodes support this feature. */
virtual void setDebugDataVisible(E_DEBUG_SCENE_TYPE visible)
/** A bitwise OR of the types is supported.
Please note that not all scene nodes support this feature.
\param state The debug data visibility state to be used. */
virtual void setDebugDataVisible(s32 state)
{
DebugDataVisible = visible;
DebugDataVisible = state;
}
//! Returns if debug data like bounding boxes are drawed.
E_DEBUG_SCENE_TYPE isDebugDataVisible() const
//! Returns if debug data like bounding boxes are drawn.
/** \return A bitwise OR of the debug data values currently visible. */
s32 isDebugDataVisible() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return DebugDataVisible;
}
......@@ -479,9 +493,11 @@ namespace scene
IsDebugObject = debugObject;
}
//! Returns if this scene node is a debug object.
/** Debug objects have some special properties, for example they can be easily
excluded from collision detection or from serialization, etc. */
excluded from collision detection or from serialization, etc.
\return If this node is a debug object, true is returned. */
bool isDebugObject() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
......@@ -490,6 +506,7 @@ namespace scene
//! Returns a const reference to the list of all children.
/** \return The list of all children of this node. */
const core::list<ISceneNode*>& getChildren() const
{
return Children;
......@@ -497,6 +514,7 @@ namespace scene
//! Changes the parent of the scene node.
/** \param newParent The new parent to be used. */
virtual void setParent(ISceneNode* newParent)
{
grab();
......@@ -519,7 +537,7 @@ namespace scene
//! ISceneNode::setTriangleSelector(). If a scene node got no triangle
//! selector, but collision tests should be done with it, a triangle
//! selector is created using the bounding box of the scene node.
//! \return Returns a pointer to the TriangleSelector or NULL, if there
//! \return A pointer to the TriangleSelector or 0, if there
//! is none.
virtual ITriangleSelector* getTriangleSelector() const
{
......@@ -534,7 +552,7 @@ namespace scene
//! create their own selector by default, so it would be good to
//! check if there is already a selector in this node by calling
//! ISceneNode::getTriangleSelector().
//! \param selector: New triangle selector for this scene node.
//! \param selector New triangle selector for this scene node.
virtual void setTriangleSelector(ITriangleSelector* selector)
{
if (TriangleSelector)
......@@ -549,7 +567,7 @@ namespace scene
//! updates the absolute position based on the relative and the parents position
virtual void updateAbsolutePosition()
{
if (Parent )
if (Parent)
{
AbsoluteTransformation =
Parent->getAbsoluteTransformation() * getRelativeTransformation();
......@@ -558,23 +576,32 @@ namespace scene
AbsoluteTransformation = getRelativeTransformation();
}
//! Returns the parent of this scene node
//! \return A pointer to the parent.
scene::ISceneNode* getParent() const
{
return Parent;
}
//! Returns type of the scene node
//! \return The type of this node.
virtual ESCENE_NODE_TYPE getType() const
{
return ESNT_UNKNOWN;
}
//! Writes attributes of the scene node.
//! Implement this to expose the attributes of your scene node for
//! scripting languages, editors, debuggers or xml serialization purposes.
//! \param out The attribute container to write into.
//! \param options Additional options which might influence the serialization.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
{
if (!out)
return;
out->addString ("Name", Name.c_str());
out->addInt ("Id", ID );
......@@ -588,11 +615,16 @@ namespace scene
out->addBool ("IsDebugObject", IsDebugObject );
}
//! Reads attributes of the scene node.
//! Implement this to set the attributes of your scene node for
//! scripting languages, editors, debuggers or xml deserialization purposes.
//! \param in The attribute container to read from.
//! \param options Additional options which might influence the deserialization.
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
{
if (!in)
return;
Name = in->getAttributeAsString("Name");
ID = in->getAttributeAsInt("Id");
......@@ -603,13 +635,16 @@ namespace scene
IsVisible = in->getAttributeAsBool("Visible");
AutomaticCullingState = (scene::E_CULLING_TYPE ) in->getAttributeAsEnumeration("AutomaticCulling", scene::AutomaticCullingNames);
DebugDataVisible = (scene::E_DEBUG_SCENE_TYPE ) in->getAttributeAsInt("DebugDataVisible");
DebugDataVisible = in->getAttributeAsInt("DebugDataVisible");
IsDebugObject = in->getAttributeAsBool("IsDebugObject");
updateAbsolutePosition();
}
//! Creates a clone of this scene node and its children.
//! \param newParent An optional new parent.
//! \param newManager An optional new scene manager.
//! \return The newly created clone of this node.
virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0)
{
return 0; // to be implemented by derived classes
......@@ -617,7 +652,10 @@ namespace scene
protected:
//! A clone function for the ISceneNode members.
//! this method can be used by clone() implementations of derived classes
//! \param topCopyFrom The node from which the values are copied
//! \param newManager The new scene manager.
void cloneMembers(ISceneNode* toCopyFrom, ISceneManager* newManager)
{
Name = toCopyFrom->Name;
......@@ -697,7 +735,7 @@ namespace scene
bool IsVisible;
//! flag if debug data should be drawn, such as Bounding Boxes.
E_DEBUG_SCENE_TYPE DebugDataVisible;
s32 DebugDataVisible;
//! is debug object?
bool IsDebugObject;
......
......@@ -37,26 +37,26 @@ const c8* const LightTypeNames[] =
*/
struct SLight
{
SLight() : AmbientColor(0.0f,0.0f,0.0f), DiffuseColor(1.0f,1.0f,1.0f),
SpecularColor(1.0f,1.0f,1.0f), Attenuation(1.0f,0.0f,0.0f),
Radius(100.0f), OuterCone(45.0f), InnerCone(0.0f),
Falloff(2.0f), CastShadows(true), Type(ELT_POINT),
Position(0.0f,0.0f,0.0f), Direction(0.0f,0.0f,1.0f)
SLight() : AmbientColor(0.f,0.f,0.f), DiffuseColor(1.f,1.f,1.f),
SpecularColor(1.f,1.f,1.f), Attenuation(1.f,0.f,0.f),
Radius(100.f), OuterCone(45.f), InnerCone(0.f), Falloff(2.f),
Position(0.f,0.f,0.f), Direction(0.f,0.f,1.f),
Type(ELT_POINT), CastShadows(true)
{};
//! Ambient color emitted by the light
SColorf AmbientColor;
//! Diffuse color emitted by the light.
/** This is the primary color you might want to set. */
//! This is the primary color you want to set.
SColorf DiffuseColor;
//! Specular color emitted by the light.
/** For details how to use specular highlights, see SMaterial::Shininess */
//! For details how to use specular highlights, see SMaterial::Shininess
SColorf SpecularColor;
//! Attenuation factors (constant, linear, quadratic)
/** Changes the light strength fading over distance */
//! Changes the light strength fading over distance
core::vector3df Attenuation;
//! Radius of light. Everything within this radius be be lighted.
......@@ -71,17 +71,19 @@ struct SLight
//! The light strength's decrease between Outer and Inner cone.
f32 Falloff;
//! Does the light cast shadows?
bool CastShadows;
//! Read-ONLY! Position of the light. If Type is ELT_DIRECTIONAL,
//! it is ignored. Changed via light scene node's position.
core::vector3df Position;
//! Read-ONLY! Direction of the light. If Type is ELT_POINT,
//! it is ignored. Changed via light scene node's rotation.
core::vector3df Direction;
//! Type of the light. Default: ELT_POINT
E_LIGHT_TYPE Type;
//! Read-ONLY! Position of the light. If Type is ELT_DIRECTIONAL, this is ignored.
core::vector3df Position;
//! Read-ONLY! Direction of the light. If Type is ELT_POINT, this is ignored.
core::vector3df Direction;
//! Does the light cast shadows?
bool CastShadows;
};
} // end namespace video
......
......@@ -49,7 +49,7 @@ namespace scene
// reverse search
virtual IMeshBuffer* getMeshBuffer( const video::SMaterial & material) const
{
for (s32 i = (s32) MeshBuffers.size(); --i >= 0; )
for (s32 i = (s32)MeshBuffers.size()-1; i >= 0; --i)
{
if ( material == MeshBuffers[i]->getMaterial())
return MeshBuffers[i];
......
......@@ -556,11 +556,11 @@ public:
}
//! finds first occurrence of a character of a list in string
/** \param c: List of strings to find. For example if the method
/** \param c: List of characters to find. For example if the method
should find the first occurrence of 'a' or 'b', this parameter should be "ab".
\param count: Amount of characters in the list. Ususally,
this should be strlen(ofParameter1)
\return Returns position where one of the character has been found,
\param count: Amount of characters in the list. Usually,
this should be strlen(c)
\return Returns position where one of the characters has been found,
or -1 if not found. */
s32 findFirstChar(const T* const c, u32 count) const
{
......@@ -579,8 +579,8 @@ public:
//! Finds first position of a character not in a given list.
/** \param c: List of characters not to find. For example if the method
should find the first occurrence of a character not 'a' or 'b', this parameter should be "ab".
\param count: Amount of characters in the list. Ususally,
this should be strlen(ofParameter1)
\param count: Amount of characters in the list. Usually,
this should be strlen(c)
\return Returns position where the character has been found,
or -1 if not found. */
template <class B>
......@@ -603,8 +603,8 @@ public:
//! Finds last position of a character not in a given list.
/** \param c: List of characters not to find. For example if the method
should find the first occurrence of a character not 'a' or 'b', this parameter should be "ab".
\param count: Amount of characters in the list. Ususally,
this should be strlen(ofParameter1)
\param count: Amount of characters in the list. Usually,
this should be strlen(c)
\return Returns position where the character has been found,
or -1 if not found. */
template <class B>
......@@ -654,6 +654,27 @@ public:
return -1;
}
//! finds last occurrence of a character of a list in string
/** \param c: List of strings to find. For example if the method
should find the last occurrence of 'a' or 'b', this parameter should be "ab".
\param count: Amount of characters in the list. Usually,
this should be strlen(c)
\return Returns position where one of the characters has been found,
or -1 if not found. */
s32 findLastChar(const T* const c, u32 count) const
{
if (!c)
return -1;
for (u32 i=(used-1); i>=0; --i)
for (u32 j=0; j<count; ++j)
if (array[i] == c[j])
return i;
return -1;
}
//! finds another string in this string
//! \param str: Another string
//! \return Returns positions where the string has been found,
......
......@@ -402,10 +402,9 @@ void CAnimatedMeshMD2::updateInterpolationBuffer(s32 frame, s32 startFrameLoop,
video::S3DVertex* first = FrameList[firstFrame].pointer();
video::S3DVertex* second = FrameList[secondFrame].pointer();
s32 count = FrameList[firstFrame].size();
// interpolate both frames
for (s32 i=0; i<count; ++i)
const u32 count = FrameList[firstFrame].size();
for (u32 i=0; i<count; ++i)
{
target->Pos = (second->Pos - first->Pos) * div + first->Pos;
target->Normal = (second->Normal - first->Normal) * div + first->Normal;
......@@ -722,7 +721,8 @@ void CAnimatedMeshMD2::getFrameLoop(EMD2_ANIMATION_TYPE l,
bool CAnimatedMeshMD2::getFrameLoop(const c8* name,
s32& outBegin, s32&outEnd, s32& outFPS) const
{
for (s32 i=0; i<(s32)FrameData.size(); ++i)
for (u32 i=0; i<FrameData.size(); ++i)
{
if (FrameData[i].name == name)
{
outBegin = FrameData[i].begin << MD2_FRAME_SHIFT;
......@@ -731,6 +731,7 @@ bool CAnimatedMeshMD2::getFrameLoop(const c8* name,
outFPS = FrameData[i].fps << MD2_FRAME_SHIFT;
return true;
}
}
return false;
}
......@@ -746,7 +747,7 @@ s32 CAnimatedMeshMD2::getAnimationCount() const
//! Returns name of md2 animation.
const c8* CAnimatedMeshMD2::getAnimationName(s32 nr) const
{
if (nr < 0 || nr >= (s32)FrameData.size())
if ((u32)nr >= FrameData.size())
return 0;
return FrameData[nr].name.c_str();
......
......@@ -260,20 +260,7 @@ void CAnimatedMeshSceneNode::render()
}
m=skinnedMesh;
if (m)
{
for (u32 g=0; g< m->getMeshBufferCount(); ++g)
{
const IMeshBuffer* mb = m->getMeshBuffer(g);
const core::matrix4 mat = AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation;
core::aabbox3df tmpbox(mb->getBoundingBox());
mat.transformBox(tmpbox);
if (g==0)
Box = tmpbox;
else
Box.addInternalBox(tmpbox);
}
}
}
if ( 0 == m )
......@@ -298,14 +285,15 @@ void CAnimatedMeshSceneNode::render()
// overwrite half transparency
if ( DebugDataVisible & scene::EDS_HALF_TRANSPARENCY )
{
if (RenderFromIdentity)
driver->setTransform(video::ETS_WORLD, core::matrix4() );
for (u32 i=0; i<m->getMeshBufferCount(); ++i)
{
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
mat = Materials[i];
mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
if (Mesh->getMeshType() == EAMT_SKINNED)
if (RenderFromIdentity)
driver->setTransform(video::ETS_WORLD, core::matrix4() );
else if (Mesh->getMeshType() == EAMT_SKINNED)
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation);
driver->setMaterial(mat);
......@@ -318,8 +306,7 @@ void CAnimatedMeshSceneNode::render()
// render original meshes
if ( renderMeshes )
{
if (RenderFromIdentity)
driver->setTransform(video::ETS_WORLD, core::matrix4() );
for (u32 i=0; i<m->getMeshBufferCount(); ++i)
{
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(Materials[i].MaterialType);
......@@ -331,7 +318,9 @@ void CAnimatedMeshSceneNode::render()
{
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
if (Mesh->getMeshType() == EAMT_SKINNED)
if (RenderFromIdentity)
driver->setTransform(video::ETS_WORLD, core::matrix4() );
else if (Mesh->getMeshType() == EAMT_SKINNED)
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation);
driver->setMaterial(Materials[i]);
......@@ -402,11 +391,11 @@ void CAnimatedMeshSceneNode::render()
// show bounding box
if ( DebugDataVisible & scene::EDS_BBOX_BUFFERS )
{
if (RenderFromIdentity)
driver->setTransform(video::ETS_WORLD, core::matrix4() );
for (u32 g=0; g< m->getMeshBufferCount(); ++g)
{
const IMeshBuffer* mb = m->getMeshBuffer(g);
if (Mesh->getMeshType() == EAMT_SKINNED)
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation);
driver->draw3DBox( mb->getBoundingBox(),
......@@ -483,12 +472,13 @@ void CAnimatedMeshSceneNode::render()
mat.ZBuffer = true;
driver->setMaterial(mat);
if (RenderFromIdentity)
driver->setTransform(video::ETS_WORLD, core::matrix4() );
for (u32 g=0; g<m->getMeshBufferCount(); ++g)
{
const IMeshBuffer* mb = m->getMeshBuffer(g);
if (Mesh->getMeshType() == EAMT_SKINNED)
if (RenderFromIdentity)
driver->setTransform(video::ETS_WORLD, core::matrix4() );
else if (Mesh->getMeshType() == EAMT_SKINNED)
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation);
driver->drawMeshBuffer(mb);
}
......
......@@ -21,8 +21,7 @@ CGUIButton::CGUIButton(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle, bool noclip)
: IGUIButton(environment, parent, id, rectangle), Pressed(false),
IsPushButton(false), UseAlphaChannel(false), Border(true),
MouseOverTime(0), FocusTime(0), ClickTime(0), SpriteBank(0),
OverrideFont(0), Image(0), PressedImage(0)
ClickTime(0), SpriteBank(0), OverrideFont(0), Image(0), PressedImage(0)
{
#ifdef _DEBUG
setDebugName("CGUIButton");
......@@ -39,7 +38,6 @@ CGUIButton::CGUIButton(IGUIEnvironment* environment, IGUIElement* parent,
}
//! destructor
CGUIButton::~CGUIButton()
{
......@@ -56,12 +54,14 @@ CGUIButton::~CGUIButton()
SpriteBank->drop();
}
//! Sets if the button should use the skin to draw its border
void CGUIButton::setDrawBorder(bool border)
{
Border = border;
}
void CGUIButton::setSpriteBank(IGUISpriteBank* sprites)
{
if (sprites)
......@@ -73,6 +73,7 @@ void CGUIButton::setSpriteBank(IGUISpriteBank* sprites)
SpriteBank = sprites;
}
void CGUIButton::setSprite(EGUI_BUTTON_STATE state, s32 index, video::SColor color, bool loop)
{
if (SpriteBank)
......@@ -87,6 +88,7 @@ void CGUIButton::setSprite(EGUI_BUTTON_STATE state, s32 index, video::SColor col
}
}
//! called if an event happened.
bool CGUIButton::OnEvent(const SEvent& event)
{
......@@ -199,7 +201,6 @@ bool CGUIButton::OnEvent(const SEvent& event)
}
//! draws the element and its children
void CGUIButton::draw()
{
......@@ -287,7 +288,6 @@ void CGUIButton::draw()
}
//! sets another skin independent font. if this is set to zero, the button uses the font of the skin.
void CGUIButton::setOverrideFont(IGUIFont* font)
{
......@@ -318,6 +318,7 @@ void CGUIButton::setImage(video::ITexture* image)
setPressedImage(Image);
}
//! Sets the image which should be displayed on the button when it is in its normal state.
void CGUIButton::setImage(video::ITexture* image, const core::rect<s32>& pos)
{
......@@ -334,6 +335,7 @@ void CGUIButton::setImage(video::ITexture* image, const core::rect<s32>& pos)
setPressedImage(Image, pos);
}
//! Sets an image which should be displayed on the button when it is in pressed state.
void CGUIButton::setPressedImage(video::ITexture* image)
{
......@@ -348,6 +350,7 @@ void CGUIButton::setPressedImage(video::ITexture* image)
PressedImage->grab();
}
//! Sets the image which should be displayed on the button when it is in its pressed state.
void CGUIButton::setPressedImage(video::ITexture* image, const core::rect<s32>& pos)
{
......@@ -378,6 +381,7 @@ bool CGUIButton::isPressed() const
return Pressed;
}
//! Sets the pressed state of the button if this is a pushbutton
void CGUIButton::setPressed(bool pressed)
{
......@@ -388,6 +392,7 @@ void CGUIButton::setPressed(bool pressed)
}
}
//! Returns whether the button is a push button
bool CGUIButton::isPushButton() const
{
......@@ -395,12 +400,14 @@ bool CGUIButton::isPushButton() const
return IsPushButton;
}
//! Sets if the alpha channel should be used for drawing images on the button (default is false)
void CGUIButton::setUseAlphaChannel(bool useAlphaChannel)
{
UseAlphaChannel = useAlphaChannel;
}
//! Returns if the alpha channel should be used for drawing images on the button
bool CGUIButton::isAlphaChannelUsed() const
{
......@@ -408,16 +415,17 @@ bool CGUIButton::isAlphaChannelUsed() const
return UseAlphaChannel;
}
bool CGUIButton::isDrawingBorder() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return Border;
}
//! Writes attributes of the element.
void CGUIButton::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
{
IGUIButton::serializeAttributes(out,options);
out->addBool ("PushButton", IsPushButton );
......@@ -435,6 +443,7 @@ void CGUIButton::serializeAttributes(io::IAttributes* out, io::SAttributeReadWri
// out->addString ("OverrideFont", OverrideFont);
}
//! Reads attributes of the element
void CGUIButton::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
{
......@@ -463,7 +472,9 @@ void CGUIButton::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWr
updateAbsolutePosition();
}
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
......@@ -108,8 +108,6 @@ namespace gui
bool Border;
u32 MouseOverTime;
u32 FocusTime;
u32 ClickTime;
IGUISpriteBank* SpriteBank;
......
......@@ -206,9 +206,11 @@ CGUITabControl::CGUITabControl(IGUIEnvironment* environment,
//! destructor
CGUITabControl::~CGUITabControl()
{
for (s32 i=0; i<(s32)Tabs.size(); ++i)
for (u32 i=0; i<Tabs.size(); ++i)
{
if (Tabs[i])
Tabs[i]->drop();
}
if (UpButton)
UpButton->drop();
......@@ -269,9 +271,11 @@ void CGUITabControl::addTab(CGUITab* tab)
return;
// check if its already added
for (s32 i=0; i < (s32)Tabs.size(); ++i)
for (u32 i=0; i < Tabs.size(); ++i)
{
if (Tabs[i] == tab)
return;
}
tab->grab();
......@@ -309,7 +313,7 @@ s32 CGUITabControl::getTabCount() const
//! Returns a tab based on zero based index
IGUITab* CGUITabControl::getTab(s32 idx) const
{
if (idx < 0 || idx >= (s32)Tabs.size())
if ((u32)idx >= Tabs.size())
return 0;
return Tabs[idx];
......@@ -523,7 +527,7 @@ void CGUITabControl::draw()
//const wchar_t* activetext = 0;
CGUITab *activeTab = 0;
for (s32 i=CurrentScrollTabIndex; i<(s32)Tabs.size(); ++i)
for (u32 i=0; i<Tabs.size(); ++i)
{
// get Text
const wchar_t* text = 0;
......@@ -543,7 +547,7 @@ void CGUITabControl::draw()
pos += len;
if (i == ActiveTab)
if ((s32)i == ActiveTab)
{
left = frameRect.UpperLeftCorner.X;
right = frameRect.LowerRightCorner.X;
......
......@@ -17,6 +17,7 @@ CMetaTriangleSelector::CMetaTriangleSelector()
#endif
}
//! destructor
CMetaTriangleSelector::~CMetaTriangleSelector()
{
......@@ -24,7 +25,6 @@ CMetaTriangleSelector::~CMetaTriangleSelector()
}
//! Returns amount of all available triangles in this selector
s32 CMetaTriangleSelector::getTriangleCount() const
{
......@@ -36,7 +36,6 @@ s32 CMetaTriangleSelector::getTriangleCount() const
}
//! Gets all triangles.
void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
s32& outTriangleCount, const core::matrix4* transform) const
......@@ -54,7 +53,6 @@ void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 array
}
//! Gets all triangles which lie within a specific bounding box.
void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
s32& outTriangleCount, const core::aabbox3d<f32>& box,
......@@ -74,7 +72,6 @@ void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 array
}
//! Gets all triangles which have or may have contact with a 3d line.
void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
s32& outTriangleCount, const core::line3d<f32>& line,
......@@ -94,7 +91,6 @@ void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 array
}
//! Adds a triangle selector to the collection of triangle selectors
//! in this metaTriangleSelector.
void CMetaTriangleSelector::addTriangleSelector(ITriangleSelector* toAdd)
......@@ -107,23 +103,23 @@ void CMetaTriangleSelector::addTriangleSelector(ITriangleSelector* toAdd)
}
//! Removes a specific triangle selector which was added before from the collection.
bool CMetaTriangleSelector::removeTriangleSelector(ITriangleSelector* toRemove)
{
for (u32 i=0; i<TriangleSelectors.size(); ++i)
{
if (toRemove == TriangleSelectors[i])
{
TriangleSelectors[i]->drop();
TriangleSelectors.erase(i);
return true;
}
}
return false;
}
//! Removes all triangle selectors from the collection.
void CMetaTriangleSelector::removeAllTriangleSelectors()
{
......
......@@ -422,7 +422,7 @@ void CParticleSystemSceneNode::doParticleSystem(u32 time)
// animate all particles
f32 scale = (f32)timediff;
for (s32 i=0; i<(s32)Particles.size();)
for (u32 i=0; i<Particles.size();)
{
if (now > Particles[i].endTime)
Particles.erase(i);
......
......@@ -278,8 +278,8 @@ CSceneManager::~CSceneManager()
if (MeshManipulator)
MeshManipulator->drop();
if ( GUIEnvironment )
GUIEnvironment->drop ();
if (GUIEnvironment)
GUIEnvironment->drop();
u32 i;
......@@ -350,8 +350,9 @@ video::IVideoDriver* CSceneManager::getVideoDriver()
return Driver;
}
//! returns the GUI Environment
gui::IGUIEnvironment* CSceneManager::getGUIEnvironment ()
gui::IGUIEnvironment* CSceneManager::getGUIEnvironment()
{
return GUIEnvironment;
}
......@@ -376,6 +377,7 @@ ITextSceneNode* CSceneManager::addTextSceneNode(gui::IGUIFont* font,
return t;
}
//! Adds a text scene node, which uses billboards
ITextSceneNode* CSceneManager::addBillboardTextSceneNode(gui::IGUIFont* font,
const wchar_t* text, ISceneNode* parent,
......@@ -399,12 +401,9 @@ ITextSceneNode* CSceneManager::addBillboardTextSceneNode(gui::IGUIFont* font,
//! Adds a scene node, which can render a quake3 shader
ISceneNode* CSceneManager::addQuake3SceneNode( IMeshBuffer* meshBuffer,
ISceneNode* CSceneManager::addQuake3SceneNode(IMeshBuffer* meshBuffer,
const quake3::SShader * shader,
ISceneNode* parent,
s32 id
)
ISceneNode* parent, s32 id)
{
if ( 0 == shader )
return 0;
......@@ -412,11 +411,10 @@ ISceneNode* CSceneManager::addQuake3SceneNode( IMeshBuffer* meshBuffer,
if (!parent)
parent = this;
CQuake3ShaderSceneNode* node = new CQuake3ShaderSceneNode ( parent, this, id, FileSystem, meshBuffer, shader );
CQuake3ShaderSceneNode* node = new CQuake3ShaderSceneNode( parent, this, id, FileSystem, meshBuffer, shader );
node->drop();
return node;
}
//! adds Volume Lighting Scene Node.
......@@ -437,8 +435,9 @@ ISceneNode* CSceneManager::addVolumeLightSceneNode(ISceneNode* parent, s32 id,
//! 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.
ISceneNode* CSceneManager::addCubeSceneNode(f32 size, ISceneNode* parent, s32 id,
const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale)
ISceneNode* CSceneManager::addCubeSceneNode(f32 size, ISceneNode* parent,
s32 id, const core::vector3df& position,
const core::vector3df& rotation, const core::vector3df& scale)
{
if (!parent)
parent = this;
......@@ -449,11 +448,11 @@ ISceneNode* CSceneManager::addCubeSceneNode(f32 size, ISceneNode* parent, s32 id
return node;
}
//! Adds a sphere scene node for test purposes to the scene.
ISceneNode* CSceneManager::addSphereSceneNode(f32 radius, s32 polyCount, ISceneNode* parent, s32 id,
const core::vector3df& position,
const core::vector3df& rotation,
const core::vector3df& scale)
ISceneNode* CSceneManager::addSphereSceneNode(f32 radius, s32 polyCount,
ISceneNode* parent, s32 id, const core::vector3df& position,
const core::vector3df& rotation, const core::vector3df& scale)
{
if (!parent)
parent = this;
......@@ -504,7 +503,6 @@ ISceneNode* CSceneManager::addWaterSurfaceSceneNode(IMesh* mesh, f32 waveHeight,
}
//! adds a scene node for rendering an animated mesh model
IAnimatedMeshSceneNode* CSceneManager::addAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, s32 id,
const core::vector3df& position, const core::vector3df& rotation,
......@@ -584,7 +582,6 @@ ICameraSceneNode* CSceneManager::addCameraSceneNode(ISceneNode* parent,
}
//! Adds a camera scene node which is able to be controlle with the mouse similar
//! like in the 3D Software Maya by Alias Wavefront.
//! The returned pointer must not be dropped.
......@@ -604,7 +601,6 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent,
}
//! Adds a camera scene node which is able to be controled with the mouse and keys
//! like in most first person shooters (FPS):
ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent,
......@@ -624,7 +620,6 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent,
}
//! Adds a dynamic light scene node. The light will cast dynamic light on all
//! other scene nodes in the scene, which have the material flag video::MTF_LIGHTING
//! turned on. (This is the default setting in most scene nodes).
......@@ -641,7 +636,6 @@ ILightSceneNode* CSceneManager::addLightSceneNode(ISceneNode* parent,
}
//! Adds a billboard scene node to the scene. A billboard is like a 3d sprite: A 2d element,
//! which always looks to the camera. It is usually used for things like explosions, fire,
//! lensflares and things like that.
......@@ -1239,9 +1233,9 @@ void CSceneManager::drawAll()
Driver->setAmbientLight(AmbientLight);
LightList.sort (); // on distance to camera
LightList.sort(); // on distance to camera
u32 maxLights = core::min_ ( Driver->getMaximalDynamicLightAmount (), LightList.size () );
u32 maxLights = core::min_ ( Driver->getMaximalDynamicLightAmount(), LightList.size() );
for (i=0; i< maxLights; ++i)
LightList[i].node->render();
......@@ -1267,7 +1261,7 @@ void CSceneManager::drawAll()
for (i=0; i<SolidNodeList.size(); ++i)
SolidNodeList[i].node->render();
Parameters.setAttribute ( "drawn", (s32) SolidNodeList.size () );
Parameters.setAttribute ( "drawn", (s32) SolidNodeList.size() );
SolidNodeList.set_used(0);
}
......@@ -1296,7 +1290,6 @@ void CSceneManager::drawAll()
TransparentNodeList.set_used(0);
}
clearDeletionList();
CurrentRendertime = ESNRP_COUNT;
......@@ -1495,7 +1488,7 @@ void CSceneManager::clearDeletionList()
if (DeletionList.empty())
return;
for (s32 i=0; i<(s32)DeletionList.size(); ++i)
for (u32 i=0; i<DeletionList.size(); ++i)
{
DeletionList[i]->remove();
DeletionList[i]->drop();
......
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