www.quadsoftware.com
FAQ  FAQ   Search  Search   Memberlist  Memberlist   Usergroups  Usergroups
Register  ::  Log in Log in to check your private messages


Post new topic  Reply to topic
 How to get position of zone « View previous topic :: View next topic » 
Author Message
takuhiro
PostPosted: Thu Apr 01, 2010 10:42 am    Post subject: How to get position of zone Reply with quote



Joined: 02 Dec 2009
Posts: 29

Hi.

Is there a method of acquiring the position of the zone?
It is not coordinates but indices.
The method was not found in iTerrainZone.

+---+---+---+
|0,0|1,0|2,0|
+---+---+---+
|0,1|1,1|2,1|
+---+---+---+
|0,2|1,2|2,2|
+---+---+---+
Back to top
View user's profile Send private message
ALicu
PostPosted: Thu Apr 01, 2010 12:03 pm    Post subject: Reply with quote



Joined: 12 Feb 2007
Posts: 1326

Hi,

If you know that your zones are in a grid (Grome allows any configuration), you can find the horizontal extent of your entire scene (iScene::GetGlobalBBox or if you have objects outside the zones, just go through all the scene zones and find their max and min extent on OX and OZ) and then (considering that each zone has the same size as TilesNo() * TileSize()) you can detect (based on zone size and its bounding box location inside scene extent) where in the grid the zone is (in what cell).

The SDK doesn't offer this information because in Grome you can place the zones in any cluster scheme so taking a grid coordinate doesn't apply.

Regards,
Adrian L.
Back to top
View user's profile Send private message
takuhiro
PostPosted: Fri Apr 02, 2010 4:37 am    Post subject: Reply with quote



Joined: 02 Dec 2009
Posts: 29

It has understood somehow.
I devise to acquire the position.

Thankyou.
Back to top
View user's profile Send private message
ALicu
PostPosted: Fri Apr 02, 2010 12:02 pm    Post subject: Reply with quote



Joined: 12 Feb 2007
Posts: 1326

Hi,

Let me know if you cannot manage to obtain it. The code should look something like this:

Code:

const t_float3 *scene_bbox = g_scene->GetGlobalBBox();
const float scene_min_x = scene_bbox[0].x;
const float scene_min_z = scene_bbox[0].z;

for(uint i=0; i<zones_no; i++)
{
   const t_float3 *zone_bbox = zone[i]->GetBBox();

   uint scene_pos_x = uint(round((zone_bbox[0].x - scene_min_x) / zone_size));

   uint scene_pos_z = uint(round((zone_bbox[0].z - scene_min_z) / zone_size));
}


Round is a rounding function to nearest integer. zone_size should be the same for all zones (TilesNo() * TileSize()).

This is just a pseudo code I wrote without testing but the real code should be very similar.

Regards,
Adrian
Back to top
View user's profile Send private message
takuhiro
PostPosted: Mon Apr 12, 2010 6:19 am    Post subject: Reply with quote



Joined: 02 Dec 2009
Posts: 29

The problem was fixed.
Thank you for sample.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

Jump to:  



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 vote in polls in this forum


Based on a template by Dustin Baccetti
Powered by phpBB © 2001, 2005 phpBB Group