PnP TerrainCreator - Forum

The PnP TerrainCreator Forum
It is currently Sat Sep 23, 2017 5:51 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Bug in Ogre scene export
PostPosted: Sun Feb 28, 2010 2:37 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 8:24 pm
Posts: 64
Location: Denmark
I noticed that the scene export does not take the scale factor into account.

It works great when using a factor of 1, but - as I wanted more performance, I set the terrain size to be 256+1 with a scale factor of 4, and it does not work. :)

The scene exporter gave me this:
<position x="170.436996" y="655.959351" z="-44.172516" />

The normal object exporter gave me this:
X 170.436996
Y 655.959351
Z-300.172516
(After swapping Y and Z and flipping the sign of Z)

As you can see, the Z component was adjusted by 256 units.
It should have been adjusted by (256 * 4) : 1024.
And the position would be:
<position x="170.436996" y="655.959351" z="724.172516" />

And then it can be used, after offsetting the position to the centre, like this:
Code:
   Ogre::Vector3 adjust(512,0,512);
   Ogre::Vector3 house1_pos(170.436996, 655.993286, 724.172516);
   house1_pos -= adjust;


But, since the Ogre terrain is now zero at the centre, it really should be:
x -= (sector detail size * detail element size) / 2;
z += (sector detail size * detail element size) / 2;

Which would give me this position:
<position x="-342.436996" y="655.959351" z="212.172516" />
And I don't need to offset it in code.

So, after flipping y and z, and flipping the sign of the new z, subtract (sector detail size * detail element size) / 2 from x, and add (sector detail size * detail element size) / 2 to z.

Of course, this assumes that you choose a factor of 4 when exporting the terrain heightmap.

I am not really sure how to set it up on the exporter.

But it allows you to use a detail size of 257 (256+1) and a terrain size of 1024 (detail element size * sector detail size).
Code:
   defaultimp.terrainSize = 257;
   defaultimp.worldSize = 1024;


That yields much better performance.
Especially when using paging.
For larger terrains, this is a must.
Otherwise you'll crash because you run out of GPU memory after loading page number 16..

Let me know if I didn't manage to explain the problem. :)

_________________
/* when invited to a free lunch, you should not complain about the quality of the caviar */


Top
 Profile  
 
 Post subject: Re: Bug in Ogre scene export
PostPosted: Sun Feb 28, 2010 2:49 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 8:24 pm
Posts: 64
Location: Denmark
One more bug for you:
The height map exporter (RAW) does not remember the scale factor!

The texture map exporter does..

_________________
/* when invited to a free lunch, you should not complain about the quality of the caviar */


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron