Select to view content in your preferred language

embedding attributes into .obj in Maya...or Max Is it possible?

3702
11
09-12-2012 08:03 AM
SahakSahakian
Deactivated User
Hi.

I wonder if there is a way to add attribute such as building height or roof type onto footprint .obj files from within Maya or Max?

How does one go about adding an attribute that City Engine can read/show and be usable like shown in the tutorial files?

Does it have to be in shape format? And if there are other software that allow for adding this attribute before importing?

Is there tutorials that show how one can add building height attribute to a polygonal building footprint before importing to City Engine?

EDIT: I did some searching and found out that these attributes live in an external to the polygons database, table.dbf file. Is there scripts or exporters that anyone is aware of that allows these attributes ( buildingHeight, buildingType ) to be added and exported from within Maya, Max, Sketchup?

Thank you.
0 Kudos
11 Replies
SahakSahakian
Deactivated User
I do have (mostly) one mesh for each building. But these models are inefficient and have no extra attributes associated to them. It is relatively easy to add an extra attribute in Maya. Getting an attribute out of her and in to the City Engine is the part I don't yet know how to do. I guess attributes are handled differently internally and are stripped out during the exporting from Maya. To work around this requires Python and 3D math matrices ninjahood that I do not yet possess :P...

I am measuring building height with Mayas Measure Tool and can plot these manually or automate the process when I know more about the route the attributes are taking between Maya and City Engine...

The footprints are separate pieces of geometry. I can remodel them by hand or programatically if I knew how, inside of City Engine. It may be better to just redraw them manually, to ensure correct point order and facade facing the streets etc.. I also have a version of the footprints as separate curves for each footprint, in Maya but the point order in both curves and polygons is probably messy...

choices choices..
0 Kudos
MatthiasBuehler1
Deactivated User
To get the building height, I'd rather set up a script which calculates the meshes bounding box.

Polys with holes would not be supported.

I've written some MEL code which gets a vertex list of one polygon with which you can directly create a corresponding shape in CityEngine.

That could be a starting point. You'd have to continue using the output of this, then go on and create the text for CityEngine python code.


float $resultArray[] = `getFaceVertexCoordList("polySurface1" )`;
print $resultArray;

global proc float[] getFaceVertexCoordList(string $shapeName)
{
    float $resultArray[] = {};
    string $ftv[] = `polyInfo -faceToVertex ($shapeName+ ".f[0]")`;
    
    string $buf[];
 $numTokens = `tokenize $ftv[0] ":" $buf`;
 $numTokens = `tokenize $buf[1] " " $buf`;
    
    for ($element in $buf)
    {
        float $coords[] = `xform -ws -q -t ($shapeName + ".vtx[" + int($element) +"]")`;
        $resultArray[size($resultArray)] = $coords[0];
        $resultArray[size($resultArray)] = $coords[1];
        $resultArray[size($resultArray)] = $coords[2];
    }
    return $resultArray;
}


Note that this obviously only works if the input mesh has just 1 face.
0 Kudos