mirror of
https://github.com/moparisthebest/minetest
synced 2024-11-06 17:35:14 -05:00
Properly read the mesh from LUA.
Players can now be set to meshes using the following test script: function switch_player_visual() prop = { mesh="player.obj", texture="player.png", visual="mesh", } for _, obj in pairs(minetest.get_connected_players()) do obj:set_properties(prop) end minetest.after(1.0, switch_player_visual) end minetest.after(1.0, switch_player_visual)
This commit is contained in:
parent
ac97a7f70e
commit
0a020dbcc8
@ -802,14 +802,18 @@ public:
|
|||||||
else if(m_prop.visual == "mesh"){
|
else if(m_prop.visual == "mesh"){
|
||||||
infostream<<"GenericCAO::addToScene(): mesh"<<std::endl;
|
infostream<<"GenericCAO::addToScene(): mesh"<<std::endl;
|
||||||
scene::IAnimatedMesh *mesh = smgr->getMesh(m_prop.mesh.c_str());
|
scene::IAnimatedMesh *mesh = smgr->getMesh(m_prop.mesh.c_str());
|
||||||
m_animated_meshnode = smgr->addAnimatedMeshSceneNode(mesh, NULL);
|
if(mesh)
|
||||||
mesh->drop();
|
{
|
||||||
|
m_animated_meshnode = smgr->addAnimatedMeshSceneNode(mesh, NULL);
|
||||||
m_animated_meshnode->setScale(v3f(m_prop.visual_size.X,
|
|
||||||
m_prop.visual_size.Y,
|
m_animated_meshnode->setScale(v3f(m_prop.visual_size.X,
|
||||||
m_prop.visual_size.X));
|
m_prop.visual_size.Y,
|
||||||
u8 li = m_last_light;
|
m_prop.visual_size.X));
|
||||||
setMeshColor(m_animated_meshnode->getMesh(), video::SColor(255,li,li,li));
|
u8 li = m_last_light;
|
||||||
|
setMeshColor(m_animated_meshnode->getMesh(), video::SColor(255,li,li,li));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
errorstream<<"GenericCAO::addToScene(): Could not load mesh "<<m_prop.mesh<<std::endl;
|
||||||
}
|
}
|
||||||
else if(m_prop.visual == "wielditem"){
|
else if(m_prop.visual == "wielditem"){
|
||||||
infostream<<"GenericCAO::addToScene(): node"<<std::endl;
|
infostream<<"GenericCAO::addToScene(): node"<<std::endl;
|
||||||
|
@ -783,14 +783,14 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_,
|
|||||||
m_prop.weight = 75;
|
m_prop.weight = 75;
|
||||||
m_prop.collisionbox = core::aabbox3d<f32>(-1/3.,-1.0,-1/3., 1/3.,1.0,1/3.);
|
m_prop.collisionbox = core::aabbox3d<f32>(-1/3.,-1.0,-1/3., 1/3.,1.0,1/3.);
|
||||||
// start of default appearance, this should be overwritten by LUA
|
// start of default appearance, this should be overwritten by LUA
|
||||||
m_prop.visual = "upright-sprite";
|
m_prop.visual = "upright_sprite";
|
||||||
m_prop.visual_size = v2f(1, 2);
|
m_prop.visual_size = v2f(1, 2);
|
||||||
m_prop.textures.clear();
|
m_prop.textures.clear();
|
||||||
m_prop.textures.push_back("player.png");
|
m_prop.textures.push_back("player.png");
|
||||||
m_prop.textures.push_back("player_back.png");
|
m_prop.textures.push_back("player_back.png");
|
||||||
m_prop.spritediv = v2s16(1,1);
|
m_prop.spritediv = v2s16(1,1);
|
||||||
// end of default appearance
|
// end of default appearance
|
||||||
m_prop.is_visible = (getHP() != 0);
|
m_prop.is_visible = (getHP() != 0); // TODO: Use a death animation instead for mesh players
|
||||||
m_prop.makes_footstep_sound = true;
|
m_prop.makes_footstep_sound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1138,7 +1138,6 @@ void PlayerSAO::disconnected()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string PlayerSAO::getPropertyPacket()
|
std::string PlayerSAO::getPropertyPacket()
|
||||||
{
|
{
|
||||||
m_prop.is_visible = (getHP() != 0);
|
m_prop.is_visible = (getHP() != 0);
|
||||||
|
@ -30,6 +30,8 @@ ObjectProperties::ObjectProperties():
|
|||||||
weight(5),
|
weight(5),
|
||||||
collisionbox(-0.5,-0.5,-0.5, 0.5,0.5,0.5),
|
collisionbox(-0.5,-0.5,-0.5, 0.5,0.5,0.5),
|
||||||
visual("sprite"),
|
visual("sprite"),
|
||||||
|
mesh(""),
|
||||||
|
texture(""),
|
||||||
visual_size(1,1),
|
visual_size(1,1),
|
||||||
spritediv(1,1),
|
spritediv(1,1),
|
||||||
initial_sprite_basepos(0,0),
|
initial_sprite_basepos(0,0),
|
||||||
@ -48,6 +50,8 @@ std::string ObjectProperties::dump()
|
|||||||
os<<", weight="<<weight;
|
os<<", weight="<<weight;
|
||||||
os<<", collisionbox="<<PP(collisionbox.MinEdge)<<","<<PP(collisionbox.MaxEdge);
|
os<<", collisionbox="<<PP(collisionbox.MinEdge)<<","<<PP(collisionbox.MaxEdge);
|
||||||
os<<", visual="<<visual;
|
os<<", visual="<<visual;
|
||||||
|
os<<", mesh="<<mesh;
|
||||||
|
os<<", texture="<<texture;
|
||||||
os<<", visual_size="<<PP2(visual_size);
|
os<<", visual_size="<<PP2(visual_size);
|
||||||
os<<", textures=[";
|
os<<", textures=[";
|
||||||
for(u32 i=0; i<textures.size(); i++){
|
for(u32 i=0; i<textures.size(); i++){
|
||||||
@ -71,6 +75,8 @@ void ObjectProperties::serialize(std::ostream &os) const
|
|||||||
writeV3F1000(os, collisionbox.MinEdge);
|
writeV3F1000(os, collisionbox.MinEdge);
|
||||||
writeV3F1000(os, collisionbox.MaxEdge);
|
writeV3F1000(os, collisionbox.MaxEdge);
|
||||||
os<<serializeString(visual);
|
os<<serializeString(visual);
|
||||||
|
os<<serializeString(mesh);
|
||||||
|
os<<serializeString(texture);
|
||||||
writeV2F1000(os, visual_size);
|
writeV2F1000(os, visual_size);
|
||||||
writeU16(os, textures.size());
|
writeU16(os, textures.size());
|
||||||
for(u32 i=0; i<textures.size(); i++){
|
for(u32 i=0; i<textures.size(); i++){
|
||||||
@ -94,6 +100,8 @@ void ObjectProperties::deSerialize(std::istream &is)
|
|||||||
collisionbox.MinEdge = readV3F1000(is);
|
collisionbox.MinEdge = readV3F1000(is);
|
||||||
collisionbox.MaxEdge = readV3F1000(is);
|
collisionbox.MaxEdge = readV3F1000(is);
|
||||||
visual = deSerializeString(is);
|
visual = deSerializeString(is);
|
||||||
|
mesh = deSerializeString(is);
|
||||||
|
texture = deSerializeString(is);
|
||||||
visual_size = readV2F1000(is);
|
visual_size = readV2F1000(is);
|
||||||
textures.clear();
|
textures.clear();
|
||||||
u32 texture_count = readU16(is);
|
u32 texture_count = readU16(is);
|
||||||
|
@ -936,6 +936,9 @@ static void read_object_properties(lua_State *L, int index,
|
|||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
getstringfield(L, -1, "visual", prop->visual);
|
getstringfield(L, -1, "visual", prop->visual);
|
||||||
|
|
||||||
|
getstringfield(L, -1, "mesh", prop->mesh);
|
||||||
|
getstringfield(L, -1, "texture", prop->texture);
|
||||||
|
|
||||||
lua_getfield(L, -1, "visual_size");
|
lua_getfield(L, -1, "visual_size");
|
||||||
if(lua_istable(L, -1))
|
if(lua_istable(L, -1))
|
||||||
|
Loading…
Reference in New Issue
Block a user