This commit is contained in:
kaetemi 2014-02-09 22:15:33 +01:00
commit e90c325f1b
5 changed files with 30 additions and 13 deletions

View file

@ -791,17 +791,20 @@ void CMeshMultiLod::compileCoarseMeshes()
{ {
slotRef.CoarseTriangles.resize(slotRef.CoarseNumTris * 3); slotRef.CoarseTriangles.resize(slotRef.CoarseNumTris * 3);
TCoarseMeshIndexType *dstPtr= &slotRef.CoarseTriangles[0]; TCoarseMeshIndexType *dstPtr= &slotRef.CoarseTriangles[0];
uint totalTris = 0;
for(uint i=0;i<meshGeom->getNbRdrPass(0);i++) for(uint i=0;i<meshGeom->getNbRdrPass(0);i++)
{ {
const CIndexBuffer &pb= meshGeom->getRdrPassPrimitiveBlock(0, i); const CIndexBuffer &pb= meshGeom->getRdrPassPrimitiveBlock(0, i);
CIndexBufferRead ibaRead; CIndexBufferRead ibaRead;
pb.lock (ibaRead); pb.lock (ibaRead);
uint numTris= pb.getNumIndexes()/3; uint numTris= pb.getNumIndexes()/3;
totalTris += numTris;
if (pb.getFormat() == CIndexBuffer::Indices16) if (pb.getFormat() == CIndexBuffer::Indices16)
{ {
if (sizeof(TCoarseMeshIndexType) == sizeof(uint16)) if (sizeof(TCoarseMeshIndexType) == sizeof(uint16))
{ {
memcpy(dstPtr, (uint16 *) ibaRead.getPtr(), numTris*3*sizeof(uint16)); memcpy(dstPtr, (uint16 *) ibaRead.getPtr(), numTris*3*sizeof(uint16));
dstPtr+= numTris*3;
} }
else else
{ {
@ -820,6 +823,7 @@ void CMeshMultiLod::compileCoarseMeshes()
if (sizeof(TCoarseMeshIndexType) == sizeof(uint32)) if (sizeof(TCoarseMeshIndexType) == sizeof(uint32))
{ {
memcpy(dstPtr, (uint32 *) ibaRead.getPtr(), numTris*3*sizeof(uint32)); memcpy(dstPtr, (uint32 *) ibaRead.getPtr(), numTris*3*sizeof(uint32));
dstPtr+= numTris*3;
} }
else else
{ {
@ -836,8 +840,8 @@ void CMeshMultiLod::compileCoarseMeshes()
} }
} }
} }
dstPtr+= numTris*3;
} }
nlassert(totalTris == slotRef.CoarseNumTris);
} }
} }
} }

View file

@ -142,7 +142,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
{ {
bool tempBRet = bRet; bool tempBRet = bRet;
bRet = false; bRet = false;
// delete pShape; // FIXME: there is a delete bug with CMeshMultiLod exported from max!!! delete pShape;
bRet = tempBRet; bRet = tempBRet;
} }
catch (...) catch (...)

View file

@ -41,8 +41,10 @@ IShape* CExportNel::buildFlare(INode& node, TimeValue time)
CExportNel::getValueByNameUsingParamBlock2(node, "PersistenceParam", (ParamType2)TYPE_FLOAT, &persistence, 0); CExportNel::getValueByNameUsingParamBlock2(node, "PersistenceParam", (ParamType2)TYPE_FLOAT, &persistence, 0);
fshape->setPersistence(persistence); fshape->setPersistence(persistence);
// retrieve spacing of the flare // retrieve spacing of the flare
CExportNel::getValueByNameUsingParamBlock2(node, "Spacing", (ParamType2)TYPE_FLOAT, &spacing, 0); bool hasSpacing = CExportNel::getValueByNameUsingParamBlock2(node, "Spacing", (ParamType2)TYPE_FLOAT, &spacing, 0)
fshape->setFlareSpacing(spacing); || CExportNel::getValueByNameUsingParamBlock2(node, "spacing", (ParamType2)TYPE_FLOAT, &spacing, 0);
if (hasSpacing) fshape->setFlareSpacing(spacing);
else nlwarning("FAILED CFlareShape Spacing");
// retrieve use of radial attenuation // retrieve use of radial attenuation
CExportNel::getValueByNameUsingParamBlock2(node, "Attenuable", (ParamType2) TYPE_BOOL, &attenuable, 0); CExportNel::getValueByNameUsingParamBlock2(node, "Attenuable", (ParamType2) TYPE_BOOL, &attenuable, 0);
if (attenuable) if (attenuable)

View file

