www.quadsoftware.com
FAQ  FAQ   Search  Search   Memberlist  Memberlist   Usergroups  Usergroups
Register  ::  Log in Log in to check your private messages


Post new topic  Reply to topic
 Initializing Property Table « View previous topic :: View next topic » 
Author Message
AD_Dennis
PostPosted: Tue Aug 12, 2008 2:39 am    Post subject: Initializing Property Table Reply with quote



Joined: 02 Apr 2008
Posts: 32

I am trying to initialize a property table for use in creating a lightmap through the SDK. Unfortunately I can't get a pointer to the table owner. Here is what I have:

Code:

   //Setup property table
   iPropertyTableOwner *table_owner;
   t_type_id type_id = NULL;
   type_id = g_sdk_root->GetTypeId(iPropertyTableOwner::TypeString());
   if(type_id)   table_owner = (iPropertyTableOwner*)iSdkInterface::OpenSubinterface(type_id);


I am not sure about the use of "iSdkInterface::OpenSubinterface(type_id)". In the Grome Standard SDK forum I saw a post which used "inst->OpenSubInterface(type_id)" although it isn't clear what "inst" points to.
Back to top
View user's profile Send private message
ALicu
PostPosted: Tue Aug 12, 2008 9:03 am    Post subject: Reply with quote



Joined: 12 Feb 2007
Posts: 1326

Hi Dennis,

As was presented in the SDK help, property tables nodes (one or more of them) can be assigned and accessed from the scene entities. For now, scene entities supporting property tables are terrain zones (iTerrainZone) and object instances (iObjectInstance). These entities can be obtained from the current selection of the scene (browse the current selection) or from the terrain and object editing projects (you can browse all the entities in a certain project). UtilCustomProp plugin is an example plugin in the SDK that assigns property tables to the selected entities in the current scene.

A SDK node can contain multiple interfaces. An scene entity (terrain zone or object instance) besides its primal interface, it also supports iPropertyTableOwner interface. This interface allows you to read and add property tables to this entity. This interface concept allows various other types of entities to support additional functionality (so, for example, in the future updates we may add the possibility to query and add property tables to projects, workspaces or other types of nodes).

The interface is specific to a certain node (it is not global so it cannot be opened with iSdkInterface::OpenSubinterface). It must be opened with, for example, inst->OpenSubinterface, where inst is a pointer to the object instance to which you want to add the property table.

So, first, obtain the pointer to the nodes you want to add/query property tables and then obtain the property table owner interface from them. This owner interface allows you to add and query the property tables to/from the instance/terrainzone from which you opened the subinterface.

Regards,
Adrian L.
Back to top
View user's profile Send private message
AD_Dennis
PostPosted: Wed Aug 13, 2008 10:54 pm    Post subject: Reply with quote



Joined: 02 Apr 2008
Posts: 32

Hmmm... I didn't realize there was an SDK help. I'll have to check that out. Thanks for the information ALicu.
Back to top
View user's profile Send private message
AD_Dennis
PostPosted: Thu Aug 21, 2008 2:20 am    Post subject: Reply with quote



Joined: 02 Apr 2008
Posts: 32

ALicu, thanks again for the help. I have a few more questions about the custom table usage. My goal here is to assign the properties necessary to apply the lightmap to a terrain zone. As you described above I've managed to get the owner interface to the table for zone(0):

Code:

...
   t_type_id type_id2 = g_sdk_root->GetTypeId(iPropertyTableOwner::TypeString());

   prop_owner = (iPropertyTableOwner*)zones->Elem(0)->OpenSubinterface(type_id2);
   
   if(prop_owner)
   {

      t_error answer = prop_owner->AddProperties(prop_table);

      prop_owner->CloseInterface();
   }
...


I am using a small terrain project to test this code. It has four zones and three texture masks -> rock, grass and sand. If I understand correctly each zone has a property table assigned to it for each of these three masks. So it should be possible to access these existing tables once you have the table owner pointer. If this is correct then shouldn't prop_owner->GetPropertyTablesNo() return 3 for this example? Currently I get 0; What I am hoping to do is to understand the table structure by accessing one of these.

Thanks.
Back to top
View user's profile Send private message
ALicu
PostPosted: Thu Aug 21, 2008 7:16 am    Post subject: Reply with quote



Joined: 12 Feb 2007
Posts: 1326

Hi Dennis,

The property tables are assigned to the zone and not to its masks/layers. You can have as many property table as you want per zone. You need to assign them first before reading them (a newly created zone, even if you add layers to it, will not have any property table).

Property tables are a way to add custom properties (that can refer to any client specific tasks) to scene terrain zones and object instances. By default all the scene entities are created with no custom property tables. You need to add them either by Grome UI (assign from the property table panel) or by SDK. Once you assign them, they are saved with the entities in the scene files.

In your case, if you need to keep information about the layers, you can create a plugin to assign a property table to any newly created layer. For this you first need to identify which property table refer to which layer (you cannot use the index of the property table for this because the layers can moved without this reflecting the property tables order). One way to do this is to use the layer names (and make sure these are unique). So you can have an entry in each property table (a string variable) to keep the layer name he is referring to. In this way you can quickly identify for each zone which property table is referring to which layer.

I hope this helps.

Adrian L.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Based on a template by Dustin Baccetti
Powered by phpBB © 2001, 2005 phpBB Group