PDA

View Full Version : Can I make an objects list using coffee?


Caravaggio
12-06-2009, 08:21 PM
I'm trying to put together a game in MS' XNA, but it's all code and doesn't use a map editor. So I've got two choices, enter the positions of static meshes manually or code my own editor. I'm thinking it'll be faster/easier if I could just use a 3d package like c4d or max to map the world and then just find some way to create a list of the objects and their positions for use in xna, the objects themselves already being in the xna content directory.

I've never looked at coffee before, and while some things are obvious, others definitely less so. So I'm hope someone has done something like this or maybe already has. My initial idea was to just cycle through the index numbers of all the children of the main doc, but I'm having trouble finding something on index positions.

I did find this page while searching the forums...
http://www.per-anders.net/w/index.php?title=COFFEE_Object_Iteration
...so should I just not worry about cycling through index numbers and use the GetNext() funtcion?

Obviously not real code, just kind of how I'd like it to work...

main(doc,op)
{

for (i=0; i<total_objects_in_scene; i++)
{
//add object name to list...
print(doc->GetObject()[i]->GetName() + ", ");
//then translation...
print(object x position + ", "); //hopefully more like "child[i].x"
print(object y position + ", ");
print(object z position + ", ");
//and rotation...
print(object h rotation + ", ");
print(object p rotation + ", ");
print(object b rotation + ", "); //I can delete the last one manually.
}

}

So I end up with something like;
[wall, 23, 53, 453.3, 0,0,0, pillar, 357, 464, 465, 35,0,0]

(I understand writing to a file is itself problematic but it'll be fine if I can just use print to trace it all to the console window and then just control-c it.)

Any help appreciated.

Kuroyume0161
12-06-2009, 09:03 PM
OM2File2 (http://www.kuroyumes-developmentzone.com/c4d/plugins/OM2File2_v0.1.zip)

It does just that.

bobtronic
12-06-2009, 09:16 PM
simple script iterating through the whole scene


PrintObject(op) //recusrsive function, iterates through the complete object hierarchy
{
while(op)
{
println(op->GetName()); //print the name

var mg = op->GetMg(); //get global matrix

println(stradd("position ",tostring(mg->GetV0()))); //print the postion
println(stradd("rotation ",tostring(mg->GetHPB()))); //print the rotation, it's in radians

PrintObject(op->GetDown()); //recursion
op = op->GetNext();
}
}

main(doc,op)
{
PrintObject(doc->GetFirstObject()); //calls the iteration function
}


cheers,
Matthias

Caravaggio
12-06-2009, 10:15 PM
Yes, both of your are awesome. Unless your were already awesome in which case you can feel free to pencil in a little "r" at the end of your name tag.

CGTalk Moderation
12-06-2009, 10:15 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.