Realistic water scene node

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
elvman
Posts: 253
Joined: Sun Sep 17, 2006 9:37 am
Location: Riga, Latvia
Contact:

Post by elvman »

[*] Refraction is supported
[*] setClipPlane can be disabled, but the result can be a little bit cracky (you will have to wait for Irrlicht 1.4).
[*] I haven't seen the problem with skyboxes (I will check it out). It would be much better if Irrlicht supported CubeMaps!
andrei25ni
Posts: 326
Joined: Wed Dec 14, 2005 10:08 pm

Post by andrei25ni »

The code is not compiling under 1.3.1 :

Code: Select all

18 cpp\RealisticWater.cpp no matching function for call to `irr::scene::ISceneManager::addHillPlaneMesh(const char[15], irr::core::dimension2d<irr::f32>&, irr::core::dimension2d<irr::u32>)' 

312 cpp\main.cpp `Water' undeclared (first use this function)
312 cpp\main.cpp `width' undeclared (first use this function) 
312 cpp\main.cpp `height' undeclared (first use this function) 
312 cpp\main.cpp `VideoDriver' undeclared (first use this function)
312 cpp\main.cpp `Irrlicht' undeclared (first use this function)    
:roll:
elvman
Posts: 253
Joined: Sun Sep 17, 2006 9:37 am
Location: Riga, Latvia
Contact:

Post by elvman »

In irrlicht 1.3.1 you will have to change the line 18 in .cpp file to this:

Code: Select all

