Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / A question of Terrains.

Author
Message
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 31st Oct 2008 10:53 Edited at: 31st Oct 2008 11:00
I have the requirement to be able to move my terrain while the game is running.

This can not be done with the current Terrain objects within DSDK so I have to create my own Matrix terrain from scratch.

I am having trouble understanding how normal terrain gets created with the Terrain commands ...... it just does not make sense to me. I hope some one can help me understand where my logic is flawed in my understanding. I require this understanding so that I can reverse my code back to using the default Terrain commands when the new DGDK SDK gets released (as it will have the required terrain x,y,z move functions).

Take a typical standard terrain in DSDK.

We have 2 typical pictures:
Hightmap.BMP , and it is a 256x256 pixel gray scale.
Texture.BMP , and it is a 512x512 pixel, 24 bit color.

When we use the dbSetTerrainHeightmap() function with the 256x256 pixel heightmap, it should produce one mesh point for every pixel.
We should get a terrain matrix that is made up of 256x256 nodes, and that means it is made up of 255x255 mesh squares.

Now the question.!!!!

How can the texture picture that happens to be 512x512 pixels in size be broken down into 255x255 matrix tiles, to be used to skin the terrain matrix.

Each matrix tile would have to be a small fraction larger than 2x2 pixels in size.
This does not make sense.

My logic tells me that the terrain texture bitmap would have to be 510x510 pixels in size, yet every example that i see is the 512x512 size.

This is driving me nuts ...... can any body please help me.

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 31st Oct 2008 12:07 Edited at: 31st Oct 2008 12:07
Because it can? You can use a 700x1337 texture and it should still work, the texels don't have to be accurate to the vertices. Plus it's generally better to use textures whose x/y/z resolution is a power of 2, so even if you were to use a 510^2 texture you'd gain nothing. If it bothers you that much you could always offset and scale the UV so it goes from xy: -0.5f/tileCountXY to 1.0f+0.5f/tileCountXY, where tileCountXY is a 2D vector.

sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 31st Oct 2008 12:44
Quote: "Because it can?"


Maybe my implied question was not clear enough. I am new to all this , so please be patient.

I am trying to duplicate the operation of creating a terrain with the terrain picture files, by using a matrix and skinning it.

I would like to use the same bitmap files with both approaches, and produce the same terrain. (I know I have to image the terrain in the y direction to make same results between the 2 approaches)

Where I am getting confused is the following.

If I use a heightmap of 256x256 and produce a terrain matrix of 255x255 terrain squares how do I skin it.

I would have to brake up the terrain texture with the
"dbPrepareMatrixTexture ( ID, ID, 255, 255 );"
and the break points for the matrix tiles would not be at the boundries between pixels of the texture file.

Am I understanding you correctly that a boundry for a terrain square texture does not have to be between pixels and the texturing will handle this correctly. If so then I am worrying about nothing.
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 1st Nov 2008 01:37 Edited at: 1st Nov 2008 01:53
Quote: "Am I understanding you correctly that a boundry for a terrain square texture does not have to be between pixels and the texturing will handle this correctly. If so then I am worrying about nothing. "


I have just tried it and things look to be OK, but it was just a simple and not accurate test.

This has highlighted a problem with the "Terrain" commands within the current Dark SDK.

When one creates a terrain using the "Terrain" commands, it looks like the inbuilt code actually chops off some of the terrain from the top edge.

Using the same texture and heightmap in both set of tests.
Produce the same terrain by "Matrix" method.





Now creating the same terrain using the inbuilt "Terrain" method.



both images were captured with the camera rotated right by 90deg so in actuality the left side of the pictures are the top of the terrains.

It shows that creating the terrains using the inbuilt "Terrain" commands tends to cut off the top couple of terrain squares and square textures.

Now I can understand why I had so much trouble coupling "Terrain" based objects with matrix based support graphics like oceans and ocean bottoms.

Something for others to be careful of.

Login to post a reply

Server time is: 2024-11-25 05:46:30
Your offset time is: 2024-11-25 05:46:30