forked from oerkki/voxelands
new mesh loader
This commit is contained in:
parent
b99887d2e9
commit
77879fb18c
|
@ -364,27 +364,33 @@ void RatCAO::addToScene(scene::ISceneManager *smgr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
video::IVideoDriver* driver = smgr->getVideoDriver();
|
video::IVideoDriver* driver = smgr->getVideoDriver();
|
||||||
scene::IAnimatedMesh* mesh = smgr->getMesh(getModelPath("rat.x").c_str());
|
scene::IAnimatedMesh* mesh = createModelMesh(smgr,"rat.x",true);
|
||||||
if (!mesh)
|
if (!mesh)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_node = smgr->addAnimatedMeshSceneNode(mesh);
|
m_node = smgr->addAnimatedMeshSceneNode(mesh);
|
||||||
// m_node = m_node->clone(); // this will be fixed in later irrlicht versions, but for now our mobs flash
|
|
||||||
|
|
||||||
if (m_node) {
|
if (m_node) {
|
||||||
m_node->setFrameLoop(0,79);
|
m_node->setFrameLoop(0,79);
|
||||||
m_node->setScale(v3f(1.0,1.0,1.0));
|
m_node->setScale(v3f(1.0,1.0,1.0));
|
||||||
setMeshColor(m_node->getMesh(), video::SColor(255,255,255,255));
|
setMeshColor(m_node->getMesh(), video::SColor(255,255,255,255));
|
||||||
|
|
||||||
|
bool use_trilinear_filter = g_settings->getBool("trilinear_filter");
|
||||||
|
bool use_bilinear_filter = g_settings->getBool("bilinear_filter");
|
||||||
|
bool use_anisotropic_filter = g_settings->getBool("anisotropic_filter");
|
||||||
|
|
||||||
// Set material flags and texture
|
// Set material flags and texture
|
||||||
m_node->setMaterialTexture( 0, driver->getTexture(getTexturePath("rat_mob.png").c_str()));
|
m_node->setMaterialTexture( 0, driver->getTexture(getTexturePath("rat_mob.png").c_str()));
|
||||||
video::SMaterial& material = m_node->getMaterial(0);
|
video::SMaterial& material = m_node->getMaterial(0);
|
||||||
material.setFlag(video::EMF_LIGHTING, false);
|
material.setFlag(video::EMF_LIGHTING, false);
|
||||||
material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
material.setFlag(video::EMF_TRILINEAR_FILTER, use_trilinear_filter);
|
||||||
|
material.setFlag(video::EMF_BILINEAR_FILTER, use_bilinear_filter);
|
||||||
|
material.setFlag(video::EMF_ANISOTROPIC_FILTER, use_anisotropic_filter);
|
||||||
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||||
|
|
||||||
m_node->setPosition(v3f(0,0,0));
|
m_node->setPosition(v3f(0,0,0));
|
||||||
}
|
}
|
||||||
|
mesh->drop();
|
||||||
|
|
||||||
updateNodePos();
|
updateNodePos();
|
||||||
}
|
}
|
||||||
|
@ -403,10 +409,9 @@ void RatCAO::updateLight(u8 light_at_pos)
|
||||||
if(m_node == NULL)
|
if(m_node == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// disabled due to the clone bug, this will at least stop flashing
|
u8 li = decode_light(light_at_pos);
|
||||||
//u8 li = decode_light(light_at_pos);
|
video::SColor color(255,li,li,li);
|
||||||
//video::SColor color(255,li,li,li);
|
setMeshVerticesColor(m_node->getMesh(), color);
|
||||||
//setMeshVerticesColor(m_node->getMesh(), color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v3s16 RatCAO::getLightPosition()
|
v3s16 RatCAO::getLightPosition()
|
||||||
|
@ -505,27 +510,32 @@ void Oerkki1CAO::addToScene(scene::ISceneManager *smgr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
video::IVideoDriver* driver = smgr->getVideoDriver();
|
video::IVideoDriver* driver = smgr->getVideoDriver();
|
||||||
scene::IAnimatedMesh* mesh = smgr->getMesh(getModelPath("oerkki.x").c_str());
|
scene::IAnimatedMesh* mesh = createModelMesh(smgr,"oerkki.x",true);
|
||||||
if (!mesh)
|
if (!mesh)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_node = smgr->addAnimatedMeshSceneNode(mesh);
|
m_node = smgr->addAnimatedMeshSceneNode(mesh);
|
||||||
// m_node = m_node->clone(); // this will be fixed in later irrlicht versions, but for now our mobs flash
|
|
||||||
|
|
||||||
if (m_node) {
|
if (m_node) {
|
||||||
m_node->setFrameLoop(24,36);
|
m_node->setFrameLoop(24,36);
|
||||||
m_node->setScale(v3f(5.0,5.0,5.0));
|
m_node->setScale(v3f(5.0,5.0,5.0));
|
||||||
setMeshColor(m_node->getMesh(), video::SColor(255,255,255,255));
|
setMeshColor(m_node->getMesh(), video::SColor(255,255,255,255));
|
||||||
|
bool use_trilinear_filter = g_settings->getBool("trilinear_filter");
|
||||||
|
bool use_bilinear_filter = g_settings->getBool("bilinear_filter");
|
||||||
|
bool use_anisotropic_filter = g_settings->getBool("anisotropic_filter");
|
||||||
|
|
||||||
// Set material flags and texture
|
// Set material flags and texture
|
||||||
m_node->setMaterialTexture( 0, driver->getTexture(getTexturePath("oerkki.png").c_str()));
|
m_node->setMaterialTexture( 0, driver->getTexture(getTexturePath("oerkki.png").c_str()));
|
||||||
video::SMaterial& material = m_node->getMaterial(0);
|
video::SMaterial& material = m_node->getMaterial(0);
|
||||||
material.setFlag(video::EMF_LIGHTING, false);
|
material.setFlag(video::EMF_LIGHTING, false);
|
||||||
material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
material.setFlag(video::EMF_TRILINEAR_FILTER, use_trilinear_filter);
|
||||||
|
material.setFlag(video::EMF_BILINEAR_FILTER, use_bilinear_filter);
|
||||||
|
material.setFlag(video::EMF_ANISOTROPIC_FILTER, use_anisotropic_filter);
|
||||||
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||||
|
|
||||||
m_node->setPosition(v3f(0,0,0));
|
m_node->setPosition(v3f(0,0,0));
|
||||||
}
|
}
|
||||||
|
mesh->drop();
|
||||||
updateNodePos();
|
updateNodePos();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,10 +561,9 @@ void Oerkki1CAO::updateLight(u8 light_at_pos)
|
||||||
|
|
||||||
m_node->setVisible(true);
|
m_node->setVisible(true);
|
||||||
|
|
||||||
// disabled due to the clone bug, this will at least stop flashing
|
u8 li = decode_light(light_at_pos);
|
||||||
//u8 li = decode_light(light_at_pos);
|
video::SColor color(255,li,li,li);
|
||||||
//video::SColor color(255,li,li,li);
|
setMeshVerticesColor(m_node->getMesh(), color);
|
||||||
//setMeshVerticesColor(m_node->getMesh(), color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v3s16 Oerkki1CAO::getLightPosition()
|
v3s16 Oerkki1CAO::getLightPosition()
|
||||||
|
@ -567,7 +576,6 @@ void Oerkki1CAO::updateNodePos()
|
||||||
if(m_node == NULL)
|
if(m_node == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//m_node->setPosition(m_position);
|
|
||||||
m_node->setPosition(pos_translator.vect_show);
|
m_node->setPosition(pos_translator.vect_show);
|
||||||
|
|
||||||
v3f rot = m_node->getRotation();
|
v3f rot = m_node->getRotation();
|
||||||
|
@ -766,7 +774,6 @@ void FireflyCAO::updateNodePos()
|
||||||
if(m_node == NULL)
|
if(m_node == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//m_node->setPosition(m_position);
|
|
||||||
m_node->setPosition(pos_translator.vect_show);
|
m_node->setPosition(pos_translator.vect_show);
|
||||||
|
|
||||||
v3f rot = m_node->getRotation();
|
v3f rot = m_node->getRotation();
|
||||||
|
|
|
@ -130,7 +130,7 @@ scene::IAnimatedMesh* createModelMesh(scene::ISceneManager* smgr, std::string mo
|
||||||
for (u32 i=0; i<lc; i++) {
|
for (u32 i=0; i<lc; i++) {
|
||||||
loader = smgr->getMeshLoader(i);
|
loader = smgr->getMeshLoader(i);
|
||||||
file->seek(0);
|
file->seek(0);
|
||||||
if (loader->isALoadableFileExtension("character.b3d")) {
|
if (loader->isALoadableFileExtension(model.c_str())) {
|
||||||
mesh = loader->createMesh(file);
|
mesh = loader->createMesh(file);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,7 +222,6 @@ RemotePlayer::RemotePlayer(
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_node = mgr->addAnimatedMeshSceneNode(mesh,this);
|
m_node = mgr->addAnimatedMeshSceneNode(mesh,this);
|
||||||
// m_node = m_node->clone(); // this will be fixed in later irrlicht versions, but for now our players may flash
|
|
||||||
|
|
||||||
if (m_node) {
|
if (m_node) {
|
||||||
m_node->setFrameLoop(0,79);
|
m_node->setFrameLoop(0,79);
|
||||||
|
|
Loading…
Reference in New Issue