+ else if(m_prop.visual == "upright_sprite") {
+ scene::SMesh *mesh = new scene::SMesh();
+ double dx = BS*m_prop.visual_size.X/2;
+ double dy = BS*m_prop.visual_size.Y/2;
+ { // Front
+ scene::IMeshBuffer *buf = new scene::SMeshBuffer();
+ u8 li = m_last_light;
+ video::SColor c(255,li,li,li);
+ video::S3DVertex vertices[4] =
+ {
+ video::S3DVertex(-dx,-dy,0, 0,0,0, c, 0,1),
+ video::S3DVertex(dx,-dy,0, 0,0,0, c, 1,1),
+ video::S3DVertex(dx,dy,0, 0,0,0, c, 1,0),
+ video::S3DVertex(-dx,dy,0, 0,0,0, c, 0,0),
+ };
+ u16 indices[] = {0,1,2,2,3,0};
+ buf->append(vertices, 4, indices, 6);
+ // Set material
+ buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
+ buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
+ buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
+ buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
+ // Add to mesh
+ mesh->addMeshBuffer(buf);
+ buf->drop();
+ }
+ { // Back
+ scene::IMeshBuffer *buf = new scene::SMeshBuffer();
+ u8 li = m_last_light;
+ video::SColor c(255,li,li,li);
+ video::S3DVertex vertices[4] =
+ {
+ video::S3DVertex(dx,-dy,0, 0,0,0, c, 1,1),
+ video::S3DVertex(-dx,-dy,0, 0,0,0, c, 0,1),
+ video::S3DVertex(-dx,dy,0, 0,0,0, c, 0,0),
+ video::S3DVertex(dx,dy,0, 0,0,0, c, 1,0),
+ };
+ u16 indices[] = {0,1,2,2,3,0};
+ buf->append(vertices, 4, indices, 6);
+ // Set material
+ buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
+ buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
+ buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
+ buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+ // Add to mesh
+ mesh->addMeshBuffer(buf);
+ buf->drop();
+ }
+ m_meshnode = smgr->addMeshSceneNode(mesh, NULL);
+ m_meshnode->grab();
+ mesh->drop();
+ // Set it to use the materials of the meshbuffers directly.
+ // This is needed for changing the texture in the future
+ m_meshnode->setReadOnlyMaterials(true);
+ }
+ else if(m_prop.visual == "cube") {
+ infostream<<"GenericCAO::addToScene(): cube"<<std::endl;
+ scene::IMesh *mesh = createCubeMesh(v3f(BS,BS,BS));
+ m_meshnode = smgr->addMeshSceneNode(mesh, NULL);
+ m_meshnode->grab();
+ mesh->drop();
+
+ m_meshnode->setScale(v3f(m_prop.visual_size.X,
+ m_prop.visual_size.Y,
+ m_prop.visual_size.X));
+ u8 li = m_last_light;
+ setMeshColor(m_meshnode->getMesh(), video::SColor(255,li,li,li));
+
+ m_meshnode->setMaterialFlag(video::EMF_LIGHTING, false);
+ m_meshnode->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
+ m_meshnode->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
+ m_meshnode->setMaterialFlag(video::EMF_FOG_ENABLE, true);
+ }
+ else if(m_prop.visual == "mesh") {
+ infostream<<"GenericCAO::addToScene(): mesh"<<std::endl;
+ scene::IAnimatedMesh *mesh = m_gamedef->getMesh(m_prop.mesh);
+ if(mesh)
+ {
+ m_animated_meshnode = smgr->addAnimatedMeshSceneNode(mesh, NULL);
+ m_animated_meshnode->grab();
+ mesh->drop(); // The scene node took hold of it
+ m_animated_meshnode->animateJoints(); // Needed for some animations
+ m_animated_meshnode->setScale(v3f(m_prop.visual_size.X,
+ m_prop.visual_size.Y,
+ m_prop.visual_size.X));
+ u8 li = m_last_light;
+ setMeshColor(m_animated_meshnode->getMesh(), video::SColor(255,li,li,li));