Problem applying texture for water surface

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
byelan74
Posts: 28
Joined: Sat Dec 24, 2005 11:29 am

Problem applying texture for water surface

Post by byelan74 »

I applied the texture for water surface. However, it didn't display correctly. All I see is the black surface. Any solution are welcome

Code: Select all

scene::ISceneNode* node = 0;
	mesh = smgr->addHillPlaneMesh("water_plane",
		core::dimension2d<f32>(20,20),
		core::dimension2d<s32>(40,40), 0, 0,
		core::dimension2d<f32>(0,0),
		core::dimension2d<f32>(10,10));

	node = smgr->addWaterSurfaceSceneNode(mesh->getMesh(0), 3.0f, 300.0f, 30.0f);
	node->setPosition(core::vector3df(2800,-80,1500));
	node->setScale(core::vector3df(6.0f, 1.0f, 4.0f));

	node->setMaterialTexture(0,	driver->getTexture("media/water.jpg"));
	node->setMaterialTexture(1,	driver->getTexture("media/stones.jpg"));

	node->setMaterialType(video::EMT_REFLECTION_2_LAYER);
Image
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

You never connected your mesh.
This should work wrote: mesh = smgr->addHillPlaneMesh("water_plane",
core::dimension2d<f32>(20,20),
core::dimension2d<s32>(40,40), 0, 0,
core::dimension2d<f32>(0,0),
core::dimension2d<f32>(10,10));

scene::ISceneNode* node = 0;
node = smgr->addAnimatedMeshSceneNode(water_plane);

node = smgr->addWaterSurfaceSceneNode(mesh->getMesh(0), 3.0f, 300.0f, 30.0f);
node->setPosition(core::vector3df(2800,-80,1500));
node->setScale(core::vector3df(6.0f, 1.0f, 4.0f));

node->setMaterialTexture(0, driver->getTexture("media/water.jpg"));
node->setMaterialTexture(1, driver->getTexture("media/stones.jpg"));

node->setMaterialType(video::EMT_REFLECTION_2_LAYER);
Now, water_plane should actually be the name of your land mesh. But this should still work.
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
byelan74
Posts: 28
Joined: Sat Dec 24, 2005 11:29 am

Post by byelan74 »

thanks a lot...but it stay th same.

it's not work.
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

byelan74 wrote:thanks a lot...but it stay th same.

it's not work.
Have you renamed "water_plane" to the name of your main world mesh??

Ok, as an example:
This is my main world mesh loader:

Code: Select all

scene::IAnimatedMesh* q3levelmesh = smgr->getMesh("media/old_Homeworld.dmf");
Here is the water plane I have:

Code: Select all

	q3levelmesh = smgr->addHillPlaneMesh("myHill",
		core::dimension2d<f32>(20,20),
		core::dimension2d<s32>(50,50), 0, 0,
		core::dimension2d<f32>(0,0),
		core::dimension2d<f32>(10,10));
		
scene::ISceneNode* node = 0;
node = smgr->addAnimatedMeshSceneNode(q3levelmesh);

    node= smgr->addWaterSurfaceSceneNode(q3levelmesh->getMesh(0), 3.0f, 300.0f, 30.0f);
	node->setPosition(core::vector3df(1700,-1550,-440));

	node->setMaterialTexture(0,	driver->getTexture("media/water.jpg"));
	node->setMaterialTexture(1,	driver->getTexture("media/stones.jpg"));

	node->setMaterialType(video::EMT_REFLECTION_2_LAYER);
This is how it is done in my game and it works.
You have to attach it to your main mesh.
Also, what renderer are you using?
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
byelan74
Posts: 28
Joined: Sat Dec 24, 2005 11:29 am

Post by byelan74 »

it work!!!

thanks a lot.............................................
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

You're welcome.
Now the fun of figureing out how to make it look with the right wave heights and such.
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
Post Reply