Hi mouness, in answer to your question ... yes you can do this with the new update. As you correctly say, you need to know the internally generated ObjectID for the barrel and the tree.
The way to do this is as follows:
1. Open you level in 3DWS and select the barrel.
2. Select the barrel by clicking on it in the perspective window and then click on the selected object in either of the other windows (this is neccessary or you can't bring the properties up).
3. Choose properties from the edit menu or press Shift+Enter to bring up the properties dialog
4. In the classname box type 'barrel'
5. Click on the Add button to display the New KeyValue window and enter 'name' for the KeyName and 'barrel1' for the KeyValue, then click OK.
6. Do the same for the tree setting the Classname to 'tree' and the KeyName to 'name' and the value to 'tree1'
7. Save the level.
8. Replace your existing level in your project with this one.
9. Use the following code to obtain the ObjectID assigned by the loader:
int ObjectCount = 0;
int Barrel1ID;
int Tree1ID;
vector<int> ObjectIDList;
// Search for a matching Key name and Value
ObjectCount = c3dw.getDBObjectIDsMatchingClassnameAndKey("barrel","name","barrel1",&ObjectIDList);
// Check that the number of objects returned is not zero
// and if not extract the ObjectID
if(ObjectCount) then Barrel1ID = ObjectIDList[0];
// Clear the list
ObjectIDList.clear();
// Search for a matching Key name and Value
ObjectCount = c3dw.getDBObjectIDsMatchingClassnameAndKey("tree","name","tree1",&ObjectIDList);
// Check that the number of objects returned is not zero
// and if not extract the ObjectID
if(ObjectCount) then Tree1ID = ObjectIDList[0];
So basically, in 3DWS group similar objects by giving them the same classname, that way, if you want to act on all of these collectively, you can search and return objectIDs based on just the classname.
Secondly, ensure you give them a unique name by assigning a name Key and Value. This way you can identify individual objects and return their ID.
So, if for instance you had 5 barrel objects all with the classname 'barrel' and named 'barrel1' to 'barrel5' if you wanted to say hide all the barrels then you could do the following which demonstrates the use of the ? wildcard character (this will return any value for the position in which it is used):
int ObjectCount = 0;
vector<int> ObjectIDList;
// Search for all objects matching a classname
objectCount = c3dw.getDBObjectIDsMatchingClassnameAndKey("barrel","?","?",&ObjectIDList);
// Hide all of these objects
for(int i = 0; i < objectCount; i++)
{
dbHideObject(ObjectIDList[i]);
}
The functions use a vector<int> (similar to an array) to enable one or many items to be returned giving greater flexability than just allowing a single item to be returned at a time.
It's up to you how you use this but I hope that demonstrates a simple use of just one of the functions as well as providing a direct solution to your question.
No matter how good your code is, someone will improve on it