Next step in my project

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
JRS
Posts: 45
Joined: Tue Jun 03, 2008 10:00 am
Location: Universität Heidelberg

Next step in my project

Post by JRS »

After the radar works the next problem appears :(

First I'll describe my project a little bit.

I have real satellite data of a terrain an want to visualize it.
The data is a lot of stuff like hight, boundary, landuse... First, of course, I took a look at hight and made an heightmap out of some points that I have. I calculated height for each pixel, write it into a buffer16[] and then give it directly to arras TSTerrainSceneNode() via SetHeight()
Now I took a part of my terrain (because most was absolutly plane) and it is 8000x8000 pixel, I scaled it to 1000x1000 just for runtime while calculating height for each pixel.
It all works but looks not really nice.

So after I added the radar for orientation I now want to add realistic water
http://irrlicht.sourceforge.net/phpBB2/ ... sc&start=0

For this I read out another data (WaterPoly) that gives me polygons for every waterpart.
I wrote an algorithm that writes buffer16[] again and gives back a 1 if there is water, otherwise a 0.
Based on this I am able to create a "watermap" which is white everywhere, where water should be. Or I could give the buffer16[] array directly to the program.

How is it possible to add Waternodes based on my information?
Any ideas?

Thank you very much!![/url]
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Well you make your water mesh from the polys you have and then apply the necessary things to make it look like water; reflection, refraction, waves etc.

If you look at the way Elvman did the Realistic Water Scene Node you should be able to see how you can swap in your water mesh instead of the one he uses (which i imagine is just a large grid).
Image Image Image
JRS
Posts: 45
Joined: Tue Jun 03, 2008 10:00 am
Location: Universität Heidelberg

Post by JRS »

Well, thanks!

I'll try. Sorry for the questions but I'm not into making water at the moment...
But I will be soon ;)
Then I'll be back
JRS
Posts: 45
Joined: Tue Jun 03, 2008 10:00 am
Location: Universität Heidelberg

Post by JRS »

Ok,

based on example 8 I now have this code:

Code: Select all

IAnimatedMesh mesh = smgr.GetMesh(
            path + "terrain-heightmap.bmp");

            mesh = smgr.AddHillPlaneMesh("myHill",
            new Dimension2Df(20, 20),
            new Dimension2D(90, 90), new Material(), 1,
            new Dimension2Df(0, 0),
            new Dimension2Df(10, 10));

            ISceneNode water = smgr.AddWaterSurfaceSceneNode //!!!!(mesh.GetMesh(0), 3.0f, 300.0f, 30.0f, null, 0);

            water.Position = new Vector3D(5000, 50, 5000);
            water.Scale = new Vector3D(15, 5, 15);
            water.SetMaterialFlag(MaterialFlag.LIGHTING, false);

            water.SetMaterialTexture(0, driver.GetTexture(path + "water.jpg"));
            water.SetMaterialTexture(1, driver.GetTexture(path + "terrain-texture.jpg"));

            water.SetMaterialType(MaterialType.REFLECTION_2_LAYER);
But what I don't understand is
water.Scale = new Vector3D(15, 5, 15);
Is the height the height of the waves? If not, I don't see the use of a 3DScale for water...

And how could I do this in my example? For every poly I should set a mesh?
But meshes are always rectangles or am I wrong? So the problem is, that my polys are no rectangles...
And water is just visible because it is higher than the terrain, isn't it? So if there isn't a good coast there will be a problem, or not?

So I have the vertex of a polygon. Now I have find a rectangle around my polygon (what is not difficult) and hope that the terrain is deeper than the water only there where water should be?
Last edited by JRS on Fri Aug 01, 2008 9:09 am, edited 1 time in total.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

The scale is the scale of the node. Obviously the person who wrote the code wanted to increase the size of the water.

Put all of your polys into one mesh, i don't know how Elvman represents his mesh, you need to check his source to find this out and basically replicate it. Meshes are not always rectangles... that's mad... think of the animated meshes in the tutorials.. sydney... the dwarf.. are they rectangles? Nope! They're still meshes though ;)

I'm not sure what you mean about your terrain and coast...
Image Image Image
JRS
Posts: 45
Joined: Tue Jun 03, 2008 10:00 am
Location: Universität Heidelberg

Post by JRS »

Well, I think that I've got another problem:

It looks like that my algorithm to check whether a given point is inside or outside the given polygon doesn't work correctly.

I thought that the algorithm is to check whether a given point is on the "right hand side" of the nearest vector connecting two vertices of this polygon (of course this vector should be a side of the polygon)... And it seems not to work correctly... :?

So I wonder if there's any algorithm in Irrlicht to do this. I couldn't find any classes for polygons or something like that (except for rectangles, of course), or if anyone has any idea how to do this.

Any suggestion?


P.S. about terrain and coast I meant that the terrain at the position where there's water should be somewhat deeper, but our terrain is somewhat too "flat" to be able to determine directly where the water is...
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

If your terrain is too flat could you not scale it up on the y axis to make it deeper?

In irrlicht polygons are just triangles (i don't think it deals with any polys with more sides anyway...), look at triangle3df, it's probably got a function to find it a point is inside it.
Image Image Image
Post Reply