moving water

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
WWW
Posts: 26
Joined: Thu Oct 04, 2007 1:41 pm

moving water

Post by WWW »

Hi,
Im new in irrlicht and i need to know how can i simulate a moving water (like a river).i was thinking to someting like moving the water texture but i don't know how :(
Sorry for my bad english
Please help me :?
WWW
Posts: 26
Joined: Thu Oct 04, 2007 1:41 pm

Post by WWW »

No one can help me :( :( :(
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Have you seen the waterscenenode in one of the tutorials. With that you can have a moving water surface, the surface moves with waves.

It's pretty good and may well fit your needs so check it out.
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

First of all, learn patience. Why do you think that you receive answers in about 2 hours?
Next thing: What did you achieve as of now? As you see going through the tutorials would reveal much of Irrlicht's features. Maybe you find something useful in there.
Anyway, for a river some texture animator (either the one from Irrlicht or a custom one based on Texture matrices) might be what you need. Check that one and ask again if you tried it but did not succeed.
WWW
Posts: 26
Joined: Thu Oct 04, 2007 1:41 pm

Post by WWW »

thanks for your answers, i saw all the irrlicht tutorials but none of them is what i need.All i need is to move the texture (with TextureMatrix() i think :roll: ) but i don't understand how to use that function.
Can some one show me how to use TextureMatrix ?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You get the proper matrix from the material you want to alter (check SMaterial for the method to get it) and change the values accordingly.
WWW
Posts: 26
Joined: Thu Oct 04, 2007 1:41 pm

Post by WWW »

Hi, I don't understand textureMatrix() function :oops:
I have this little code :
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")

int main()
{
IrrlichtDevice *device =
createDevice(video::EDT_DIRECT3D8 , core::dimension2d<s32>(640, 480),
16, false,false);

video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
////water///
scene::ISceneNode* node = 0;
scene::IAnimatedMesh* mesh = smgr->addHillPlaneMesh("hill",
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(0,7,0));
node->setMaterialTexture(0, driver->getTexture("../../media/water.jpg"));

///Light////
node = smgr->addLightSceneNode(0, core::vector3df(0,0,0),
video::SColorf(1.0f, 0.6f, 0.7f, 1.0f), 600.0f);
scene::ISceneNodeAnimator* anim = 0;
anim = smgr->createFlyCircleAnimator (core::vector3df(0,150,0),250.0f);
node->addAnimator(anim);
anim->drop();

///Camera///
scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
camera->setPosition(core::vector3df(-50,50,-150));
device->getCursorControl()->setVisible(false);

while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, 0);
smgr->drawAll();
driver->endScene();

}

device->drop();
return 0;
}

can some one show me how to move texture "water.jpg" in that code(to simulate flow of a river)
Please help me because i need that. Thanks.
WWW
Posts: 26
Joined: Thu Oct 04, 2007 1:41 pm

Post by WWW »

No one can't show me a code ? :cry:
Please help me i need it very much.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

1. Don't use the water scene node
2. get Material from a scene node you have the model of the river in
3. getTextureMatrix of layer 0
4. change the translation of the texture coords by using setTextureTranslate() on that matrix.
WWW
Posts: 26
Joined: Thu Oct 04, 2007 1:41 pm

Post by WWW »

THANKS AGAIN FOR YOUR ANSWERS
I did this :

Code: Select all

river->getMaterial(0).getTextureMatrix(0).setTextureTranslate(x,y);
y=y+0.001f;
x=x+0.001f;
but nothing happend, the texture is't moving , what i made wrong? :shock:
EDIT: that code is updating every step(i put it in while loop)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Try rotation and scaling first. There seems to be some problems with translation.
WWW
Posts: 26
Joined: Thu Oct 04, 2007 1:41 pm

Post by WWW »

I don't need to rotate or scale the texture, I need to move it :( .
I think it's a bug with setTextureTranslate().
Anyway thanks again for your help, Hybrid.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Man, you should try if your code works. And red my post again, I mentioned 'problems', that's sort of a bug, isn't it?
IrrGamer
Posts: 22
Joined: Fri Oct 05, 2007 3:30 am

Post by IrrGamer »

I think he wants to animate a mesh to make it look like its moving water.

The EASIEST way to do this would be creating a 3D model of it. I know you can use 3D World Studio to create a terrain, add water etc and load it on to Irrlicht. There's even a tutorial on it.

It's not easy animating water using a 3D engine- better to create a base model, load it and add the "water" model to the cordinates you want and scale it to fit.

It's the easiest way if you know how to model. Using transformers on seperate loaded models might get a bit messy, so transforming the model itself on 3DS Max or whatever might be what your looking for.
Post Reply