PDA

View Full Version : create vertices at object pivot points?

 Soulcialism07-19-2005, 05:01 PMhi everyone, i'm trying to come up with a script here for a game engine... the overall idea is that we have ton of trees that will be instanced throughout the scene from one asset in-game. in order to provide spawn points for the trees to snap to, we want to create a mesh of vertices according to a tree layout scene in maya, then export it to a game asset, and i'm trying to write a mel script to do it for us (just the mesh creation)... here's the basic pseudocode i think we need to follow: -select all objects in scene -ls -sl all trees into an array -for each tree in trees, find & store world space pivot, create vertex, assign vertex to world space pivot it sounds pretty simple but the thing that i'm getting stuck on is 1st how to GET the worldspace pivot (is it the same as the tx ty tz if the mesh hasn't had freeze transforms done to it?), and secondly (bigger problem) how to create a single vertex. my idea thus far has been to create a cv for each, assign them all to a group after the for loop completes, then i would have to go back and convert all the cv's to poly. that's not such a big deal but it seems extraneous, is there a way to just create 1 vertex? thanks for helping in advance.
Soulcialism
07-19-2005, 09:52 PM
so update is that i've figured out how to do everything except create 1 vertex... create polygon won't allow anything less than 3 vertices to create a poly...but i don't need a poly, just 1 point... anyone have any bright ideas? is this even possible?

code to this point:

string \$trees[] = `ls -sl -fl`;

for (\$tree in \$trees)
{
\$tree = \$tree + ".rotatePivot";
float \$piv[] = `pointPosition \$tree`;
curve -p \$piv[0] \$piv[1] \$piv[2];
}

handy little find: pointPosition won't return anything if you tell it to do \$array.attribute. i thought it would, but i had to do that little bit about adding .rotatePivot to keep it from erroring.

thanks

mhovland
07-20-2005, 02:30 PM
I guess the real question is what is the output format you need?

If it is a geometry format, whether some internal format or known format like .X files, you can create one big poly, with the verts at the appropriate locations and then have your programmers know on that specific object, not to draw the faces, but only use the vertex information.

If your target format is a text file that you will export out of Maya that will be parsed by the engine, the easiest way will be to create locators at each location, and then export the info for all the locators to a text file.

I suppose even if the file format is a geometry format, but also ASCII text, you could use the locators method and then write your own version of the exporter to write the file out correctly.

If you provide more clarification on the target output format, I might be able to help you more.

CGTalk Moderation
07-20-2005, 02:30 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.