I'm working on a ASE (ASCII Scene Export) file format loader for Irrlicht.
It would be nice to import whole scenes directly from 3DSMax.
Unfortunately I can only get the debug boundingboxes to show up. Not the vertices or the textures. If anyone could help a bit with this it would be great!
This is the code that should do it:
Code: Select all
CASELoader::CASELoader(irr::scene::ISceneManager *smgr, char *filename)
{
ASE_Scene *scene = ASE_loadFilename(filename);
if(!scene){
trace("ERROR loading ase file\n");
return;
}
irr::video::IVideoDriver *driver = smgr->getVideoDriver();
for(int i=0;i<scene->objectCount;i++)
{
ASE_GeomObject obj = scene->objs[i];
ASE_Material mat = scene->materials[i];
scene::SMesh *mesh = new scene::SMesh();
scene::SMeshBuffer *mb = new scene::SMeshBuffer();
for(int j=0;j<obj.mesh.vertexCount;j++)
{
ASE_Vector3D asevec3d = obj.mesh.vertices[j];
ASE_Vector3D asenormal3d = obj.mesh.vertex_normals[j];
core::vector3df asevec(asevec3d.x,asevec3d.y,asevec3d.z);
core::vector3df normal(asenormal3d.x,asenormal3d.y,asenormal3d.z);
irr::video::S3DVertex s3dvertext(asevec, normal,
video::SColor(255,255,255,255), core::vector2df(1.0f,1.0f));
mb->Vertices.push_back(s3dvertext);
}
mb->recalculateBoundingBox();
mb->Material.DiffuseColor.set(255,s32(mat.diffuse.r*255.0f),s32(mat.diffuse.g*255.0f),s32(mat.diffuse.b*255.0f));
mb->Material.AmbientColor.set(255,s32(mat.ambient.r*255.0f),s32(mat.ambient.g*255.0f),s32(mat.ambient.b*255.0f));
mesh->addMeshBuffer(mb);
mesh->recalculateBoundingBox();
scene::ISceneNode *node = smgr->addMeshSceneNode(mesh);
node->setDebugDataVisible(true);
wchar_t objname[100];
swprintf(objname,100,L"%S",obj.name);
node->setName(objname);
node->setRotation(node->getRotation()+core::vector3df(90.0f,0.0f,0.0f));
// node->setScale(core::vector3df(10.0f,10.0f,10.0f));
node->setMaterialTexture(0,driver->getTexture(mat.diffuseMaterialMap.image_path));
node->setVisible(true);
}
}
http://213.189.20.120/~nieka/ASELoader.zip