About Store Forum Documentation Contact
Donations:
327$/mo



Post Reply 
Change area heightmap
Author Message
kulesz Offline
Member

Post: #1
Change area heightmap
Hi,

After few nights with the code I can't get it to work. Esenthel, could you write a sample code, how to change (and add) the area heightmap in the realtime, please?
07-02-2011 11:03 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Change area heightmap
After you've created Mesh from Edit::Heightmap, just replace it with Game::Area::Data::mesh()
And do the same with Phys (create it from mesh, use MeshBase::createPhys(src_mesh) then create phys from that MeshBase).

BTW: I am thinking of adding simplified version of Ineisis Online sources to the Company license and above (with terrain/material/grass editing, server/client/launcher)
07-02-2011 11:18 AM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #3
RE: Change area heightmap
Game::Area::Data doesn't have a data member :-)

However, such thing as simplified version of terrain/material/grass editing would be nice.
07-02-2011 06:03 PM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #4
RE: Change area heightmap
(07-02-2011 11:18 AM)Esenthel Wrote:  BTW: I am thinking of adding simplified version of Ineisis Online sources to the Company license and above (with terrain/material/grass editing, server/client/launcher)

Great idea and very useful thing.
Editing terrain in realtime also interests me.

I intend to buy license soon.
07-02-2011 07:27 PM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #5
RE: Change area heightmap
Agree :-) Too bad, it'd be for company license - I was planning to buy a personal one. If I'd get the terrain editing to work, I would buy it instantly :-)
07-02-2011 08:07 PM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #6
RE: Change area heightmap
As for now, it works with something like this (closer to the license :-)):
Code:
Edit::Heightmap *hm=new Edit::Heightmap;
hm->create(128,&m1,true,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

Mesh *m_temp = new Mesh;
PhysBody *p_temp = new PhysBody;
hm->build(*m_temp, 0,10,false,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

p_temp->parts.New().createMesh(*m_temp); // create physical body from 'mesh'

Game::World.areaActive(VecI2(0,0))->data->data()->mshg.meshes(0).create(*m_temp);
Game::World.areaActive(VecI2(0,0))->data->data()->phys()=*p_temp;
Game::World.areaActive(VecI2(0,0))->data->data()->actor().create(*p_temp);

However it's kinda slow sometimes. Is there some way to optimize it? Do I need to create physics after every littel height change? In Ineisis it works quite fast.

And second question: code above works only for pre-generated (in WE) areas. How to add new areas in the application?
(This post was last modified: 07-03-2011 07:44 PM by kulesz.)
07-03-2011 07:44 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: Change area heightmap
ineisis has only 32 hm res and some other optimizations
07-03-2011 07:54 PM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #8
RE: Change area heightmap
Well, with 32 hm res it works like a charm smile
But when I change
Code:
Game::World.areaActive(VecI2(0,0))
to
Code:
Game::World.areaActive(VecI2(0,1))
the app crashes, probably because of the fact, that world has only one area. How can I add the area to the world and save it afterwards?
(This post was last modified: 07-03-2011 08:36 PM by kulesz.)
07-03-2011 08:36 PM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #9
RE: Change area heightmap
I tried to do:
Code:
Game::WorldManager::AreaState a01;
a01.set(VecI2(0,1), Game::AREA_LOAD);   // or AREA_ACTIVE too
Memc<Game::WorldManager::AreaState> as;
as.add(a01);

Game::World.areaSetState(as, false);
but it keeps crashing, when I try to access area at (0,1)...
(This post was last modified: 07-03-2011 09:43 PM by kulesz.)
07-03-2011 09:43 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #10
RE: Change area heightmap
first do
game world init world_manual
game world create or new

then Game::World.areaSetState(as, ..);

then Area::getData
07-05-2011 03:41 PM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #11
RE: Change area heightmap
Hmm...
Code:
In Init():

Game::World.init(Game::WORLD_MANUAL);
Game::World.Create("world/empty.world",worldSettings);
Game::World.New  ("world/empty.world");
Game::World.setObjType(Items  ,OBJ_ITEM).setObjType(Statics,OBJ_STATIC).setObjType(Players,OBJ_PLAYER);
Game::World.update(Cam.at);

And in Update():

Mesh *m_temp = new Mesh;
hm->build(*m_temp, 0,10,false,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

Game::WorldManager::AreaState as1;
as1.set(VecI2(0,0), Game::AREA_ACTIVE);
Memc<Game::WorldManager::AreaState> ases;
ases.add(as1);

Game::World.areaSetState(ases, false);

Game::World.areaActive(VecI2(0,0))->data->data()->mshg.meshes(0).create(*m_temp);

crashes in the last line...
07-05-2011 05:55 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #12
RE: Change area heightmap
data->data()->
Area::getData
07-05-2011 06:22 PM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #13
RE: Change area heightmap
Works now :-) Thanks ;-)
07-05-2011 07:42 PM
Find all posts by this user Quote this message in a reply
Post Reply