Added a Mesh to 2TCoords converter.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1010 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
aa9b94b3ca
commit
e7393eddc7
|
@ -93,6 +93,8 @@ namespace scene
|
||||||
See IReferenceCounted::drop() for more information. */
|
See IReferenceCounted::drop() for more information. */
|
||||||
virtual IMesh* createMeshWithTangents(IMesh* mesh) const = 0;
|
virtual IMesh* createMeshWithTangents(IMesh* mesh) const = 0;
|
||||||
|
|
||||||
|
//! Creates a copy of the mesh, which will only consist of S3DVertex2TCoord vertices.
|
||||||
|
virtual IMesh* createMeshWith2TCoords(IMesh* mesh) const = 0;
|
||||||
//! Creates a copy of a mesh with all vertices unwelded
|
//! Creates a copy of a mesh with all vertices unwelded
|
||||||
virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const = 0;
|
virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const = 0;
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,16 @@
|
||||||
|
|
||||||
#include "IrrCompileConfig.h"
|
#include "IrrCompileConfig.h"
|
||||||
#include "aabbox3d.h"
|
#include "aabbox3d.h"
|
||||||
|
#include "coreutil.h"
|
||||||
#include "irrArray.h"
|
#include "irrArray.h"
|
||||||
#include "irrMap.h"
|
#include "irrMap.h"
|
||||||
|
#include "irrMath.h"
|
||||||
|
#include "irrString.h"
|
||||||
|
#include "irrTypes.h"
|
||||||
#include "SColor.h"
|
#include "SColor.h"
|
||||||
#include "SLight.h"
|
#include "SLight.h"
|
||||||
#include "dimension2d.h"
|
#include "dimension2d.h"
|
||||||
#include "EDriverTypes.h"
|
#include "EDriverTypes.h"
|
||||||
#include "heapsort.h"
|
|
||||||
#include "IAttributes.h"
|
#include "IAttributes.h"
|
||||||
#include "IAttributeExchangingObject.h"
|
#include "IAttributeExchangingObject.h"
|
||||||
#include "IAnimatedMesh.h"
|
#include "IAnimatedMesh.h"
|
||||||
|
@ -91,8 +94,6 @@
|
||||||
#include "IMetaTriangleSelector.h"
|
#include "IMetaTriangleSelector.h"
|
||||||
#include "IReadFile.h"
|
#include "IReadFile.h"
|
||||||
#include "IrrlichtDevice.h"
|
#include "IrrlichtDevice.h"
|
||||||
#include "irrMath.h"
|
|
||||||
#include "irrString.h"
|
|
||||||
#include "ISceneManager.h"
|
#include "ISceneManager.h"
|
||||||
#include "ISceneNode.h"
|
#include "ISceneNode.h"
|
||||||
#include "ISceneUserDataSerializer.h"
|
#include "ISceneUserDataSerializer.h"
|
||||||
|
@ -136,8 +137,6 @@
|
||||||
#include "SMeshBufferLightMap.h"
|
#include "SMeshBufferLightMap.h"
|
||||||
#include "SMeshBufferTangents.h"
|
#include "SMeshBufferTangents.h"
|
||||||
#include "SViewFrustum.h"
|
#include "SViewFrustum.h"
|
||||||
#include "irrTypes.h"
|
|
||||||
#include "coreutil.h"
|
|
||||||
|
|
||||||
/*! \mainpage Irrlicht Engine 1.4 API documentation
|
/*! \mainpage Irrlicht Engine 1.4 API documentation
|
||||||
*
|
*
|
||||||
|
|
|
@ -426,9 +426,11 @@ SMesh* CMeshManipulator::createMeshCopy(scene::IMesh* mesh) const
|
||||||
video::S3DVertex* v =
|
video::S3DVertex* v =
|
||||||
(video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices();
|
(video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices();
|
||||||
|
|
||||||
|
buffer->Vertices.reallocate(vtxCnt);
|
||||||
for (i=0; i<vtxCnt; ++i)
|
for (i=0; i<vtxCnt; ++i)
|
||||||
buffer->Vertices.push_back(v[i]);
|
buffer->Vertices.push_back(v[i]);
|
||||||
|
|
||||||
|
buffer->Indices.reallocate(idxCnt);
|
||||||
for (i=0; i<idxCnt; ++i)
|
for (i=0; i<idxCnt; ++i)
|
||||||
buffer->Indices.push_back(idx[i]);
|
buffer->Indices.push_back(idx[i]);
|
||||||
|
|
||||||
|
@ -444,9 +446,11 @@ SMesh* CMeshManipulator::createMeshCopy(scene::IMesh* mesh) const
|
||||||
video::S3DVertex2TCoords* v =
|
video::S3DVertex2TCoords* v =
|
||||||
(video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices();
|
(video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices();
|
||||||
|
|
||||||
|
buffer->Vertices.reallocate(vtxCnt);
|
||||||
for (i=0; i<vtxCnt; ++i)
|
for (i=0; i<vtxCnt; ++i)
|
||||||
buffer->Vertices.push_back(v[i]);
|
buffer->Vertices.push_back(v[i]);
|
||||||
|
|
||||||
|
buffer->Indices.reallocate(idxCnt);
|
||||||
for (i=0; i<idxCnt; ++i)
|
for (i=0; i<idxCnt; ++i)
|
||||||
buffer->Indices.push_back(idx[i]);
|
buffer->Indices.push_back(idx[i]);
|
||||||
|
|
||||||
|
@ -462,9 +466,11 @@ SMesh* CMeshManipulator::createMeshCopy(scene::IMesh* mesh) const
|
||||||
video::S3DVertexTangents* v =
|
video::S3DVertexTangents* v =
|
||||||
(video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices();
|
(video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices();
|
||||||
|
|
||||||
|
buffer->Vertices.reallocate(vtxCnt);
|
||||||
for (i=0; i<vtxCnt; ++i)
|
for (i=0; i<vtxCnt; ++i)
|
||||||
buffer->Vertices.push_back(v[i]);
|
buffer->Vertices.push_back(v[i]);
|
||||||
|
|
||||||
|
buffer->Indices.reallocate(idxCnt);
|
||||||
for (i=0; i<idxCnt; ++i)
|
for (i=0; i<idxCnt; ++i)
|
||||||
buffer->Indices.push_back(idx[i]);
|
buffer->Indices.push_back(idx[i]);
|
||||||
|
|
||||||
|
@ -538,7 +544,7 @@ IMesh* CMeshManipulator::createMeshUniquePrimitives(IMesh* mesh) const
|
||||||
|
|
||||||
for ( u32 b=0; b<meshBufferCount; ++b)
|
for ( u32 b=0; b<meshBufferCount; ++b)
|
||||||
{
|
{
|
||||||
s32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount();
|
const s32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount();
|
||||||
const u16* idx = mesh->getMeshBuffer(b)->getIndices();
|
const u16* idx = mesh->getMeshBuffer(b)->getIndices();
|
||||||
|
|
||||||
switch(mesh->getMeshBuffer(b)->getVertexType())
|
switch(mesh->getMeshBuffer(b)->getVertexType())
|
||||||
|
@ -551,6 +557,8 @@ IMesh* CMeshManipulator::createMeshUniquePrimitives(IMesh* mesh) const
|
||||||
video::S3DVertex* v =
|
video::S3DVertex* v =
|
||||||
(video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices();
|
(video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices();
|
||||||
|
|
||||||
|
buffer->Vertices.reallocate(idxCnt);
|
||||||
|
buffer->Indices.reallocate(idxCnt);
|
||||||
for (s32 i=0; i<idxCnt; i += 3)
|
for (s32 i=0; i<idxCnt; i += 3)
|
||||||
{
|
{
|
||||||
buffer->Vertices.push_back( v[idx[i + 0 ]] );
|
buffer->Vertices.push_back( v[idx[i + 0 ]] );
|
||||||
|
@ -574,6 +582,8 @@ IMesh* CMeshManipulator::createMeshUniquePrimitives(IMesh* mesh) const
|
||||||
video::S3DVertex2TCoords* v =
|
video::S3DVertex2TCoords* v =
|
||||||
(video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices();
|
(video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices();
|
||||||
|
|
||||||
|
buffer->Vertices.reallocate(idxCnt);
|
||||||
|
buffer->Indices.reallocate(idxCnt);
|
||||||
for (s32 i=0; i<idxCnt; i += 3)
|
for (s32 i=0; i<idxCnt; i += 3)
|
||||||
{
|
{
|
||||||
buffer->Vertices.push_back( v[idx[i + 0 ]] );
|
buffer->Vertices.push_back( v[idx[i + 0 ]] );
|
||||||
|
@ -596,6 +606,8 @@ IMesh* CMeshManipulator::createMeshUniquePrimitives(IMesh* mesh) const
|
||||||
video::S3DVertexTangents* v =
|
video::S3DVertexTangents* v =
|
||||||
(video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices();
|
(video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices();
|
||||||
|
|
||||||
|
buffer->Vertices.reallocate(idxCnt);
|
||||||
|
buffer->Indices.reallocate(idxCnt);
|
||||||
for (s32 i=0; i<idxCnt; i += 3)
|
for (s32 i=0; i<idxCnt; i += 3)
|
||||||
{
|
{
|
||||||
buffer->Vertices.push_back( v[idx[i + 0 ]] );
|
buffer->Vertices.push_back( v[idx[i + 0 ]] );
|
||||||
|
@ -800,7 +812,7 @@ IMesh* CMeshManipulator::createMeshWithTangents(IMesh* mesh) const
|
||||||
|
|
||||||
for (b=0; b<meshBufferCount; ++b)
|
for (b=0; b<meshBufferCount; ++b)
|
||||||
{
|
{
|
||||||
s32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount();
|
const s32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount();
|
||||||
const u16* idx = mesh->getMeshBuffer(b)->getIndices();
|
const u16* idx = mesh->getMeshBuffer(b)->getIndices();
|
||||||
|
|
||||||
SMeshBufferTangents* buffer = new SMeshBufferTangents();
|
SMeshBufferTangents* buffer = new SMeshBufferTangents();
|
||||||
|
@ -808,6 +820,7 @@ IMesh* CMeshManipulator::createMeshWithTangents(IMesh* mesh) const
|
||||||
|
|
||||||
// copy vertices
|
// copy vertices
|
||||||
|
|
||||||
|
buffer->Vertices.reallocate(idxCnt);
|
||||||
switch(mesh->getMeshBuffer(b)->getVertexType())
|
switch(mesh->getMeshBuffer(b)->getVertexType())
|
||||||
{
|
{
|
||||||
case video::EVT_STANDARD:
|
case video::EVT_STANDARD:
|
||||||
|
@ -858,7 +871,7 @@ IMesh* CMeshManipulator::createMeshWithTangents(IMesh* mesh) const
|
||||||
// now calculate tangents
|
// now calculate tangents
|
||||||
for (b=0; b<meshBufferCount; ++b)
|
for (b=0; b<meshBufferCount; ++b)
|
||||||
{
|
{
|
||||||
s32 idxCnt = clone->getMeshBuffer(b)->getIndexCount();
|
const s32 idxCnt = clone->getMeshBuffer(b)->getIndexCount();
|
||||||
|
|
||||||
u16* idx = clone->getMeshBuffer(b)->getIndices();
|
u16* idx = clone->getMeshBuffer(b)->getIndices();
|
||||||
video::S3DVertexTangents* v =
|
video::S3DVertexTangents* v =
|
||||||
|
@ -906,6 +919,81 @@ IMesh* CMeshManipulator::createMeshWithTangents(IMesh* mesh) const
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//! Creates a copy of the mesh, which will only consist of S3DVertex2TCoords vertices.
|
||||||
|
IMesh* CMeshManipulator::createMeshWith2TCoords(IMesh* mesh) const
|
||||||
|
{
|
||||||
|
if (!mesh)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// copy mesh and fill data into SMeshBufferLightMap
|
||||||
|
|
||||||
|
SMesh* clone = new SMesh();
|
||||||
|
const u32 meshBufferCount = mesh->getMeshBufferCount();
|
||||||
|
u32 b;
|
||||||
|
|
||||||
|
for (b=0; b<meshBufferCount; ++b)
|
||||||
|
{
|
||||||
|
const s32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount();
|
||||||
|
const u16* idx = mesh->getMeshBuffer(b)->getIndices();
|
||||||
|
|
||||||
|
SMeshBufferLightMap* buffer = new SMeshBufferLightMap();
|
||||||
|
buffer->Material = mesh->getMeshBuffer(b)->getMaterial();
|
||||||
|
|
||||||
|
// copy vertices
|
||||||
|
|
||||||
|
buffer->Vertices.reallocate(idxCnt);
|
||||||
|
switch(mesh->getMeshBuffer(b)->getVertexType())
|
||||||
|
{
|
||||||
|
case video::EVT_STANDARD:
|
||||||
|
{
|
||||||
|
video::S3DVertex* v =
|
||||||
|
(video::S3DVertex*)mesh->getMeshBuffer(b)->getVertices();
|
||||||
|
|
||||||
|
for (s32 i=0; i<idxCnt; ++i)
|
||||||
|
buffer->Vertices.push_back(
|
||||||
|
video::S3DVertex2TCoords(
|
||||||
|
v[idx[i]].Pos, v[idx[i]].Color, v[idx[i]].TCoords, v[idx[i]].TCoords));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case video::EVT_2TCOORDS:
|
||||||
|
{
|
||||||
|
video::S3DVertex2TCoords* v =
|
||||||
|
(video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices();
|
||||||
|
|
||||||
|
for (s32 i=0; i<idxCnt; ++i)
|
||||||
|
buffer->Vertices.push_back(v[idx[i]]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case video::EVT_TANGENTS:
|
||||||
|
{
|
||||||
|
video::S3DVertexTangents* v =
|
||||||
|
(video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices();
|
||||||
|
|
||||||
|
for (s32 i=0; i<idxCnt; ++i)
|
||||||
|
buffer->Vertices.push_back(video::S3DVertex2TCoords(
|
||||||
|
v[idx[i]].Pos, v[idx[i]].Color, v[idx[i]].TCoords, v[idx[i]].TCoords));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create new indices
|
||||||
|
|
||||||
|
buffer->Indices.set_used(idxCnt);
|
||||||
|
for (s32 i=0; i<idxCnt; ++i)
|
||||||
|
buffer->Indices[i] = i;
|
||||||
|
|
||||||
|
// add new buffer
|
||||||
|
clone->addMeshBuffer(buffer);
|
||||||
|
buffer->drop();
|
||||||
|
}
|
||||||
|
|
||||||
|
clone->BoundingBox = mesh->getBoundingBox();
|
||||||
|
|
||||||
|
return clone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CMeshManipulator::calculateTangents(
|
void CMeshManipulator::calculateTangents(
|
||||||
core::vector3df& normal,
|
core::vector3df& normal,
|
||||||
core::vector3df& tangent,
|
core::vector3df& tangent,
|
||||||
|
|
|
@ -75,6 +75,7 @@ public:
|
||||||
//! If you no longer need the cloned mesh, you should call IMesh::drop().
|
//! If you no longer need the cloned mesh, you should call IMesh::drop().
|
||||||
//! See IReferenceCounted::drop() for more information.
|
//! See IReferenceCounted::drop() for more information.
|
||||||
virtual IMesh* createMeshWithTangents(IMesh* mesh) const;
|
virtual IMesh* createMeshWithTangents(IMesh* mesh) const;
|
||||||
|
virtual IMesh* createMeshWith2TCoords(IMesh* mesh) const;
|
||||||
|
|
||||||
virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const;
|
virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const;
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ staticlib sharedlib : CXXINCS += -I/usr/X11R6/include
|
||||||
|
|
||||||
#Windows specific options
|
#Windows specific options
|
||||||
sharedlib_win32 staticlib_win32: SYSTEM = Win32-gcc
|
sharedlib_win32 staticlib_win32: SYSTEM = Win32-gcc
|
||||||
sharedlib_win32: LDFLAGS = -lgdi32 -lwinspool -lcomdlg32 -lole32 -loleaut32 -luuid -lopengl32 -ld3dx9d -lSDL
|
sharedlib_win32: LDFLAGS = -lgdi32 -lopengl32 -ld3dx9d -lSDL
|
||||||
sharedlib_win32 staticlib_win32: CPPFLAGS += -DIRR_COMPILE_WITH_DX9_DEV_PACK -D__GNUWIN32__ -D_WIN32 -DWIN32 -D_WINDOWS -D_MBCS -D_USRDLL
|
sharedlib_win32 staticlib_win32: CPPFLAGS += -DIRR_COMPILE_WITH_DX9_DEV_PACK -D__GNUWIN32__ -D_WIN32 -DWIN32 -D_WINDOWS -D_MBCS -D_USRDLL
|
||||||
staticlib_win32: CPPFLAGS += -D_IRR_STATIC_LIB_
|
staticlib_win32: CPPFLAGS += -D_IRR_STATIC_LIB_
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue