mixpro
Member
|
[SOLVED]Reference dynamically added object in a world
Hi,
I'm using for example :
Code:
Game.World.objCreate(*obs_1,Matrix(obs_1->scale3(), tmpLastPos));
to add object to a world , but for certain objects i need to get a reference to them , so i can do other things specific to them , like getting pos, accessing params , accessing mesh ...
Game.World.objCreate doesn't return a pointer or reference .
how can i do that ?
note: i purchased ineisis source code to see how he did that , but looks like he isn't using Game.World .
which leads to my next question :
why would someone prefers not to use Game.World ?
(This post was last modified: 05-07-2016 07:26 PM by mixpro.)
|
|
05-07-2016 01:49 PM |
|
Tottel
Member
|
RE: Reference dynamically added object in a world
Hi there, you can use Game.World.objCreateNear, which return a Game.Obj* object. You can then use CAST(ObjectClass, pointer to object), to cast it to your own type and access it. It will still be added to the world manager and used just like objCreate.
Game.World should be fine for more of your needs. But, it does all of the updating, drawing and creating/deleting objects for you. If you want to have more control over the process, then you could consider to not use it.
|
|
05-07-2016 03:08 PM |
|
mixpro
Member
|
RE: Reference dynamically added object in a world
(05-07-2016 03:08 PM)Tottel Wrote: Hi there, you can use Game.World.objCreateNear, which return a Game.Obj* object. You can then use CAST(ObjectClass, pointer to object), to cast it to your own type and access it. It will still be added to the world manager and used just like objCreate.
Game.World should be fine for more of your needs. But, it does all of the updating, drawing and creating/deleting objects for you. If you want to have more control over the process, then you could consider to not use it.
Thanks can't believe i missed that in the header of world ![pfft pfft](images/smilies/pfft.gif) .
|
|
05-07-2016 07:26 PM |
|