multiple textures terrain in b3d format

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
crivipro
Posts: 20
Joined: Tue Nov 25, 2008 7:17 pm

multiple textures terrain in b3d format

Post by crivipro »

Hi! I am new in irrlicht, I made a terrain with multiple textures using 3d wold studio and exported it to b3d format. Well, I could load the terrain but only I see one texture. What I missing?

This is my code:

// loadB3D.cpp: define el punto de entrada de la aplicación de consola.
//

#include "stdafx.h"
#include <irrlicht.h>

using namespace irr;

#pragma comment(lib, "Irrlicht.lib")

int main()
{

IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(640, 480), 32, false, false, false, 0);

video::IVideoDriver *driver = device->getVideoDriver();
scene::ISceneManager *smgr = device->getSceneManager();
gui::IGUIEnvironment *guienv = device->getGUIEnvironment();

guienv->addStaticText(L"Hello World! You are now running Irrlicht Engine!", core::rect<int>(10,10,200,22), true);

scene::IAnimatedMesh *mesh = smgr->getMesh("media/terrain.b3d");
scene::IAnimatedMeshSceneNode *node = smgr->addAnimatedMeshSceneNode(mesh);

if (node)
{

node->setMaterialFlag(video::EMF_LIGHTING, false);

video::ITexture *texture1 = driver->getTexture("media/isampler24.jpg");
node->setMaterialTexture(0, texture1);
video::ITexture *texture2 = driver->getTexture("media/rock1.jpg");
node->setMaterialTexture(2, texture2);

//node->setFrameLoop(1, 25);

//node->setRotation(core::vector3df(0, 180, 0));
}

//scene::ICameraSceneNode *camera = smgr->addCameraSceneNode(0, core::vector3df(-100, 100, 150), core::vector3df(0, 5, 20));

scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();


while(device->run())
{

driver->beginScene(true, true, video::SColor(255, 100, 101, 140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();

}
device->drop();
return 0;

}

Thanks in advance!
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

hmm, the textures should load automatic (or does b3d not?)... :shock:
at least this is wrong in your code:

Code: Select all

node->setMaterialTexture(2, texture2);
this doesn't mean setting the 2nd texture, but it's texture layer 2 (in fact the 3rd, bc it starts at 0) and this is not what you want !!! ;)
try it without loading the textures manually (remove the 2 setMaterialTexture lines)...

oh, and please use code tags for your code... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
crivipro
Posts: 20
Joined: Tue Nov 25, 2008 7:17 pm

Ok, but another problem with textures

Post by crivipro »

Yes you are right, was just a scene ligth problem I went to 3WDS and set a sun ligth and later could see multiple textures, and commented this lines of code:

Code: Select all

video::ITexture *texture1 = driver->getTexture("media/isampler24.jpg");
node->setMaterialTexture(0, texture1);
video::ITexture *texture2 = driver->getTexture("media/rock1.jpg");
node->setMaterialTexture(2, texture2); 
But now I facing other problem. I have a terrain made in 3d world studio with 2 textures and the textures do not become soft where one finishes and the other one begins, alone a division in straight line between one and another one looks. Please how can I resolve this?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

what do you mean by "not become soft" ???
I guess you want the textures fade into each other ??? ;)
well, this can't be done the way you try it now...

the technique you want to use is called texture blending or splatting...
unfortunately I'm not familar with this, sorry... :cry:

I think there where some threads about this and a terrain editor using Irrlicht in the project announcement forum, but I don't know how much they could help...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
crivipro
Posts: 20
Joined: Tue Nov 25, 2008 7:17 pm

Yes, yes

Post by crivipro »

Sorry my friend, my english is not good enough. That is what I want precisely.
Thanks again!
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post by Eigen »

Better yet, use a 3d world studio loader.

http://irrlicht.sourceforge.net/phpBB2/ ... 35&start=0

With this you can open the 3dw files directly (with terrain splating)
crivipro
Posts: 20
Joined: Tue Nov 25, 2008 7:17 pm

Yes, is great but...

Post by crivipro »

The thing is I can't make collisions, I know that I must use OctTreeTriangleSelector but I can't get the mesh. After load the model with:

Code: Select all

	C3DWScene c3dw;
	c3dw.load(device, "track.3dw", true, true);
How I can get the mesh, like MyMesh->getMesh(0)?

That's all I need now...Thanks everybody!
Post Reply