Upright sprite objects: Horizontally flip the front image
For consistent horizontal sprite structure when seen from front and back Fix code stylepull/4387/head
parent
2cb0f649f4
commit
8a98cbda84
|
@ -839,54 +839,50 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr,
|
||||||
setBillboardTextureMatrix(m_spritenode,
|
setBillboardTextureMatrix(m_spritenode,
|
||||||
txs, tys, 0, 0);
|
txs, tys, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
} else if (m_prop.visual == "upright_sprite") {
|
||||||
else if(m_prop.visual == "upright_sprite") {
|
|
||||||
scene::SMesh *mesh = new scene::SMesh();
|
scene::SMesh *mesh = new scene::SMesh();
|
||||||
double dx = BS*m_prop.visual_size.X/2;
|
double dx = BS * m_prop.visual_size.X / 2;
|
||||||
double dy = BS*m_prop.visual_size.Y/2;
|
double dy = BS * m_prop.visual_size.Y / 2;
|
||||||
{ // Front
|
|
||||||
scene::IMeshBuffer *buf = new scene::SMeshBuffer();
|
|
||||||
u8 li = m_last_light;
|
u8 li = m_last_light;
|
||||||
video::SColor c(255,li,li,li);
|
video::SColor c(255, li, li, li);
|
||||||
video::S3DVertex vertices[4] =
|
|
||||||
{
|
{ // Front
|
||||||
video::S3DVertex(-dx,-dy,0, 0,0,0, c, 0,1),
|
scene::IMeshBuffer *buf = new scene::SMeshBuffer();
|
||||||
video::S3DVertex(dx,-dy,0, 0,0,0, c, 1,1),
|
video::S3DVertex vertices[4] = {
|
||||||
video::S3DVertex(dx,dy,0, 0,0,0, c, 1,0),
|
video::S3DVertex(-dx, -dy, 0, 0,0,0, c, 1,1),
|
||||||
video::S3DVertex(-dx,dy,0, 0,0,0, c, 0,0),
|
video::S3DVertex( dx, -dy, 0, 0,0,0, c, 0,1),
|
||||||
};
|
video::S3DVertex( dx, dy, 0, 0,0,0, c, 0,0),
|
||||||
u16 indices[] = {0,1,2,2,3,0};
|
video::S3DVertex(-dx, dy, 0, 0,0,0, c, 1,0),
|
||||||
buf->append(vertices, 4, indices, 6);
|
};
|
||||||
// Set material
|
u16 indices[] = {0,1,2,2,3,0};
|
||||||
buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
|
buf->append(vertices, 4, indices, 6);
|
||||||
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
|
// Set material
|
||||||
buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
|
buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
|
||||||
buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||||
// Add to mesh
|
buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
|
||||||
mesh->addMeshBuffer(buf);
|
buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||||
buf->drop();
|
// Add to mesh
|
||||||
|
mesh->addMeshBuffer(buf);
|
||||||
|
buf->drop();
|
||||||
}
|
}
|
||||||
{ // Back
|
{ // Back
|
||||||
scene::IMeshBuffer *buf = new scene::SMeshBuffer();
|
scene::IMeshBuffer *buf = new scene::SMeshBuffer();
|
||||||
u8 li = m_last_light;
|
video::S3DVertex vertices[4] = {
|
||||||
video::SColor c(255,li,li,li);
|
video::S3DVertex( dx,-dy, 0, 0,0,0, c, 1,1),
|
||||||
video::S3DVertex vertices[4] =
|
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,1),
|
video::S3DVertex( dx, dy, 0, 0,0,0, c, 1,0),
|
||||||
video::S3DVertex(-dx,-dy,0, 0,0,0, c, 0,1),
|
};
|
||||||
video::S3DVertex(-dx,dy,0, 0,0,0, c, 0,0),
|
u16 indices[] = {0,1,2,2,3,0};
|
||||||
video::S3DVertex(dx,dy,0, 0,0,0, c, 1,0),
|
buf->append(vertices, 4, indices, 6);
|
||||||
};
|
// Set material
|
||||||
u16 indices[] = {0,1,2,2,3,0};
|
buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
|
||||||
buf->append(vertices, 4, indices, 6);
|
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||||
// Set material
|
buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
|
||||||
buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
|
buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||||
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
|
// Add to mesh
|
||||||
buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
|
mesh->addMeshBuffer(buf);
|
||||||
buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
buf->drop();
|
||||||
// Add to mesh
|
|
||||||
mesh->addMeshBuffer(buf);
|
|
||||||
buf->drop();
|
|
||||||
}
|
}
|
||||||
m_meshnode = smgr->addMeshSceneNode(mesh, NULL);
|
m_meshnode = smgr->addMeshSceneNode(mesh, NULL);
|
||||||
m_meshnode->grab();
|
m_meshnode->grab();
|
||||||
|
|
Loading…
Reference in New Issue