Commit 99aedb34 authored by hybrid's avatar hybrid

Add convenience functions to change the HW buffer settings for a complete mesh...

Add convenience functions to change the HW buffer settings for a complete mesh instead of just one buffer.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1742 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 900123fd
...@@ -25,6 +25,14 @@ namespace scene ...@@ -25,6 +25,14 @@ namespace scene
EHM_STREAM EHM_STREAM
}; };
enum E_BUFFER_TYPE
{
EBT_NONE=0,
EBT_VERTEX,
EBT_INDEX,
EBT_VERTEX_AND_INDEX
};
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "IReferenceCounted.h" #include "IReferenceCounted.h"
#include "SMaterial.h" #include "SMaterial.h"
#include "EHardwareBufferFlags.h"
namespace irr namespace irr
{ {
...@@ -51,6 +52,12 @@ namespace scene ...@@ -51,6 +52,12 @@ namespace scene
/** \param flag: Flag to set in all materials. /** \param flag: Flag to set in all materials.
\param newvalue: New value to set in all materials. */ \param newvalue: New value to set in all materials. */
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) = 0; virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) = 0;
//! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX ) = 0;
//! flags the meshbuffer as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) = 0;
}; };
} // end namespace scene } // end namespace scene
......
...@@ -56,14 +56,6 @@ namespace scene ...@@ -56,14 +56,6 @@ namespace scene
EPT_POINT_SPRITES EPT_POINT_SPRITES
}; };
enum E_BUFFER_TYPE
{
EBT_NONE=0,
EBT_VERTEX,
EBT_INDEX,
EBT_VERTEX_AND_INDEX
};
//! Struct for holding a mesh with a single material //! Struct for holding a mesh with a single material
/** SMeshBuffer is a simple implementation of a MeshBuffer. /** SMeshBuffer is a simple implementation of a MeshBuffer.
...@@ -169,10 +161,10 @@ namespace scene ...@@ -169,10 +161,10 @@ namespace scene
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const = 0; virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const = 0;
//! set the hardware mapping hint, for driver //! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX ) = 0; virtual void setHardwareMappingHint( E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX ) = 0;
//! flags the meshbuffer as changed, reloads hardware buffers //! flags the meshbuffer as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX) = 0; virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) = 0;
//to be spit into vertex and index buffers: //to be spit into vertex and index buffers:
//! Get the currently used ID for identification of changes. //! Get the currently used ID for identification of changes.
......
...@@ -150,6 +150,20 @@ namespace scene ...@@ -150,6 +150,20 @@ namespace scene
Meshes[i]->setMaterialFlag(flag, newvalue); Meshes[i]->setMaterialFlag(flag, newvalue);
} }
//! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX )
{
for (u32 i=0; i<Meshes.size(); ++i)
Meshes[i]->setHardwareMappingHint(newMappingHint, buffer);
}
//! flags the meshbuffer as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
{
for (u32 i=0; i<Meshes.size(); ++i)
Meshes[i]->setDirty(buffer);
}
//! The bounding box of this mesh //! The bounding box of this mesh
core::aabbox3d<f32> Box; core::aabbox3d<f32> Box;
//! All meshes defining the animated mesh //! All meshes defining the animated mesh
......
...@@ -100,6 +100,20 @@ namespace scene ...@@ -100,6 +100,20 @@ namespace scene
MeshBuffers[i]->getMaterial().setFlag(flag, newvalue); MeshBuffers[i]->getMaterial().setFlag(flag, newvalue);
} }
//! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX )
{
for (u32 i=0; i<MeshBuffers.size(); ++i)
MeshBuffers[i]->setHardwareMappingHint(newMappingHint, buffer);
}
//! flags the meshbuffer as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
{
for (u32 i=0; i<MeshBuffers.size(); ++i)
MeshBuffers[i]->setDirty(buffer);
}
//! The meshbuffers of this mesh //! The meshbuffers of this mesh
core::array<IMeshBuffer*> MeshBuffers; core::array<IMeshBuffer*> MeshBuffers;
//! The bounding box of this mesh //! The bounding box of this mesh
......
...@@ -679,6 +679,22 @@ void CAnimatedMeshMD2::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalu ...@@ -679,6 +679,22 @@ void CAnimatedMeshMD2::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalu
} }
//! set the hardware mapping hint, for driver
void CAnimatedMeshMD2::setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint,
E_BUFFER_TYPE buffer)
{
InterpolationBuffer->setHardwareMappingHint(newMappingHint, buffer);
}
//! flags the meshbuffer as changed, reloads hardware buffers
void CAnimatedMeshMD2::setDirty(E_BUFFER_TYPE buffer)
{
InterpolationBuffer->setDirty(buffer);
}
//! returns an axis aligned bounding box //! returns an axis aligned bounding box
const core::aabbox3d<f32>& CAnimatedMeshMD2::getBoundingBox() const const core::aabbox3d<f32>& CAnimatedMeshMD2::getBoundingBox() const
{ {
......
...@@ -58,6 +58,12 @@ namespace scene ...@@ -58,6 +58,12 @@ namespace scene
//! sets a flag of all contained materials to a new value //! sets a flag of all contained materials to a new value
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue); virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue);
//! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX);
//! flags the meshbuffer as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX);
//! 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;
......
...@@ -96,6 +96,21 @@ void CAnimatedMeshMD3::setInterpolationShift ( u32 shift, u32 loopMode ) ...@@ -96,6 +96,21 @@ void CAnimatedMeshMD3::setInterpolationShift ( u32 shift, u32 loopMode )
} }
//! set the hardware mapping hint, for driver
void CAnimatedMeshMD3::setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint,
E_BUFFER_TYPE buffer)
{
MeshIPol.setHardwareMappingHint(newMappingHint, buffer);
}
//! flags the meshbuffer as changed, reloads hardware buffers
void CAnimatedMeshMD3::setDirty(E_BUFFER_TYPE buffer)
{
MeshIPol.setDirty(buffer);
}
//! Returns the animated tag list based on a detail level. 0 is the lowest, 255 the highest detail. //! Returns the animated tag list based on a detail level. 0 is the lowest, 255 the highest detail.
SMD3QuaterionTagList *CAnimatedMeshMD3::getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) SMD3QuaterionTagList *CAnimatedMeshMD3::getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop)
{ {
...@@ -172,17 +187,18 @@ IMesh* CAnimatedMeshMD3::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, ...@@ -172,17 +187,18 @@ IMesh* CAnimatedMeshMD3::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop,
return &MeshIPol; return &MeshIPol;
} }
//! create a Irrlicht MeshBuffer for a MD3 MeshBuffer //! create a Irrlicht MeshBuffer for a MD3 MeshBuffer
IMeshBuffer * CAnimatedMeshMD3::createMeshBuffer ( const SMD3MeshBuffer * source ) IMeshBuffer * CAnimatedMeshMD3::createMeshBuffer(const SMD3MeshBuffer* source)
{ {
SMeshBuffer * dest = new SMeshBuffer (); SMeshBuffer * dest = new SMeshBuffer();
dest->Vertices.set_used ( source->MeshHeader.numVertices ); dest->Vertices.set_used( source->MeshHeader.numVertices );
dest->Indices.set_used ( source->Indices.size () ); dest->Indices.set_used( source->Indices.size () );
u32 i; u32 i;
// fill in static face info // fill in static face info
for ( i = 0; i < source->Indices.size (); i += 3 ) for ( i = 0; i < source->Indices.size(); i += 3 )
{ {
dest->Indices[i + 0 ] = (u16) source->Indices[i + 0]; dest->Indices[i + 0 ] = (u16) source->Indices[i + 0];
dest->Indices[i + 1 ] = (u16) source->Indices[i + 1]; dest->Indices[i + 1 ] = (u16) source->Indices[i + 1];
...@@ -192,7 +208,7 @@ IMeshBuffer * CAnimatedMeshMD3::createMeshBuffer ( const SMD3MeshBuffer * source ...@@ -192,7 +208,7 @@ IMeshBuffer * CAnimatedMeshMD3::createMeshBuffer ( const SMD3MeshBuffer * source
// fill in static vertex info // fill in static vertex info
for ( i = 0; i!= (u32)source->MeshHeader.numVertices; ++i ) for ( i = 0; i!= (u32)source->MeshHeader.numVertices; ++i )
{ {
video::S3DVertex &v = dest->Vertices [ i ]; video::S3DVertex &v = dest->Vertices[i];
v.Color = 0xFFFFFFFF; v.Color = 0xFFFFFFFF;
v.TCoords.X = source->Tex[i].u; v.TCoords.X = source->Tex[i].u;
v.TCoords.Y = source->Tex[i].v; v.TCoords.Y = source->Tex[i].v;
......
...@@ -71,8 +71,14 @@ namespace scene ...@@ -71,8 +71,14 @@ namespace scene
return; return;
} }
//! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX);
//! flags the meshbuffer as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX);
//! set user axis aligned bounding box //! set user axis aligned bounding box
virtual void setBoundingBox( const core::aabbox3df& box) virtual void setBoundingBox(const core::aabbox3df& box)
{ {
return; return;
} }
......
...@@ -84,8 +84,7 @@ namespace scene ...@@ -84,8 +84,7 @@ namespace scene
//! Returns pointer to a mesh buffer which fits a material //! Returns pointer to a mesh buffer which fits a material
/** \param material: material to search for /** \param material: material to search for
\return Returns the pointer to the mesh buffer or \return Pointer to the mesh buffer or 0 if there is no such mesh buffer. */
NULL if there is no such mesh buffer. */
virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const
{ {
return 0; return 0;
...@@ -96,18 +95,18 @@ namespace scene ...@@ -96,18 +95,18 @@ namespace scene
return; return;
} }
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint ) //! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
{ {
return; return;
} }
virtual void setDirty() //! flags the meshbuffer as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
{ {
return; return;
} }
private: private:
//! constructs a mesh from the quake 3 level file. //! constructs a mesh from the quake 3 level file.
......
...@@ -601,6 +601,23 @@ void CSkinnedMesh::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) ...@@ -601,6 +601,23 @@ void CSkinnedMesh::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
} }
//! set the hardware mapping hint, for driver
void CSkinnedMesh::setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint,
E_BUFFER_TYPE buffer)
{
for (u32 i=0; i<LocalBuffers.size(); ++i)
LocalBuffers[i]->setHardwareMappingHint(newMappingHint, buffer);
}
//! flags the meshbuffer as changed, reloads hardware buffers
void CSkinnedMesh::setDirty(E_BUFFER_TYPE buffer)
{
for (u32 i=0; i<LocalBuffers.size(); ++i)
LocalBuffers[i]->setDirty(buffer);
}
//! uses animation from another mesh //! uses animation from another mesh
bool CSkinnedMesh::useAnimationFrom(const ISkinnedMesh *mesh) bool CSkinnedMesh::useAnimationFrom(const ISkinnedMesh *mesh)
{ {
......
...@@ -66,6 +66,12 @@ namespace scene ...@@ -66,6 +66,12 @@ namespace scene
//! sets a flag of all contained materials to a new value //! sets a flag of all contained materials to a new value
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue); virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue);
//! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX);
//! flags the meshbuffer as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX);
//! 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;
......
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