About Store Forum Documentation Contact



Post Reply 
World.areaActive
Author Message
Brainache Offline
Member

Post: #1
World.areaActive
Hey there,

The new funcitons look like just what I needed, but I am a little confused on how to use the areaActive method...

Below is is the snippet of what I've tried... I know areaActive returns Grid<Area> but I'm confused on how to utilize it to get to to the actual Area... Can you clarify for me please?

GridGame::Area *area = Game::World.areaActive(VecI2(0,0));

if (area)
{
MeshGroup *mg = area->mshg();
}


Thanks
09-07-2009 04:49 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
Re: World.areaActive
Code:
if(Grid<Game::Area> *grid=Game::World.areaActive(VecI2(0,0)))
{
    Game::Area &area=(*grid)();
    if(Game::Area::Data *data=area.data())
    {
         MeshGroup &mshg=data->mshg();
    }
}

remember that each MeshPart has only Mshr (rendering version set), so if you want to access the mesh you need to create a temporary MeshBase from the Mshr, using the following:

Code:
struct MeshBase
{
   MeshBase& create(Mshr     &mshr                                                          ); // create from Mshr
   ...
09-07-2009 05:57 PM
Find all posts by this user Quote this message in a reply
Brainache Offline
Member

Post: #3
Re: World.areaActive
Is there a way to get all areas of the world?

ie:

GridGame::Area *area = Game::World.areaActive(VecI2(0,0));

That brings back one terrain chunck... ( Is the VecI2 world coords? or area grid goords?)
how can I get all chunks... whether they are active or not?

Thanks!
09-08-2009 02:10 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
Re: World.areaActive
VecI2 is Integer based so its area grid coords.

You can't get all areas at once in the memory, because they will not fit into it (it's too big).

you need to call at least once Game::World.update(..) at another position,
this will unload previous areas, and load only those areas which are around the given position.
after making the 'update' call you can access those areas.
09-08-2009 09:33 AM
Find all posts by this user Quote this message in a reply
Brainache Offline
Member

Post: #5
Re: World.areaActive
Gotya - figured it was grid based... but... since "World.areaActive(VecI2(0,0))" brings back only the active chunk - it confused my why it gets passed the VecI2...

So.. If I were to call World.areaActive( VecI2(1,0) ) - would it bring back another chunk? ( if so - do I still need to call World.update(pos)? )

Also - Is there a way to tell how many chunks exist?
ie: something like...

gridx = world.areaCountX();
gridy = world.areaCountY();
for (x=0;x<gridx;x++)
for (y=0;y<gridy;y++)
{
area = Wrold.areaActive( VecI2(x,y) );
}

( at work so cant test )

thanks!
09-08-2009 02:01 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
Re: World.areaActive
Quote:So.. If I were to call World.areaActive( VecI2(1,0) ) - would it bring back another chunk? ( if so - do I still need to call World.update(pos)? )
when you call World.update it will load only a small number of area's aroung the position that you give, the range is specified in the Game::World.init() method

World.areaActive( VecI2(0,0) ) gets area of 0,0 area coordinates
World.areaActive( VecI2(1,0) ) gets area of 1,0 area coordinates

check the World Editor, enable view/cursor position information (it will display the coordinates of the area)

Quote:Also - Is there a way to tell how many chunks exist?
no,
you can either check it in World Editor (view/cursor position information)
or
analyze the "world\game\area\x,y" files (analyze the min and max of x,y file names)
check to "resources\worlds" documentation, and check the output of your world folder after building.
09-08-2009 05:04 PM
Find all posts by this user Quote this message in a reply
Brainache Offline
Member

Post: #7
Re: World.areaActive
Thanks! that clears up alot for me.
09-08-2009 09:30 PM
Find all posts by this user Quote this message in a reply
Post Reply