About Store Forum Documentation Contact



Post Reply 
Best way to read Editor "World" object
Author Message
aceio76 Offline
Source Licensee

Post: #1
Best way to read Editor "World" object
What is the best way to read the contents of a "World" (created via 'New World' in the editor), particularly the objects placed within? I'm interested in reading the mesh objects used, the position, orientation, scale and also the object custom params (ee params). I want to use the 'World' objects as a way to each store a collection of manually placed objects as a single group of fixed objects that I can then dynamically place as a set whole. Before I dive into the worldmanager code, I thought I'd ask for direction and guidance first smile

Thanks.
05-31-2017 11:58 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Best way to read Editor "World" object
Hi,

Do you want this during the game? or for some custom made tool and use network EditorInterface?
06-01-2017 12:59 AM
Find all posts by this user Quote this message in a reply
aceio76 Offline
Source Licensee

Post: #3
RE: Best way to read Editor "World" object
For the game. I expect the 'World' editor objects included in the game asset so I'd prefer to read them directly. Otherwise, the other roundabout approach is to write an Editor Interface app to read the 'World' and its contents, and write the data into a new file that the game can access.
06-01-2017 02:43 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Tottel Offline
Legacy License Owner

Post: #4
RE: Best way to read Editor "World" object
I use this for a bunch of different things (my Visual Events Project completely relies on this to work), but here is a simple example for a path of nodes (which are world objects). Among a couple of things, each node takes an index as a parameter, which controls the flow of the path:

Code:
/******************************************************************************/
class PathNode : Game.Static
{
   int Index;
  
   /******************************************************************************/
   virtual void create(Object &obj)
   {
      if(Param *p = obj.findParam("PathNodeIndex"    )) Index             = p.asInt();

      super.create(obj);
   }
}
/******************************************************************************/

Then, I made a container for objects of this class:

Code:
Game.ObjMap<PathNode> WorldPathNodes;

And use setObjectType when initializing the world to link that container with OBJ_PATH_NODE, which is a custom Object Class.

Then, finding the correct object is simple. E.g. I want to find a node by index (which is a parameter, stored as a class variable).

Code:
PathNode* GetPathNodeByIndex(int index)
{
   FREPA(WorldPathNodes)
   {
      if(WorldPathNodes[i].Index == index)
      {
         return &WorldPathNodes[i];
      }
   }
              
   return null;      
}

So, you can collect objects based on your criteria, and then do whatever you want with them.
(This post was last modified: 06-01-2017 12:48 PM by Tottel.)
06-01-2017 12:46 PM
Find all posts by this user Quote this message in a reply
aceio76 Offline
Source Licensee

Post: #5
RE: Best way to read Editor "World" object
Thanks Tottel, I'm actually looking to read several 'World' files created thru the editor (ie. right-click on the node window on the left and select New World). Each 'World' file would have placed objects, terrain, etc. I then intend to read each 'World' file and its contents, including custom EE Params of the objects in each 'World' file. None of these 'World' files would be the active world, they are merely used to hold manual placements of a set of objects. I'm looking to access these 'World' files directly within the game.
(This post was last modified: 06-01-2017 01:47 PM by aceio76.)
06-01-2017 01:44 PM
Visit this user's website Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Binary Licensee

Post: #6
RE: Best way to read Editor "World" object
I believe every thing is saved into those area file isnt it ? Including obj ?
Then you just have to read those area chunk of the world preset needed ?
06-01-2017 03:16 PM
Find all posts by this user Quote this message in a reply
aceio76 Offline
Source Licensee

Post: #7
RE: Best way to read Editor "World" object
Are you referring to using the worldmanager to read the 'World' files?
06-01-2017 05:09 PM
Visit this user's website Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Binary Licensee

Post: #8
RE: Best way to read Editor "World" object
I was talking about the areas saved under your project directory. world manager works "as is" only with active world i believe?
Pixel perfect might be able to help you better with this as i believe he managed to read areas directly from the file and imported the data for his ai system into another software. I have never tried to open one of this pfft
06-01-2017 05:54 PM
Find all posts by this user Quote this message in a reply
Tottel Offline
Legacy License Owner

Post: #9
RE: Best way to read Editor "World" object
Basically, you are trying to create a prefab.
06-01-2017 06:10 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #10
RE: Best way to read Editor "World" object
From the EditorInterface:
worldObjGetDesc and worldObjGetData is what you want.

From the game side:
you'd have to load a world Game.World.NewTry, and then iterate all areas, you can manually load the areas using Game.World.areaSetState, this will trigger Game.Obj.create callbacks when objects are loaded from that area, in that callback you can extract all the parameters.
But you need to first of course link the object classes with the world manager like in all tutorials: Game.World.setObjType

The easiest way for me is to use the EditorInterface
06-02-2017 12:27 AM
Find all posts by this user Quote this message in a reply
Post Reply