About Store Forum Documentation Contact
Donations:
140$/mo



Post Reply 
Grass
Author Message
kulesz Offline
Member

Post: #1
Grass
Any chance for some tutorial/code snippet how to use Game::Area::Data::GrassObj for in-game plants placing?
09-25-2011 08:45 PM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #2
RE: Grass
I've got another question :-)

For now I'm placing grass elements with a piece of code:
Code:
Game::ObjParamsPtr object = Game::Objs.ptrRequire("Data/Obj/plant/Grass/0.obj");
object->type(true, "OBJ_STATIC");
Game::Obj *obj=Game::World.objCreateNear(*object, Matrix(object->scale(), Vec(meshX, meshY, meshZ)));

What can be changed here, to assure maximum performance? How can I use the ame::Area::Data::GrassObj feature?
10-27-2011 06:11 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: Grass
just setup game::area::data::grass_objs,grass_objs_box
10-27-2011 12:52 PM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #4
RE: Grass
So, instead of creating as show above, I should make and fill the GrassObj object and then add it to the grass_objs in area, yes?
And what with the grass_objs_box?
10-27-2011 05:15 PM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #5
RE: Grass
I'm doing something like this:
Code:
CustomWorldAreaData * AreaData = CAST(CustomWorldAreaData, Game::World.areaLoaded(VecI2(x, z))->data());

Game::Area::Data::GrassObj &grassObj = AreaData->grass_objs.New();
grassObj.mesh = Meshes("Obj/plant/Grass/6.mesh");

for (int u=0; u<100; u++)
{
   double gxx = RandomF(0, 128);
   double gzz = RandomF(0, 128);

   grassObj.instances.New().matrix = Matrix(1, Vec(gxx,0,gzz));
   AreaData->grass_objs_box.include(Vec(gxx,0,gzz));
}

But the grass do not show.
10-31-2011 10:51 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Grass
is 'x' and 'z' 0 , 0 ?

because grassObj.instances.New().matrix is in world coordinates (global)
not relative to area.

maybe the grass position is just below heightmap?

code looks fine, except for small bug in setting the box (you're not initializing it before the loop)

also remember that if you make the modification before loading the area, changes will get discarded
10-31-2011 06:35 PM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #7
RE: Grass
Hmm, x and z are 0, everything is placed in the area(0,0), so it should be visible. There are no heightmap (flat plane), so they cannot be under.
I'm initializing box with zero() now.
10-31-2011 06:45 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
RE: Grass
do you have D.grassRange set correctly?
if you put grass from the Editor instead of code, does it display?
10-31-2011 06:51 PM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #9
RE: Grass
Yes, putting grass in WE works fine. Grass range is set to 200, density to 1.
I'm generating my areas dynamically (not from WE), heightmap, actors etc. are created in code. Maybe this is the issue?
10-31-2011 06:56 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #10
RE: Grass
ineisis also works like that (fully dynamically) and it works fine,
perhaps you have some other bug in codes.
10-31-2011 07:13 PM
Find all posts by this user Quote this message in a reply
Post Reply