Changed addArrowMesh parameter order. Changed OBJ loader to use stringc instead of dynamically allocated char array.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@766 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2007-07-07 20:08:47 +00:00
parent 1406fa59b8
commit ef4443353b
9 changed files with 53 additions and 60 deletions

View File

@ -1,5 +1,10 @@
Changes in version 1.4 (... 2007)
- Changed parameter order of addArrowMesh and added default parameters such
that it's enough to set the color (or even just the name).
- Fixed bugs in MY3D and OBJ loader.
- Added IMeshCache::clearUnusedMeshes(). This allows the user to remove
meshes that are sitting in the mesh cache but aren't used by any scene nodes.
This is useful for example when changing levels.

View File

@ -497,7 +497,7 @@ namespace scene
camera = sceneManager->addCameraSceneNodeFPS(0, 100, 500, -1, keyMap, 8);
\endcode
\param parent: Parent scene node of the camera. Can be null.
\param rotateSpeed: Speed with wich the camera is rotated. This can be done
\param rotateSpeed: Speed with which the camera is rotated. This can be done
only with the mouse.
\param moveSpeed: Speed with which the camera is moved. Movement is done with
the cursor keys.
@ -753,7 +753,7 @@ namespace scene
good value to start, for example.
\param tileCount: Specifies how much tiles there will be. If you specifiy
for example that a tile has the size (10.0f, 10.0f) and the tileCount is
(10,10), than you get a field of 100 tiles wich has the dimension 100.0fx100.0f.
(10,10), than you get a field of 100 tiles which has the dimension 100.0fx100.0f.
\param material: Material of the hill mesh.
\param hillHeight: Height of the hills. If you specify a negative value
you will get holes instead of hills. If the height is 0, no hills will be
@ -803,14 +803,15 @@ namespace scene
const core::dimension2d<s32>& defaultVertexBlockSize = core::dimension2d<s32>(64,64)) = 0;
//! add a static arrow mesh to the meshpool
/** it quite usefull for debuggin purposes. ( showing directions eq )
*/
virtual IAnimatedMesh* addArrowMesh(const c8* name, u32 tesselationCylinder, u32 tesselationCone, f32 height,
f32 cylinderHeight, f32 width0,f32 width1,
video::SColor vtxColor0, video::SColor vtxColor1) = 0;
virtual IAnimatedMesh* addArrowMesh(const c8* name,
video::SColor vtxColor0=0xFFFFFFFF,
video::SColor vtxColor1=0xFFFFFFFF,
u32 tesselationCylinder=4, u32 tesselationCone=8,
f32 height=1.f, f32 cylinderHeight=0.6f,
f32 width0=0.05f, f32 width1=0.3f) = 0;
//! Returns the root scene node.
/** This is the scene node wich is parent
/** This is the scene node which is parent
of all scene nodes. The root scene node is a special scene node which
only exists to manage all scene nodes. It will not be rendered and cannot
be removed from the scene.

View File

@ -303,9 +303,12 @@ void CAnimatedMeshSceneNode::render()
// show tag for quake3 models
if (Mesh->getMeshType() == EAMT_MD3 )
{
IAnimatedMesh * arrow = SceneManager->addArrowMesh ( "__tag_show",
4, 8, 5.f, 4.f, 0.5f, 1.f, 0xFF0000FF, 0xFF000088
);
IAnimatedMesh * arrow =
SceneManager->addArrowMesh (
"__tag_show",
0xFF0000FF, 0xFF000088,
4, 8, 5.f, 4.f, 0.5f,
1.f);
if ( 0 == arrow )
{
arrow = SceneManager->getMesh ( "__tag_show" );
@ -341,9 +344,10 @@ void CAnimatedMeshSceneNode::render()
// show normals
if ( DebugDataVisible & scene::EDS_NORMALS )
{
IAnimatedMesh * arrow = SceneManager->addArrowMesh ( "__debugnormal",
4, 8, 1.f, 0.6f, 0.05f, 0.3f, 0xFFECEC00, 0xFF999900
);
IAnimatedMesh * arrow = SceneManager->addArrowMesh (
"__debugnormal", 0xFFECEC00,
0xFF999900, 4, 8, 1.f, 0.6f, 0.05f,
0.3f);
if ( 0 == arrow )
{
arrow = SceneManager->getMesh ( "__debugnormal" );

View File

@ -32,21 +32,16 @@ public:
const core::dimension2d<f32>& textureRepeatCount);
static IAnimatedMesh* createTerrainMesh(video::IImage* texture,
video::IImage* heightmap, const core::dimension2d<f32>& stretchSize, f32 maxHeight,
video::IVideoDriver* driver,
video::IImage* heightmap, const core::dimension2d<f32>& stretchSize,
f32 maxHeight, video::IVideoDriver* driver,
const core::dimension2d<s32> defaultVertexBlockSize,
bool debugBorders=false);
static IAnimatedMesh* createArrowMesh ( const u32 tesselationCylinder,
const u32 tesselationCone,
const f32 height,
const f32 cylinderHeight,
const f32 width0,
const f32 width1,
const video::SColor vtxColor0,
const video::SColor vtxColor1
);
static IAnimatedMesh* createArrowMesh(const u32 tesselationCylinder,
const u32 tesselationCone, const f32 height,
const f32 cylinderHeight, const f32 width0,
const f32 width1, const video::SColor vtxColor0,
const video::SColor vtxColor1);
};

View File

@ -339,7 +339,7 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
me.Texture2FileName.append("Lightmaps/");
me.Texture2FileName.append(Name);
if (Name.size()>0)
if (Name.size())
me.Texture2 = Driver->getTexture(me.Texture2FileName.c_str());
me.MaterialType = video::EMT_LIGHTMAP_M2;
@ -431,7 +431,7 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
s32 vertsNum=0;
s32 facesNum=0;
// verticies
// vertices
file->read(&id, sizeof(id));
if (id!=MY_VERTS_ID)
{

View File

@ -174,8 +174,6 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
case 'f': // face
{
const u32 FACE_BUFFER_LENGTH = 1024;
c8* wordBuffer = new c8[FACE_BUFFER_LENGTH];
c8 vertexWord[WORD_BUFFER_LENGTH]; // for retrieving vertex data
video::S3DVertex v;
u32 currentVertexCount = pCurrMtl->pMeshbuffer->Vertices.size();
@ -186,9 +184,9 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
v.Color = pCurrMtl->pMeshbuffer->Material.DiffuseColor;
// get all vertices data in this face (current line of obj file)
u32 length = copyLine(&wordBuffer, pBufPtr, FACE_BUFFER_LENGTH, pBufEnd);
const c8* pLinePtr = wordBuffer;
const c8* const pEndPtr = wordBuffer+length;
const core::stringc wordBuffer = copyLine(pBufPtr, pBufEnd);
const c8* pLinePtr = wordBuffer.c_str();
const c8* const pEndPtr = pLinePtr+wordBuffer.size();
// read in all vertices
pLinePtr = goNextWord(pLinePtr, pEndPtr);
@ -234,7 +232,6 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
pCurrMtl->pMeshbuffer->Indices.push_back( ( facePointCount - 2 - i ) + currentVertexCount );
pCurrMtl->pMeshbuffer->Indices.push_back( ( facePointCount - 3 - i ) + currentVertexCount );
}
delete wordBuffer;
}
break;
@ -699,33 +696,19 @@ u32 COBJMeshFileLoader::copyWord(c8* outBuf, const c8* const inBuf, u32 outBufLe
}
u32 COBJMeshFileLoader::copyLine(c8** outBuf, const c8* inBuf, u32 outBufLength, const c8* pBufEnd)
core::stringc COBJMeshFileLoader::copyLine(const c8* inBuf, const c8* pBufEnd)
{
if (!outBufLength)
return 0;
if (!inBuf)
{
*outBuf = 0;
return 0;
}
return core::stringc();
u32 i = 0;
while(inBuf[i])
const c8* ptr = inBuf;
while (ptr<pBufEnd)
{
if (inBuf[i]=='\n' || inBuf[i]=='\r' || &(inBuf[i]) == pBufEnd)
if (*ptr=='\n' || *ptr=='\r')
break;
++i;
++ptr;
}
if (i>outBufLength-1)
{
delete [] *outBuf;
*outBuf = new c8[i+1];
}
memcpy(outBuf, inBuf, i);
outBuf[i] = 0;
return i;
return core::stringc(inBuf, ptr-inBuf+1);
}

View File

@ -76,7 +76,7 @@ private:
// copies the current word from the inBuf to the outBuf
u32 copyWord(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd);
// copies the current line from the inBuf to the outBuf
u32 copyLine(c8** outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd);
core::stringc copyLine(const c8* inBuf, const c8* const pBufEnd);
// combination of goNextWord followed by copyWord
const c8* goAndCopyNextWord(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd);

View File

@ -723,7 +723,10 @@ IAnimatedMesh* CSceneManager::addTerrainMesh(const c8* name,
}
//! Adds an arrow mesh to the mesh pool.
IAnimatedMesh* CSceneManager::addArrowMesh(const c8* name,u32 tesselationCylinder, u32 tesselationCone, f32 height, f32 cylinderHeight, f32 width0,f32 width1, video::SColor vtxColor0, video::SColor vtxColor1)
IAnimatedMesh* CSceneManager::addArrowMesh(const c8* name,
video::SColor vtxColor0, video::SColor vtxColor1,
u32 tesselationCylinder, u32 tesselationCone, f32 height,
f32 cylinderHeight, f32 width0,f32 width1)
{
if (!name || MeshCache->isMeshLoaded(name))

View File

@ -193,9 +193,11 @@ namespace scene
f32 maxHeight, const core::dimension2d<s32>& defaultVertexBlockSize);
//! Add a arrow mesh to the mesh pool
virtual IAnimatedMesh* addArrowMesh(const c8* name, u32 tesselationCylinder, u32 tesselationCone, f32 height,
f32 cylinderHeight, f32 width0,f32 width1,
video::SColor vtxColor0, video::SColor vtxColor1);
virtual IAnimatedMesh* addArrowMesh(const c8* name,
video::SColor vtxColor0, video::SColor vtxColor1,
u32 tesselationCylinder, u32 tesselationCone,
f32 height, f32 cylinderHeight, f32 width0,
f32 width1);
//! Adds a particle system scene node.
virtual IParticleSystemSceneNode* addParticleSystemSceneNode(