Merging r6405 through r6424 from trunk to ogl-es branch

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6425 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2022-09-22 21:55:03 +00:00
parent ddc14ea87e
commit 07f17647d2
46 changed files with 589 additions and 463 deletions

View File

@ -176,6 +176,17 @@ namespace scene
return Vertices[i].TCoords;
}
//! returns color of vertex i
virtual video::SColor& getColor(u32 i) IRR_OVERRIDE
{
return Vertices[i].Color;
}
//! returns color of vertex i
virtual const video::SColor& getColor(u32 i) const IRR_OVERRIDE
{
return Vertices[i].Color;
}
//! Append the vertices and indices to the current buffer
/** Only works for compatible types, i.e. either the same type

View File

@ -121,19 +121,23 @@ namespace scene
virtual f32 getFOV() const =0;
//! Sets the value of the near clipping plane. (default: 1.0f)
/** \param zn: New z near value. */
/** Also changes projection matrix and resets IsOrthogonal flag.
\param zn: New z near value. */
virtual void setNearValue(f32 zn) =0;
//! Sets the value of the far clipping plane (default: 2000.0f)
/** \param zf: New z far value. */
/** Also changes projection matrix and resets IsOrthogonal flag.
\param zf: New z far value. */
virtual void setFarValue(f32 zf) =0;
//! Sets the aspect ratio (default: 4.0f / 3.0f)
/** \param aspect: New aspect ratio. */
/** Also changes projection matrix and resets IsOrthogonal flag.
\param aspect: New aspect ratio. */
virtual void setAspectRatio(f32 aspect) =0;
//! Sets the field of view (Default: PI / 2.5f)
/** \param fovy: New field of view in radians. */
/** Also changes projection matrix and resets IsOrthogonal flag.
\param fovy: New field of view in radians. */
virtual void setFOV(f32 fovy) =0;
//! Get the view frustum.
@ -165,7 +169,10 @@ namespace scene
@see getTargetAndRotationBinding() */
virtual void bindTargetAndRotation(bool bound) =0;
//! Updates the matrices without uploading them to the driver
//! Updates the view matrix and frustum without uploading the matrix to the driver.
/** You need this when you want an up-to-date camera view matrix & frustum before the render() call.
Usually you should call updateAbsolutePosition() before calling this.
Despite it's function name, the projection matrix is not touched. */
virtual void updateMatrices() = 0;
//! Queries if the camera scene node's rotation and its target position are bound together.

View File

@ -166,6 +166,18 @@ namespace scene
{
return getVertexBuffer()[i].Normal;
}
//! returns color of vertex i
virtual video::SColor& getColor(u32 i) IRR_OVERRIDE
{
return getVertexBuffer()[i].Color;
}
//! returns color of vertex i
virtual const video::SColor& getColor(u32 i) const IRR_OVERRIDE
{
return getVertexBuffer()[i].Color;
}
};

View File

@ -22,7 +22,10 @@ namespace scene
before or after each scene node is rendered. It is assumed that the
ILightManager implementation will store any data that it wishes to
retain, i.e. the ISceneManager to which it is assigned, the lightList,
the current render pass, and the current scene node. */
the current render pass, and the current scene node.
It can also be useful for shaders as it allows finding out the currently rendered SceneNode.
*/
class ILightManager : public IReferenceCounted
{
public:
@ -35,27 +38,27 @@ namespace scene
the light manager may modify. This reference will remain valid
until OnPostRender().
*/
virtual void OnPreRender(core::array<ISceneNode*> & lightList) = 0;
virtual void OnPreRender(core::array<ISceneNode*> & lightList) {};
//! Called after the last scene node is rendered.
/** After this call returns, the lightList passed to OnPreRender() becomes invalid. */
virtual void OnPostRender(void) = 0;
virtual void OnPostRender(void) {};
//! Called before a render pass begins
/** \param renderPass: the render pass that's about to begin */
virtual void OnRenderPassPreRender(E_SCENE_NODE_RENDER_PASS renderPass) = 0;
virtual void OnRenderPassPreRender(E_SCENE_NODE_RENDER_PASS renderPass) {};
//! Called after the render pass specified in OnRenderPassPreRender() ends
/** \param[in] renderPass: the render pass that has finished */
virtual void OnRenderPassPostRender(E_SCENE_NODE_RENDER_PASS renderPass) = 0;
virtual void OnRenderPassPostRender(E_SCENE_NODE_RENDER_PASS renderPass) {};
//! Called before the given scene node is rendered
/** \param[in] node: the scene node that's about to be rendered */
virtual void OnNodePreRender(ISceneNode* node) = 0;
virtual void OnNodePreRender(ISceneNode* node) {};
//! Called after the the node specified in OnNodePreRender() has been rendered
/** \param[in] node: the scene node that has just been rendered */
virtual void OnNodePostRender(ISceneNode* node) = 0;
virtual void OnNodePostRender(ISceneNode* node) {};
};
} // end namespace scene
} // end namespace irr

View File

@ -119,6 +119,12 @@ namespace scene
//! returns texture coord of vertex i
virtual core::vector2df& getTCoords(u32 i) = 0;
//! returns color of vertex i
virtual video::SColor& getColor(u32 i) = 0;
//! returns color of vertex i
virtual const video::SColor& getColor(u32 i) const = 0;
//! Append the vertices and indices to the current buffer
/** Only works for compatible vertex types
and not implemented for most buffers for now.

View File

@ -103,7 +103,9 @@ namespace scene
bool angleWeighted=false) const=0;
//! Scales the actual mesh, not a scene node.
/** \param mesh Mesh on which the operation is performed.
/** Note: When your scale are not uniform then
prefer the transform function to have correct normals.
\param mesh Mesh on which the operation is performed.
\param factor Scale factor for each axis. */
void scale(IMesh* mesh, const core::vector3df& factor) const
{
@ -111,7 +113,9 @@ namespace scene
}
//! Scales the actual meshbuffer, not a scene node.
/** \param buffer Meshbuffer on which the operation is performed.
/** Note: When your scale are not uniform then
prefer the transform function to have correct normals.
\param buffer Meshbuffer on which the operation is performed.
\param factor Scale factor for each axis. */
void scale(IMeshBuffer* buffer, const core::vector3df& factor) const
{
@ -146,9 +150,12 @@ namespace scene
/** \param mesh Mesh on which the operation is performed.
\param m transformation matrix.
\param normalsUpdate When 0 - don't update normals.
When 1 - update normals with inverse transposed of the transformation matrix
When 1 - update normals with inner 3x3 matrix of the inverse transposed of the transformation matrix
should be set when the matrix has rotation or non-uniform scaling
\param normalizeNormals When true it normalizes all normals again.
Recommended to set this when normalsUpdate is 1 and there is any scaling
*/
void transform(IMesh* mesh, const core::matrix4& m, u32 normalsUpdate = 0) const
void transform(IMesh* mesh, const core::matrix4& m, u32 normalsUpdate = 0, bool normalizeNormals=false) const
{
apply(SVertexPositionTransformManipulator(m), mesh, true);
@ -158,18 +165,25 @@ namespace scene
if ( m.getInverse(invT) )
{
invT = invT.getTransposed();
apply(SVertexNormalTransformManipulator(invT), mesh, false);
apply(SVertexNormalRotateScaleManipulator(invT), mesh, false);
}
}
if ( normalizeNormals )
{
apply(SVertexNormalizeNormalManipulator(), mesh, false);
}
}
//! Applies a transformation to a meshbuffer
/** \param buffer Meshbuffer on which the operation is performed.
\param m transformation matrix.
\param normalsUpdate When 0 - don't update normals.
When 1 - update normals with inverse transposed of the transformation matrix
When 1 - update normals with inner 3x3 matrix of the inverse transposed of the transformation matrix
should be set when the matrix has rotation or non-uniform scaling
\param normalizeNormals When true it normalizes all normals again.
Recommended to set this when normalsUpdate is 1 and there is any scaling
*/
void transform(IMeshBuffer* buffer, const core::matrix4& m, u32 normalsUpdate = 0) const
void transform(IMeshBuffer* buffer, const core::matrix4& m, u32 normalsUpdate = 0, bool normalizeNormals=false) const
{
apply(SVertexPositionTransformManipulator(m), buffer, true);
@ -179,9 +193,13 @@ namespace scene
if ( m.getInverse(invT) )
{
invT = invT.getTransposed();
apply(SVertexNormalTransformManipulator(invT), buffer, false);
apply(SVertexNormalRotateScaleManipulator(invT), buffer, false);
}
}
if ( normalizeNormals )
{
apply(SVertexNormalizeNormalManipulator(), buffer, false);
}
}
//! Applies a transformation to a mesh
@ -239,6 +257,7 @@ namespace scene
/** This is useful if you want to draw tangent space normal
mapped geometry because it calculates the tangent and binormal
data which is needed there.
Note: Only 16-bit meshbuffers supported so far
\param mesh Input mesh
\param recalculateNormals The normals are recalculated if set,
otherwise the original ones are kept. Note that keeping the
@ -257,7 +276,8 @@ namespace scene
bool angleWeighted=false, bool recalculateTangents=true) const=0;
//! Creates a copy of the mesh, which will only consist of S3DVertex2TCoord vertices.
/** \param mesh Input mesh
/** Note: Only 16-bit meshbuffers supported so far
\param mesh Input mesh
\return Mesh consisting only of S3DVertex2TCoord vertices. If
you no longer need the cloned mesh, you should call
IMesh::drop(). See IReferenceCounted::drop() for more
@ -265,7 +285,8 @@ namespace scene
virtual IMesh* createMeshWith2TCoords(IMesh* mesh) const = 0;
//! Creates a copy of the mesh, which will only consist of S3DVertex vertices.
/** \param mesh Input mesh
/** Note: Only 16-bit meshbuffers supported so far
\param mesh Input mesh
\return Mesh consisting only of S3DVertex vertices. If
you no longer need the cloned mesh, you should call
IMesh::drop(). See IReferenceCounted::drop() for more
@ -273,15 +294,17 @@ namespace scene
virtual IMesh* createMeshWith1TCoords(IMesh* mesh) const = 0;
//! Creates a copy of a mesh with all vertices unwelded
/** \param mesh Input mesh
/** Note: Only 16-bit meshbuffers supported so far
\param mesh Input mesh
\return Mesh consisting only of unique faces. All vertices
which were previously shared are now duplicated. If you no
longer need the cloned mesh, you should call IMesh::drop(). See
IReferenceCounted::drop() for more information. */
virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const = 0;
//! Creates a copy of a mesh with vertices welded
/** \param mesh Input mesh
//! Creates a copy of a mesh with vertices welded
/** Note: Only 16-bit meshbuffers supported so far, 32-bit buffer are cloned
\param mesh Input mesh
\param tolerance The threshold for vertex comparisons.
\return Mesh without redundant vertices. If you no longer need
the cloned mesh, you should call IMesh::drop(). See

View File

@ -171,6 +171,21 @@ namespace scene
return (*Vertices)[Indices[i]].TCoords;
}
//! returns color of vertex i
virtual video::SColor& getColor(u32 i) IRR_OVERRIDE
{
IRR_DEBUG_BREAK_IF(!Vertices);
return (*Vertices)[Indices[i]].Color;
}
//! returns color of vertex i
virtual const video::SColor& getColor(u32 i) const IRR_OVERRIDE
{
IRR_DEBUG_BREAK_IF(!Vertices);
return (*Vertices)[Indices[i]].Color;
}
//! append the vertices and indices to the current buffer
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) IRR_OVERRIDE
{

View File

@ -326,6 +326,34 @@ struct SSkinMeshBuffer : public IMeshBuffer
}
}
//! returns color of vertex i
virtual video::SColor& getColor(u32 i) IRR_OVERRIDE
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords[i].Color;
case video::EVT_TANGENTS:
return Vertices_Tangents[i].Color;
default:
return Vertices_Standard[i].Color;
}
}
//! returns color of vertex i
virtual const video::SColor& getColor(u32 i) const IRR_OVERRIDE
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords[i].Color;
case video::EVT_TANGENTS:
return Vertices_Tangents[i].Color;
default:
return Vertices_Standard[i].Color;
}
}
//! append the vertices and indices to the current buffer
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) IRR_OVERRIDE {}

View File

@ -277,6 +277,32 @@ namespace scene
core::matrix4 Transformation;
};
//! Vertex manipulator which transforms the normal of the vertex with the rotate/scale part of the given matrix (inner 3x3)
class SVertexNormalRotateScaleManipulator : public IVertexManipulator
{
public:
SVertexNormalRotateScaleManipulator(const core::matrix4& m) : Transformation(m) {}
template <typename VType>
void operator()(VType& vertex) const
{
Transformation.rotateVect(vertex.Normal);
}
private:
core::matrix4 Transformation;
};
//! Vertex manipulator which normalizes the normal of the vertex
class SVertexNormalizeNormalManipulator : public IVertexManipulator
{
public:
SVertexNormalizeNormalManipulator() {}
template <typename VType>
void operator()(VType& vertex) const
{
vertex.Normal.normalize();
}
};
//! Vertex manipulator which scales the TCoords of the vertex
class SVertexTCoordsScaleManipulator : public IVertexManipulator
{

View File

@ -947,13 +947,13 @@ public:
\param make_lower copy only lower case */
string<T> subString(u32 begin, s32 length, bool make_lower = false ) const
{
// clamp length to maximal value
if ((length+begin) > size())
length = size()-begin;
// if start after string
// or no proper substring length
if ((length <= 0) || (begin>=size()))
return string<T>("");
// clamp length to maximal value
if ((length+begin) > size())
length = size()-begin;
string<T> o;
o.reserve(length+1);

View File

@ -221,10 +221,10 @@ namespace core
//! Translate a vector by the inverse of the translation part of this matrix.
void inverseTranslateVect( vector3df& vect ) const;
//! Rotate a vector by the inverse of the rotation part of this matrix.
//! Tranform (rotate/scale) a vector by the inverse of the rotation part this matrix
void inverseRotateVect( vector3df& vect ) const;
//! Rotate a vector by the rotation part of this matrix.
//! Transform (rotate/scale) a vector by the rotation part of this matrix.
void rotateVect( vector3df& vect ) const;
//! An alternate transform vector method, writing into a second vector