summaryrefslogtreecommitdiff
path: root/src/tile.cpp
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2011-12-03 08:40:32 +0100
committerPerttu Ahola <celeron55@gmail.com>2011-12-03 11:47:37 +0200
commit392485aa454e871566a67afc61e11331f9d27397 (patch)
tree7c2a0b971feaa6cad6fafff9569d57d8bda53803 /src/tile.cpp
parent275a348b75ae710f5cfdb71595ea6e95ecdbcd63 (diff)
downloadminetest-392485aa454e871566a67afc61e11331f9d27397.tar.gz
minetest-392485aa454e871566a67afc61e11331f9d27397.tar.bz2
minetest-392485aa454e871566a67afc61e11331f9d27397.zip
inventorycube: use all three specified textures; also moved mesh creation / modification functions to mesh.cpp; in lua, inventorycube is now called minetest.inventorycube
Diffstat (limited to 'src/tile.cpp')
-rw-r--r--src/tile.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/tile.cpp b/src/tile.cpp
index 27454c321..89f345197 100644
--- a/src/tile.cpp
+++ b/src/tile.cpp
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h"
#include "utility.h"
#include "settings.h"
+#include "mesh.h"
#include <ICameraSceneNode.h>
#include "log.h"
#include "mapnode.h" // For texture atlas making
@@ -1468,11 +1469,14 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
assert(img_top && img_left && img_right);
// Create textures from images
- // TODO: Use them all
video::ITexture *texture_top = driver->addTexture(
(imagename_top + "__temp__").c_str(), img_top);
- assert(texture_top);
-
+ video::ITexture *texture_left = driver->addTexture(
+ (imagename_left + "__temp__").c_str(), img_left);
+ video::ITexture *texture_right = driver->addTexture(
+ (imagename_right + "__temp__").c_str(), img_right);
+ assert(texture_top && texture_left && texture_right);
+
// Drop images
img_top->drop();
img_left->drop();
@@ -1499,17 +1503,24 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
Create scene:
- An unit cube is centered at 0,0,0
- Camera looks at cube from Y+, Z- towards Y-, Z+
- NOTE: Cube has to be changed to something else because
- the textures cannot be set individually (or can they?)
*/
- scene::ISceneNode* cube = smgr->addCubeSceneNode(1.0, NULL, -1,
- v3f(0,0,0), v3f(0, 45, 0));
+ scene::IMesh* cube = createCubeMesh(v3f(1, 1, 1));
+ setMeshColor(cube, video::SColor(255, 255, 255, 255));
+
+ scene::IMeshSceneNode* cubenode = smgr->addMeshSceneNode(cube, NULL, -1, v3f(0,0,0), v3f(0,45,0), v3f(1,1,1), true);
+ cube->drop();
+
// Set texture of cube
- cube->setMaterialTexture(0, texture_top);
- //cube->setMaterialFlag(video::EMF_LIGHTING, false);
- cube->setMaterialFlag(video::EMF_ANTI_ALIASING, false);
- cube->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
+ cubenode->getMaterial(0).setTexture(0, texture_top);
+ cubenode->getMaterial(1).setTexture(0, texture_top);
+ cubenode->getMaterial(2).setTexture(0, texture_right);
+ cubenode->getMaterial(3).setTexture(0, texture_right);
+ cubenode->getMaterial(4).setTexture(0, texture_left);
+ cubenode->getMaterial(5).setTexture(0, texture_left);
+ cubenode->setMaterialFlag(video::EMF_LIGHTING, true);
+ cubenode->setMaterialFlag(video::EMF_ANTI_ALIASING, true);
+ cubenode->setMaterialFlag(video::EMF_BILINEAR_FILTER, true);
scene::ICameraSceneNode* camera = smgr->addCameraSceneNode(0,
v3f(0, 1.0, -1.5), v3f(0, 0, 0));
@@ -1519,7 +1530,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
camera->setProjectionMatrix(pm, true);
/*scene::ILightSceneNode *light =*/ smgr->addLightSceneNode(0,
- v3f(-50, 100, 0), video::SColorf(0.5,0.5,0.5), 1000);
+ v3f(-50, 100, -75), video::SColorf(0.5,0.5,0.5), 1000);
smgr->setAmbientLight(video::SColorf(0.2,0.2,0.2));
@@ -1540,8 +1551,9 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
driver->setRenderTarget(0, true, true, 0);
// Free textures of images
- // TODO: When all are used, free them all
driver->removeTexture(texture_top);
+ driver->removeTexture(texture_left);
+ driver->removeTexture(texture_right);
// Create image of render target
video::IImage *image = driver->createImage(rtt, v2s32(0,0), dim);