Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Ryan Newell 2014-10-19 18:22:52 -07:00
commit eac06b8168
19 changed files with 445 additions and 46 deletions

View File

@ -103,6 +103,7 @@ mods
| |-- screenshot.png
| |-- description.txt
| |-- init.lua
| |-- models
| |-- textures
| | |-- modname_stuff.png
| | `-- modname_something_else.png
@ -137,6 +138,9 @@ init.lua:
minetest.setting_get(name) and minetest.setting_getbool(name) can be used
to read custom or existing settings at load time, if necessary.
models:
Models for entities or meshnodes.
textures, sounds, media:
Media files (textures, sounds, whatever) that will be transferred to the
client and will be available for use by the mod.
@ -404,8 +408,16 @@ param2 is reserved for the engine when any of these are used:
0 = y+ 1 = z+ 2 = z- 3 = x+ 4 = x- 5 = y-
facedir's two less significant bits are rotation around the axis
paramtype2 == "leveled"
^ The drawn node level is read from param2, like flowingliquid
collision_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
},
^ defines list of collision boxes for the node. If empty, collision boxes
will be the same as nodeboxes, in case of any other nodes will be full cube
as in the example above.
Nodes can also contain extra data. See "Node Metadata".
Node drawtypes
@ -430,6 +442,7 @@ Look for examples in games/minimal or games/minetest_game.
- fencelike
- raillike
- nodebox -- See below. EXPERIMENTAL
- mesh -- use models for nodes
*_optional drawtypes need less rendering time if deactivated (always client side)
@ -469,6 +482,12 @@ A box of a regular node would look like:
type = "leveled" is same as "fixed", but y2 will be automatically set to level from param2
Meshes
-----------
If drawtype "mesh" is used tiles should hold model materials textures.
Only static meshes are implemented.
For supported model formats see Irrlicht engine documentation.
Ore types
---------------
These tell in what manner the ore is generated.
@ -2405,7 +2424,7 @@ Node definition (register_node)
drawtype = "normal", -- See "Node drawtypes"
visual_scale = 1.0,
^ Supported for drawtypes "plantlike", "signlike", "torchlike".
^ Supported for drawtypes "plantlike", "signlike", "torchlike", "mesh".
^ For plantlike, the image will start at the bottom of the node; for the
^ other drawtypes, the image will be centered on the node.
^ Note that positioning for "torchlike" may still change.
@ -2439,6 +2458,7 @@ Node definition (register_node)
light_source = 0, -- Amount of light emitted by node
damage_per_second = 0, -- If player is inside node, this damage is caused
node_box = {type="regular"}, -- See "Node boxes"
mesh = "model",
selection_box = {type="regular"}, -- See "Node boxes"
^ If drawtype "nodebox" is used and selection_box is nil, then node_box is used
legacy_facedir_simple = false, -- Support maps made in and before January 2012

View File

@ -250,6 +250,7 @@ Client::Client(
m_inventory_updated(false),
m_inventory_from_server(NULL),
m_inventory_from_server_age(0.0),
m_show_hud(true),
m_animation_time(0),
m_crack_level(-1),
m_crack_pos(0,0,0),
@ -2678,7 +2679,7 @@ void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font)
// Update node textures and assign shaders to each tile
infostream<<"- Updating node textures"<<std::endl;
m_nodedef->updateTextures(m_tsrc, m_shsrc);
m_nodedef->updateTextures(this);
// Preload item textures and meshes if configured to
if(g_settings->getBool("preload_item_visuals"))

View File

@ -259,7 +259,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
continue;
int n_bouncy_value = itemgroup_get(f.groups, "bouncy");
std::vector<aabb3f> nodeboxes = n.getNodeBoxes(gamedef->ndef());
std::vector<aabb3f> nodeboxes = n.getCollisionBoxes(gamedef->ndef());
for(std::vector<aabb3f>::iterator
i = nodeboxes.begin();
i != nodeboxes.end(); i++)

View File

@ -188,10 +188,10 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
// Create selection mesh
v3s16 p = data->m_highlighted_pos_relative;
if (data->m_show_hud &
(p.X >= 0) & (p.X < MAP_BLOCKSIZE) &
(p.Y >= 0) & (p.Y < MAP_BLOCKSIZE) &
(p.Z >= 0) & (p.Z < MAP_BLOCKSIZE)) {
if (data->m_show_hud &&
(p.X >= 0) && (p.X < MAP_BLOCKSIZE) &&
(p.Y >= 0) && (p.Y < MAP_BLOCKSIZE) &&
(p.Z >= 0) && (p.Z < MAP_BLOCKSIZE)) {
MapNode n = data->m_vmanip.getNodeNoEx(blockpos_nodes + p);
if(n.getContent() != CONTENT_AIR) {
@ -215,7 +215,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
l = l1;
}
video::SColor c = MapBlock_LightColor(255, l, 0);
data->m_highlight_mesh_color = c;
data->m_highlight_mesh_color = c;
std::vector<aabb3f> boxes = n.getSelectionBoxes(nodedef);
TileSpec h_tile;
h_tile.material_flags |= MATERIAL_FLAG_HIGHLIGHTED;
@ -1715,6 +1715,18 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
makeCuboid(&collector, box, tiles, 6, c, txc);
}
break;}
case NDT_MESH:
{
v3f pos = intToFloat(p, BS);
video::SColor c = MapBlock_LightColor(255, getInteriorLight(n, 1, nodedef), f.light_source);
u8 facedir = n.getFaceDir(nodedef);
for(u16 j = 0; j < f.mesh_ptr[facedir]->getMeshBufferCount(); j++) {
scene::IMeshBuffer *buf = f.mesh_ptr[facedir]->getMeshBuffer(j);
collector.append(getNodeTileN(n, p, j, data),
(video::S3DVertex *)buf->getVertices(), buf->getVertexCount(),
buf->getIndices(), buf->getIndexCount(), pos, c);
}
break;}
}
}
}

View File

@ -1036,7 +1036,8 @@ static void show_pause_menu(GUIFormSpecMenu** cur_formspec,
"- T: chat\n"
));
#endif
float ypos = singleplayermode ? 1.0 : 0.5;
float ypos = singleplayermode ? 0.5 : 0.1;
std::ostringstream os;
os << FORMSPEC_VERSION_STRING << SIZE_TAG

View File

@ -48,6 +48,8 @@ MeshMakeData::MeshMakeData(IGameDef *gamedef):
m_crack_pos_relative(-1337, -1337, -1337),
m_highlighted_pos_relative(-1337, -1337, -1337),
m_smooth_lighting(false),
m_show_hud(false),
m_highlight_mesh_color(255, 255, 255, 255),
m_gamedef(gamedef)
{}
@ -330,7 +332,7 @@ static void finalColorBlend(video::SColor& result,
// Emphase blue a bit in darker places
// Each entry of this array represents a range of 8 blue levels
static u8 emphase_blue_when_dark[32] = {
static const u8 emphase_blue_when_dark[32] = {
1, 4, 6, 6, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
@ -338,7 +340,7 @@ static void finalColorBlend(video::SColor& result,
b = irr::core::clamp (b, 0, 255);
// Artificial light is yellow-ish
static u8 emphase_yellow_when_artificial[16] = {
static const u8 emphase_yellow_when_artificial[16] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 10, 15, 15, 15
};
rg += emphase_yellow_when_artificial[night/16];
@ -1086,7 +1088,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
mapblock_mesh_generate_special(data, collector);
m_highlight_mesh_color = data->m_highlight_mesh_color;
m_highlight_mesh_color = data->m_highlight_mesh_color;
/*
Convert MeshCollector to SMesh
@ -1428,3 +1430,54 @@ void MeshCollector::append(const TileSpec &tile,
p->vertices.push_back(vertices[i]);
}
}
/*
MeshCollector - for meshnodes and converted drawtypes.
*/
void MeshCollector::append(const TileSpec &tile,
const video::S3DVertex *vertices, u32 numVertices,
const u16 *indices, u32 numIndices,
v3f pos, video::SColor c)
{
if(numIndices > 65535)
{
dstream<<"FIXME: MeshCollector::append() called with numIndices="<<numIndices<<" (limit 65535)"<<std::endl;
return;
}
PreMeshBuffer *p = NULL;
for(u32 i=0; i<prebuffers.size(); i++)
{
PreMeshBuffer &pp = prebuffers[i];
if(pp.tile != tile)
continue;
if(pp.indices.size() + numIndices > 65535)
continue;
p = &pp;
break;
}
if(p == NULL)
{
PreMeshBuffer pp;
pp.tile = tile;
prebuffers.push_back(pp);
p = &prebuffers[prebuffers.size()-1];
}
u32 vertex_count = p->vertices.size();
for(u32 i=0; i<numIndices; i++)
{
u32 j = indices[i] + vertex_count;
p->indices.push_back(j);
}
for(u32 i=0; i<numVertices; i++)
{
video::S3DVertex vert = vertices[i];
vert.Pos += pos;
vert.Color = c;
p->vertices.push_back(vert);
}
}

View File

@ -174,6 +174,10 @@ struct MeshCollector
void append(const TileSpec &material,
const video::S3DVertex *vertices, u32 numVertices,
const u16 *indices, u32 numIndices);
void append(const TileSpec &material,
const video::S3DVertex *vertices, u32 numVertices,
const u16 *indices, u32 numIndices,
v3f pos, video::SColor c);
};
// This encodes

View File

@ -354,6 +354,15 @@ std::vector<aabb3f> MapNode::getNodeBoxes(INodeDefManager *nodemgr) const
return transformNodeBox(*this, f.node_box, nodemgr);
}
std::vector<aabb3f> MapNode::getCollisionBoxes(INodeDefManager *nodemgr) const
{
const ContentFeatures &f = nodemgr->get(*this);
if (f.collision_box.fixed.empty())
return transformNodeBox(*this, f.node_box, nodemgr);
else
return transformNodeBox(*this, f.collision_box, nodemgr);
}
std::vector<aabb3f> MapNode::getSelectionBoxes(INodeDefManager *nodemgr) const
{
const ContentFeatures &f = nodemgr->get(*this);

View File

@ -217,8 +217,7 @@ struct MapNode
void rotateAlongYAxis(INodeDefManager *nodemgr, Rotation rot);
/*
Gets list of node boxes (used for rendering (NDT_NODEBOX)
and collision)
Gets list of node boxes (used for rendering (NDT_NODEBOX))
*/
std::vector<aabb3f> getNodeBoxes(INodeDefManager *nodemgr) const;
@ -227,6 +226,11 @@ struct MapNode
*/
std::vector<aabb3f> getSelectionBoxes(INodeDefManager *nodemgr) const;
/*
Gets list of collision boxes
*/
std::vector<aabb3f> getCollisionBoxes(INodeDefManager *nodemgr) const;
/* Liquid helpers */
u8 getMaxLevel(INodeDefManager *nodemgr) const;
u8 getLevel(INodeDefManager *nodemgr) const;

View File

@ -408,3 +408,219 @@ void setMeshColorByNormalXYZ(scene::IMesh *mesh,
}
}
}
void rotateMeshBy6dFacedir(scene::IMesh *mesh, int facedir)
{
int axisdir = facedir>>2;
facedir &= 0x03;
u16 mc = mesh->getMeshBufferCount();
for(u16 j = 0; j < mc; j++)
{
scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
u16 vc = buf->getVertexCount();
for(u16 i=0; i<vc; i++)
{
switch (axisdir)
{
case 0:
if(facedir == 1)
vertices[i].Pos.rotateXZBy(-90);
else if(facedir == 2)
vertices[i].Pos.rotateXZBy(180);
else if(facedir == 3)
vertices[i].Pos.rotateXZBy(90);
break;
case 1: // z+
vertices[i].Pos.rotateYZBy(90);
if(facedir == 1)
vertices[i].Pos.rotateXYBy(90);
else if(facedir == 2)
vertices[i].Pos.rotateXYBy(180);
else if(facedir == 3)
vertices[i].Pos.rotateXYBy(-90);
break;
case 2: //z-
vertices[i].Pos.rotateYZBy(-90);
if(facedir == 1)
vertices[i].Pos.rotateXYBy(-90);
else if(facedir == 2)
vertices[i].Pos.rotateXYBy(180);
else if(facedir == 3)
vertices[i].Pos.rotateXYBy(90);
break;
case 3: //x+
vertices[i].Pos.rotateXYBy(-90);
if(facedir == 1)
vertices[i].Pos.rotateYZBy(90);
else if(facedir == 2)
vertices[i].Pos.rotateYZBy(180);
else if(facedir == 3)
vertices[i].Pos.rotateYZBy(-90);
break;
case 4: //x-
vertices[i].Pos.rotateXYBy(90);
if(facedir == 1)
vertices[i].Pos.rotateYZBy(-90);
else if(facedir == 2)
vertices[i].Pos.rotateYZBy(180);
else if(facedir == 3)
vertices[i].Pos.rotateYZBy(90);
break;
case 5:
vertices[i].Pos.rotateXYBy(-180);
if(facedir == 1)
vertices[i].Pos.rotateXZBy(90);
else if(facedir == 2)
vertices[i].Pos.rotateXZBy(180);
else if(facedir == 3)
vertices[i].Pos.rotateXZBy(-90);
break;
default:
break;
}
}
}
}
void recalculateBoundingBox(scene::IMesh *src_mesh)
{
core::aabbox3d<f32> bbox;
bbox.reset(0,0,0);
for(u16 j = 0; j < src_mesh->getMeshBufferCount(); j++)
{
scene::IMeshBuffer *buf = src_mesh->getMeshBuffer(j);
buf->recalculateBoundingBox();
if(j == 0)
bbox = buf->getBoundingBox();
else
bbox.addInternalBox(buf->getBoundingBox());
}
src_mesh->setBoundingBox(bbox);
}
scene::IMesh* cloneMesh(scene::IMesh *src_mesh)
{
scene::SMesh* dst_mesh = new scene::SMesh();
for(u16 j = 0; j < src_mesh->getMeshBufferCount(); j++)
{
scene::IMeshBuffer *buf = src_mesh->getMeshBuffer(j);
video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
u16 *indices = (u16*)buf->getIndices();
scene::SMeshBuffer *temp_buf = new scene::SMeshBuffer();
temp_buf->append(vertices, buf->getVertexCount(),
indices, buf->getIndexCount());
dst_mesh->addMeshBuffer(temp_buf);
temp_buf->drop();
}
return dst_mesh;
}
scene::IMesh* convertNodeboxNodeToMesh(ContentFeatures *f)
{
scene::SMesh* dst_mesh = new scene::SMesh();
for (u16 j = 0; j < 6; j++)
{
scene::IMeshBuffer *buf = new scene::SMeshBuffer();
dst_mesh->addMeshBuffer(buf);
buf->drop();
}
video::SColor c(255,255,255,255);
std::vector<aabb3f> boxes = f->node_box.fixed;
for(std::vector<aabb3f>::iterator
i = boxes.begin();
i != boxes.end(); i++)
{
aabb3f box = *i;
f32 temp;
if (box.MinEdge.X > box.MaxEdge.X)
{
temp=box.MinEdge.X;
box.MinEdge.X=box.MaxEdge.X;
box.MaxEdge.X=temp;
}
if (box.MinEdge.Y > box.MaxEdge.Y)
{
temp=box.MinEdge.Y;
box.MinEdge.Y=box.MaxEdge.Y;
box.MaxEdge.Y=temp;
}
if (box.MinEdge.Z > box.MaxEdge.Z)
{
temp=box.MinEdge.Z;
box.MinEdge.Z=box.MaxEdge.Z;
box.MaxEdge.Z=temp;
}
// Compute texture coords
f32 tx1 = (box.MinEdge.X/BS)+0.5;
f32 ty1 = (box.MinEdge.Y/BS)+0.5;
f32 tz1 = (box.MinEdge.Z/BS)+0.5;
f32 tx2 = (box.MaxEdge.X/BS)+0.5;
f32 ty2 = (box.MaxEdge.Y/BS)+0.5;
f32 tz2 = (box.MaxEdge.Z/BS)+0.5;
f32 txc[24] = {
// up
tx1, 1-tz2, tx2, 1-tz1,
// down
tx1, tz1, tx2, tz2,
// right
tz1, 1-ty2, tz2, 1-ty1,
// left
1-tz2, 1-ty2, 1-tz1, 1-ty1,
// back
1-tx2, 1-ty2, 1-tx1, 1-ty1,
// front
tx1, 1-ty2, tx2, 1-ty1,
};
v3f min = box.MinEdge;
v3f max = box.MaxEdge;
video::S3DVertex vertices[24] =
{
// up
video::S3DVertex(min.X,max.Y,max.Z, 0,1,0, c, txc[0],txc[1]),
video::S3DVertex(max.X,max.Y,max.Z, 0,1,0, c, txc[2],txc[1]),
video::S3DVertex(max.X,max.Y,min.Z, 0,1,0, c, txc[2],txc[3]),
video::S3DVertex(min.X,max.Y,min.Z, 0,1,0, c, txc[0],txc[3]),
// down
video::S3DVertex(min.X,min.Y,min.Z, 0,-1,0, c, txc[4],txc[5]),
video::S3DVertex(max.X,min.Y,min.Z, 0,-1,0, c, txc[6],txc[5]),
video::S3DVertex(max.X,min.Y,max.Z, 0,-1,0, c, txc[6],txc[7]),
video::S3DVertex(min.X,min.Y,max.Z, 0,-1,0, c, txc[4],txc[7]),
// right
video::S3DVertex(max.X,max.Y,min.Z, 1,0,0, c, txc[ 8],txc[9]),
video::S3DVertex(max.X,max.Y,max.Z, 1,0,0, c, txc[10],txc[9]),
video::S3DVertex(max.X,min.Y,max.Z, 1,0,0, c, txc[10],txc[11]),
video::S3DVertex(max.X,min.Y,min.Z, 1,0,0, c, txc[ 8],txc[11]),
// left
video::S3DVertex(min.X,max.Y,max.Z, -1,0,0, c, txc[12],txc[13]),
video::S3DVertex(min.X,max.Y,min.Z, -1,0,0, c, txc[14],txc[13]),
video::S3DVertex(min.X,min.Y,min.Z, -1,0,0, c, txc[14],txc[15]),
video::S3DVertex(min.X,min.Y,max.Z, -1,0,0, c, txc[12],txc[15]),
// back
video::S3DVertex(max.X,max.Y,max.Z, 0,0,1, c, txc[16],txc[17]),
video::S3DVertex(min.X,max.Y,max.Z, 0,0,1, c, txc[18],txc[17]),
video::S3DVertex(min.X,min.Y,max.Z, 0,0,1, c, txc[18],txc[19]),
video::S3DVertex(max.X,min.Y,max.Z, 0,0,1, c, txc[16],txc[19]),
// front
video::S3DVertex(min.X,max.Y,min.Z, 0,0,-1, c, txc[20],txc[21]),
video::S3DVertex(max.X,max.Y,min.Z, 0,0,-1, c, txc[22],txc[21]),
video::S3DVertex(max.X,min.Y,min.Z, 0,0,-1, c, txc[22],txc[23]),
video::S3DVertex(min.X,min.Y,min.Z, 0,0,-1, c, txc[20],txc[23]),
};
u16 indices[] = {0,1,2,2,3,0};
for(u16 j = 0; j < 24; j += 4)
{
scene::IMeshBuffer *buf = dst_mesh->getMeshBuffer(j / 4);
buf->append(vertices + j, 4, indices, 6);
}
}
return dst_mesh;
}

View File

@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define MESH_HEADER
#include "irrlichttypes_extrabloated.h"
#include "nodedef.h"
#include <string>
/*
@ -68,5 +69,25 @@ void setMeshColorByNormalXYZ(scene::IMesh *mesh,
const video::SColor &colorX,
const video::SColor &colorY,
const video::SColor &colorZ);
/*
Rotate the mesh by 6d facedir value.
Method only for meshnodes, not suitable for entities.
*/
void rotateMeshBy6dFacedir(scene::IMesh *mesh, int facedir);
/*
Clone the mesh.
*/
scene::IMesh* cloneMesh(scene::IMesh *src_mesh);
/*
Convert nodebox drawtype node to mesh.
*/
scene::IMesh* convertNodeboxNodeToMesh(ContentFeatures *f);
/*
Update bounding box for a mesh.
*/
void recalculateBoundingBox(scene::IMesh *src_mesh);
#endif

View File

@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "itemdef.h"
#ifndef SERVER
#include "tile.h"
#include "mesh.h"
#endif
#include "log.h"
#include "settings.h"
@ -31,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/serialize.h"
#include "exceptions.h"
#include "debug.h"
#include "gamedef.h"
/*
NodeBox
@ -195,6 +197,11 @@ void ContentFeatures::reset()
// Unknown nodes can be dug
groups["dig_immediate"] = 2;
drawtype = NDT_NORMAL;
mesh = "";
#ifndef SERVER
for(u32 i = 0; i < 24; i++)
mesh_ptr[i] = NULL;
#endif
visual_scale = 1.0;
for(u32 i = 0; i < 6; i++)
tiledef[i] = TileDef();
@ -226,6 +233,7 @@ void ContentFeatures::reset()
damage_per_second = 0;
node_box = NodeBox();
selection_box = NodeBox();
collision_box = NodeBox();
waving = 0;
legacy_facedir_simple = false;
legacy_wallmounted = false;
@ -295,6 +303,8 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version)
writeU8(os, waving);
// Stuff below should be moved to correct place in a version that otherwise changes
// the protocol version
os<<serializeString(mesh);
collision_box.serialize(os, protocol_version);
}
void ContentFeatures::deSerialize(std::istream &is)
@ -363,6 +373,8 @@ void ContentFeatures::deSerialize(std::istream &is)
try{
// Stuff below should be moved to correct place in a version that
// otherwise changes the protocol version
mesh = deSerializeString(is);
collision_box.deSerialize(is);
}catch(SerializationError &e) {};
}
@ -386,7 +398,7 @@ public:
virtual content_t set(const std::string &name, const ContentFeatures &def);
virtual content_t allocateDummy(const std::string &name);
virtual void updateAliases(IItemDefManager *idef);
virtual void updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc);
virtual void updateTextures(IGameDef *gamedef);
void serialize(std::ostream &os, u16 protocol_version);
void deSerialize(std::istream &is);
@ -669,11 +681,14 @@ void CNodeDefManager::updateAliases(IItemDefManager *idef)
}
void CNodeDefManager::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc)
void CNodeDefManager::updateTextures(IGameDef *gamedef)
{
#ifndef SERVER
infostream << "CNodeDefManager::updateTextures(): Updating "
"textures in node definitions" << std::endl;
ITextureSource *tsrc = gamedef->tsrc();
IShaderSource *shdsrc = gamedef->getShaderSource();
bool new_style_water = g_settings->getBool("new_style_water");
bool new_style_leaves = g_settings->getBool("new_style_leaves");
@ -771,6 +786,10 @@ void CNodeDefManager::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
f->backface_culling = false;
f->solidness = 0;
break;
case NDT_MESH:
f->solidness = 0;
f->backface_culling = false;
break;
case NDT_TORCHLIKE:
case NDT_SIGNLIKE:
case NDT_FENCELIKE:
@ -810,6 +829,34 @@ void CNodeDefManager::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
tile_shader[j], use_normal_texture,
f->tiledef_special[j].backface_culling, f->alpha, material_type);
}
// Meshnode drawtype
// Read the mesh and apply scale
if ((f->drawtype == NDT_MESH) && (f->mesh != "")) {
f->mesh_ptr[0] = gamedef->getMesh(f->mesh);
scaleMesh(f->mesh_ptr[0], v3f(f->visual_scale,f->visual_scale,f->visual_scale));
recalculateBoundingBox(f->mesh_ptr[0]);
}
//Convert regular nodebox nodes to meshnodes
//Change the drawtype and apply scale
if ((f->drawtype == NDT_NODEBOX) &&
((f->node_box.type == NODEBOX_REGULAR) || (f->node_box.type == NODEBOX_FIXED)) &&
(!f->node_box.fixed.empty())) {
f->drawtype = NDT_MESH;
f->mesh_ptr[0] = convertNodeboxNodeToMesh(f);
scaleMesh(f->mesh_ptr[0], v3f(f->visual_scale,f->visual_scale,f->visual_scale));
recalculateBoundingBox(f->mesh_ptr[0]);
}
//Cache 6dfacedir rotated clones of meshes
if (f->mesh_ptr[0] && (f->param_type_2 == CPT2_FACEDIR)) {
for (u16 j = 1; j < 24; j++) {
f->mesh_ptr[j] = cloneMesh(f->mesh_ptr[0]);
rotateMeshBy6dFacedir(f->mesh_ptr[j], j);
recalculateBoundingBox(f->mesh_ptr[j]);
}
}
}
#endif
}

View File

@ -152,6 +152,7 @@ enum NodeDrawType
NDT_FIRELIKE, // Draw faces slightly rotated and only on connecting nodes,
NDT_GLASSLIKE_FRAMED_OPTIONAL, // enabled -> connected, disabled -> Glass-like
// uses 2 textures, one for frames, second for faces
NDT_MESH, // Uses static meshes
};
#define CF_SPECIAL_COUNT 6
@ -187,6 +188,10 @@ struct ContentFeatures
// Visual definition
enum NodeDrawType drawtype;
std::string mesh;
#ifndef SERVER
scene::IMesh *mesh_ptr[24];
#endif
float visual_scale; // Misc. scale parameter
TileDef tiledef[6];
TileDef tiledef_special[CF_SPECIAL_COUNT]; // eg. flowing liquid
@ -239,6 +244,7 @@ struct ContentFeatures
u32 damage_per_second;
NodeBox node_box;
NodeBox selection_box;
NodeBox collision_box;
// Used for waving leaves/plants
u8 waving;
// Compatibility with old maps
@ -328,8 +334,7 @@ public:
/*
Update tile textures to latest return values of TextueSource.
*/
virtual void updateTextures(ITextureSource *tsrc,
IShaderSource *shdsrc)=0;
virtual void updateTextures(IGameDef *gamedef)=0;
virtual void serialize(std::ostream &os, u16 protocol_version)=0;
virtual void deSerialize(std::istream &is)=0;

View File

@ -281,6 +281,9 @@ ContentFeatures read_content_features(lua_State *L, int index)
ScriptApiNode::es_DrawType,NDT_NORMAL);
getfloatfield(L, index, "visual_scale", f.visual_scale);
/* Meshnode model filename */
getstringfield(L, index, "mesh", f.mesh);
// tiles = {}
lua_getfield(L, index, "tiles");
// If nil, try the deprecated name "tile_images" instead
@ -429,6 +432,11 @@ ContentFeatures read_content_features(lua_State *L, int index)
f.selection_box = read_nodebox(L, -1);
lua_pop(L, 1);
lua_getfield(L, index, "collision_box");
if(lua_istable(L, -1))
f.collision_box = read_nodebox(L, -1);
lua_pop(L, 1);
f.waving = getintfield_default(L, index,
"waving", f.waving);

View File

@ -45,6 +45,7 @@ struct EnumString ScriptApiNode::es_DrawType[] =
{NDT_FENCELIKE, "fencelike"},
{NDT_RAILLIKE, "raillike"},
{NDT_NODEBOX, "nodebox"},
{NDT_MESH, "mesh"},
{0, NULL},
};

View File

@ -573,6 +573,20 @@ void Sky::update(float time_of_day, float time_brightness,
m_clouds_visible = false;
}
video::SColor bgcolor_bright = m_bgcolor_bright_f.toSColor();
m_bgcolor = video::SColor(
255,
bgcolor_bright.getRed() * m_brightness,
bgcolor_bright.getGreen() * m_brightness,
bgcolor_bright.getBlue() * m_brightness);
video::SColor skycolor_bright = m_skycolor_bright_f.toSColor();
m_skycolor = video::SColor(
255,
skycolor_bright.getRed() * m_brightness,
skycolor_bright.getGreen() * m_brightness,
skycolor_bright.getBlue() * m_brightness);
// Horizon coloring based on sun and moon direction during sunset and sunrise
video::SColor pointcolor = video::SColor(255, 255, 255, m_bgcolor.getAlpha());
if (m_directional_colored_fog) {
@ -606,25 +620,7 @@ void Sky::update(float time_of_day, float time_brightness,
// calculate the blend color
pointcolor = m_mix_scolor(pointcolor_moon, pointcolor_sun, pointcolor_blend);
}
}
video::SColor bgcolor_bright = m_bgcolor_bright_f.toSColor();
m_bgcolor = video::SColor(
255,
bgcolor_bright.getRed() * m_brightness,
bgcolor_bright.getGreen() * m_brightness,
bgcolor_bright.getBlue() * m_brightness);
if (m_directional_colored_fog) {
m_bgcolor = m_mix_scolor(m_bgcolor, pointcolor, m_horizon_blend() * 0.5);
}
video::SColor skycolor_bright = m_skycolor_bright_f.toSColor();
m_skycolor = video::SColor(
255,
skycolor_bright.getRed() * m_brightness,
skycolor_bright.getGreen() * m_brightness,
skycolor_bright.getBlue() * m_brightness);
if (m_directional_colored_fog) {
m_skycolor = m_mix_scolor(m_skycolor, pointcolor, m_horizon_blend() * 0.25);
}

View File

@ -79,7 +79,8 @@ private:
{
if (!m_sunlight_seen)
return 0;
float x; m_time_of_day >= 0.5 ? x = (1 - m_time_of_day) * 2 : x = m_time_of_day * 2;
float x = m_time_of_day >= 0.5 ? (1 - m_time_of_day) * 2 : m_time_of_day * 2;
if (x <= 0.3)
return 0;
if (x <= 0.4) // when the sun and moon are aligned

View File

@ -16,7 +16,7 @@ toolchain_file=$dir/toolchain_mingw.cmake
irrlicht_version=1.8.1
ogg_version=1.2.1
vorbis_version=1.3.3
curl_version=7.18.0
curl_version=7.38.0
gettext_version=0.14.4
freetype_version=2.3.5
luajit_version=2.0.1
@ -41,8 +41,8 @@ cd $builddir
-c -O $packagedir/libvorbis-$vorbis_version-dev.7z
[ -e $packagedir/libvorbis-$vorbis_version-dll.7z ] || wget http://sfan5.pf-control.de/libvorbis-$vorbis_version-dll.7z \
-c -O $packagedir/libvorbis-$vorbis_version-dll.7z
[ -e $packagedir/libcurl-$curl_version-win32-msvc.zip ] || wget http://curl.haxx.se/download/libcurl-$curl_version-win32-msvc.zip \
-c -O $packagedir/libcurl-$curl_version-win32-msvc.zip
[ -e $packagedir/libcurl-$curl_version.zip ] || wget http://sfan5.pf-control.de/libcurl-$curl_version-win32.zip \
-c -O $packagedir/libcurl-$curl_version.zip
[ -e $packagedir/gettext-$gettext_version.zip ] || wget http://sfan5.pf-control.de/gettext-$gettext_version.zip \
-c -O $packagedir/gettext-$gettext_version.zip
[ -e $packagedir/libfreetype-$freetype_version.zip ] || wget http://sfan5.pf-control.de/libfreetype-$freetype_version-win32.zip \
@ -62,7 +62,7 @@ cd $libdir
[ -d libogg/bin ] || 7z x -y -olibogg $packagedir/libogg-$ogg_version-dll.7z
[ -d libvorbis/include ] || 7z x -y -olibvorbis $packagedir/libvorbis-$vorbis_version-dev.7z
[ -d libvorbis/bin ] || 7z x -y -olibvorbis $packagedir/libvorbis-$vorbis_version-dll.7z
[ -d libcurl ] || unzip -o $packagedir/libcurl-$curl_version-win32-msvc.zip -d libcurl
[ -d libcurl ] || unzip -o $packagedir/libcurl-$curl_version.zip -d libcurl
[ -d gettext ] || unzip -o $packagedir/gettext-$gettext_version.zip -d gettext
[ -d freetype ] || unzip -o $packagedir/libfreetype-$freetype_version.zip -d freetype
[ -d openal_stripped ] || unzip -o $packagedir/openal_stripped.zip
@ -123,9 +123,9 @@ cmake .. \
-DOPENAL_LIBRARY=$libdir/openal_stripped/lib/libOpenAL32.dll.a \
-DOPENAL_DLL=$libdir/openal_stripped/bin/OpenAL32.dll \
\
-DCURL_DLL=$libdir/libcurl/libcurl.dll \
-DCURL_DLL=$libdir/libcurl/bin/libcurl-4.dll \
-DCURL_INCLUDE_DIR=$libdir/libcurl/include \
-DCURL_LIBRARY=$libdir/libcurl/libcurl.lib \
-DCURL_LIBRARY=$libdir/libcurl/lib/libcurl.dll.a \
\
-DCUSTOM_GETTEXT_PATH=$libdir/gettext \
-DGETTEXT_MSGFMT=`which msgfmt` \

View File

@ -16,7 +16,7 @@ toolchain_file=$dir/toolchain_mingw64.cmake
irrlicht_version=1.8.1
ogg_version=1.3.1
vorbis_version=1.3.4
curl_version=7.36.0
curl_version=7.38.0
gettext_version=0.18.2
freetype_version=2.5.3
luajit_version=2.0.3