scene::IAnimatedMesh* WaterMesh=SceneManager->addHillPlaneMesh("realisticwater",Size,core::dimension2d<s32>(1,1));
312 cpp\main.cpp `Water' undeclared (first use this function)
312 cpp\main.cpp `width' undeclared (first use this function)
312 cpp\main.cpp `height' undeclared (first use this function)
312 cpp\main.cpp `VideoDriver' undeclared (first use this function)
312 cpp\main.cpp `Irrlicht' undeclared (first use this function)
You can do it like this:

Code: Select all

RealisticWaterSceneNode* Water=new RealisticWaterSceneNode(SceneManager, 256.0f, 256.0f,		VideoDriver->getTexture("data/waterbump.png"),Irrlicht->getTimer());
VideoDriver is the pointer to your IVideoDriver and Irrlicht is the pointer to your IrrlichtDevice.
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

So here is what it looks like to me:
Image

Here is the code I used:

Code: Select all

 
RealisticWaterSceneNode* pWater;

pWater = new RealisticWaterSceneNode(irrSceneMan, 2100.0f, 2100.0f, irrDriver->getTexture("data/textures/env/waterbump.png"),irrDevice->getTimer());

elvman
Posts: 253
Joined: Sun Sep 17, 2006 9:37 am
Location: Riga, Latvia
Contact:

Post by elvman »

It looks like your backbuffer is smaller than the RTT of the water. You will have to do it like this:

Code: Select all

RealisticWaterSceneNode* pWater;

pWater = new RealisticWaterSceneNode(irrSceneMan, 2100.0f, 2100.0f, irrDriver->getTexture("data/textures/env/waterbump.png"),irrDevice->getTimer(),core::dimension2di(256,256));
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Hmm, nope, using that exact code I got the same result as the image. Also, now using this code gives me an error in IUnknown.h

Code: Select all

bool drop()
		{
			_IRR_DEBUG_BREAK_IF(ReferenceCounter <= 0) // someone is doing bad reference counting.

			--ReferenceCounter;
			if (!ReferenceCounter)
			{
				delete this;
				return true;
			}

			return false;
		}
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

Hi Elvman.

I was able to successfully implement your codes into my demo!
I've had only a texture problem (a file as DDS extension.) Converted it as a PNG file.

Here some screenshots of the implementation (Developping with DEVCPP with IRRLICHT 1.3.1)
Image
Image

I noted your nickname and your site for the water rendering in the text file accompagning my demo.
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

Just found out something weird... Refraction seem to fade on certain angles of the camera (X angles)

I've played in my demo and seen that if im checing the water in the direction of my sun (skybox); I see the refraction.

But, if I'm turning around 180 degrees, the refraction is not there anymore.

Can you check this? I'm using the FPSCamera can this have an incidence over this problem?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

As i said in Christian's project thread there's something iffy about the reflection in the first screenshot there; where the sky is reflecting instead of the bottom of the little hill.. any ideas Elvman? I suppose that could be to do with the clipping planes maybe...
Image Image Image
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Yep most definately. If you far enough upward the water below you stops refracting. But I did manage to implement it :)

Image
elvman
Posts: 253
Joined: Sun Sep 17, 2006 9:37 am
Location: Riga, Latvia
Contact:

Post by elvman »

The first srceenshot got problems with clip planes, but that is already fixed. I will try to fix all other problems today.
andrei25ni
Posts: 326
Joined: Wed Dec 14, 2005 10:08 pm

Post by andrei25ni »

Hey elvman, thank you very much for your quick response.
But I still can't get it to compile, I get :

Code: Select all

RealisticWater.o(.text+0x0):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::RealisticWaterSceneNode(irr::scene::ISceneManager*, float, float, irr::video::ITexture*, irr::ITimer*, irr::core::dimension2d<int>, irr::scene::ISceneNode*, int)'
main.o(.text+0x100):main.cpp: first defined here
RealisticWater.o(.text+0xa80):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::RealisticWaterSceneNode(irr::scene::ISceneManager*, float, float, irr::video::ITexture*, irr::ITimer*, irr::core::dimension2d<int>, irr::scene::ISceneNode*, int)'
main.o(.text+0xb80):main.cpp: first defined here

RealisticWater.o(.text+0x1508):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::~RealisticWaterSceneNode()'
main.o(.text+0x1608):main.cpp: first defined here
RealisticWater.o(.text+0x1722):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::~RealisticWaterSceneNode()'
main.o(.text+0x1822):main.cpp: first defined here
RealisticWater.o(.text+0x193a):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::~RealisticWaterSceneNode()'
main.o(.text+0x1a3a):main.cpp: first defined here
RealisticWater.o(.text+0x1b52):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::OnRegisterSceneNode()'
main.o(.text+0x1c52):main.cpp: first defined here
RealisticWater.o(.text+0x1ba2):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::OnAnimate(unsigned int)'
main.o(.text+0x1ca2):main.cpp: first defined here
RealisticWater.o(.text+0x1ef0):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::render()'
main.o(.text+0x1ff0):main.cpp: first defined here
RealisticWater.o(.text+0x1ef6):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::getBoundingBox() const'
main.o(.text+0x1ff6):main.cpp: first defined here
RealisticWater.o(.text+0x1f1c):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::OnSetConstants(irr::video::IMaterialRendererServices*, int)'

main.o(.text+0x201c):main.cpp: first defined here
RealisticWater.o(.text+0x2318):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::setWindForce(float)'
main.o(.text+0x2418):main.cpp: first defined here

RealisticWater.o(.text+0x232a):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::setWindDirection(irr::core::vector2d<float>)'
main.o(.text+0x242a):main.cpp: first defined here
RealisticWater.o(.text+0x2356):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::setWaveHeight(float)'
main.o(.text+0x2456):main.cpp: first defined here
RealisticWater.o(.text+0x2368):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::setWaterColor(irr::video::SColorf)'
main.o(.text+0x2468):main.cpp: first defined here

RealisticWater.o(.text+0x238e):RealisticWater.cpp: multiple definition of `RealisticWaterSceneNode::setColorBlendFactor(float)'
main.o(.text+0x248e):main.cpp: first defined here
[/size]

My header from main.cpp looks like this :

Code: Select all

#include <irrlicht.h>

#include <iostream>
#include <audiere.h>

#include <irrXML.h>
#include "windows.h"
#include <string>

using namespace irr;
using namespace io;
using namespace scene;
using namespace core;
using namespace video;
using namespace gui;
using namespace std;
using namespace audiere;
#include "RealisticWater.cpp"

#pragma comment(lib, "Irrlicht.lib")
#pragma comment(lib, "audiere.lib")
I have no ideea what to search for ,in order to fix.

Cheers.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You shouldn't include .cpp files :?
fmx

Post by fmx »

elvman
you've done a great job with this!
Thanks a lot!


andrei25ni

Code: Select all

#include "RealisticWater.cpp" 
as hybrid says, this line of code looks really strange...
I can't really help you any more than this, because I haven't tried to compile it for myself yet :(
andrei25ni
Posts: 326
Joined: Wed Dec 14, 2005 10:08 pm

Post by andrei25ni »

Thanks alot hybrid, that did it.
It now compiles.
That's what happens when a modeler tries to do code... :shock:

Sorry to elvman for bumping his topic.

Cheers.
Post Reply