@ -17,6 +17,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "export_nel.h" #include "export_nel.h"
#include "../tile_utility/tile_utility.h" #include "../tile_utility/tile_utility.h"
#include "nel/misc/path.h"
#include "nel/3d/texture_file.h" #include "nel/3d/texture_file.h"
#include "nel/3d/texture_multi_file.h" #include "nel/3d/texture_multi_file.h"
#include "nel/3d/texture_cube.h" #include "nel/3d/texture_cube.h"
@ -1139,9 +1140,9 @@ int CExportNel::getVertMapChannel (Texmap& texmap, Matrix3& channelMatrix, TimeV
} }
// get the absolute or relative path from a texture filename // get the absolute or relative path from a texture filename
static std::string ConvertTexFileName(const char *src, bool _AbsolutePath) static std::string ConvertTexFileName(const std::string &path, bool _AbsolutePath)
{ {
// File name, maxlen 256 under windows /*// File name, maxlen 256 under windows
char sFileName[512]; char sFileName[512];
strcpy (sFileName, src); strcpy (sFileName, src);
@ -1156,7 +1157,15 @@ static std::string ConvertTexFileName(const char *src, bool _AbsolutePath)
// Make the final path // Make the final path
_makepath (sFileName, NULL, NULL, sName, sExt); _makepath (sFileName, NULL, NULL, sName, sExt);
} }
return std::string(sFileName); return std::string(sFileName);*/
if (_AbsolutePath)
{
return path;
}
else
{
return NLMISC::CFile::getFilename(path);
}
} }
// Build a NeL texture corresponding with a max Texmap. // Build a NeL texture corresponding with a max Texmap.
@ -1243,7 +1252,7 @@ ITexture* CExportNel::buildATexture (Texmap& texmap, CMaterialDesc &remap3dsTexC
if (l == 1 && !fileName[0].empty()) if (l == 1 && !fileName[0].empty())
{ {
srcTex = new CTextureFile; srcTex = new CTextureFile;
static_cast<CTextureFile *>(srcTex)->setFileName (ConvertTexFileName(fileName[0].c_str(), _AbsolutePath)); static_cast<CTextureFile *>(srcTex)->setFileName (ConvertTexFileName(fileName[0], _AbsolutePath));
} }
else else
{ {
@ -1253,7 +1262,8 @@ ITexture* CExportNel::buildATexture (Texmap& texmap, CMaterialDesc &remap3dsTexC
if (!fileName[k].empty()) if (!fileName[k].empty())
{ {
/// set the name of the texture after converting it /// set the name of the texture after converting it
static_cast<CTextureMultiFile *>(srcTex)->setFileName(k, ConvertTexFileName(fileName[k].c_str(), _AbsolutePath).c_str()); std::string convertMultiTex = ConvertTexFileName(fileName[k], _AbsolutePath);
static_cast<CTextureMultiFile *>(srcTex)->setFileName(k, convertMultiTex.c_str());
} }
} }
} }
@ -1261,7 +1271,8 @@ ITexture* CExportNel::buildATexture (Texmap& texmap, CMaterialDesc &remap3dsTexC
else // standard texture else // standard texture
{ {
srcTex = new CTextureFile; srcTex = new CTextureFile;
static_cast<CTextureFile *>(srcTex)->setFileName (ConvertTexFileName(pBitmap->GetMapName(), _AbsolutePath)); std::string mapName = pBitmap->GetMapName();
static_cast<CTextureFile *>(srcTex)->setFileName (ConvertTexFileName(mapName, _AbsolutePath));
} }
// 2) Use this texture 'as it', or duplicate it to create the faces of a cube map // 2) Use this texture 'as it', or duplicate it to create the faces of a cube map
@ -1361,7 +1372,7 @@ NL3D::CTextureCube *CExportNel::buildTextureCubeFromReflectRefract(Texmap &texma
CTextureFile *pT = new CTextureFile(); CTextureFile *pT = new CTextureFile();
// Set the file name // Set the file name
pT->setFileName(ConvertTexFileName(names[i].c_str(), _AbsolutePath)); pT->setFileName(ConvertTexFileName(names[i], _AbsolutePath));
// Set the texture // Set the texture
pTextureCube->setTexture(tfNewOrder[i], pT); pTextureCube->setTexture(tfNewOrder[i], pT);

View file

@ -409,7 +409,7 @@ bool getValueByNameUsingParamBlock2Internal (Animatable& node, const char* sName
} }
else else
{ {
nldebug("Invalid type specified for pblock2 value with name '%s', given type '%u', found '%u'", nlwarning("Invalid type specified for pblock2 value with name '%s', given type '%u', found '%u'",
sName, (uint32)type, (uint32)paramType); sName, (uint32)type, (uint32)paramType);
} }
} }
@ -448,7 +448,7 @@ bool CExportNel::getValueByNameUsingParamBlock2 (Animatable& node, const char* s
} }
else else
{ {
// nlwarning ("Can't found ParamBlock named %s", sName); nlwarning ("FAILED Can't find ParamBlock named '%s'", sName);
return false; return false;
} }
} }