Start a new topic

Need 3d coord, uv help.

I have vertical planes at different angles. They are quads (rectangles) I have a script to grab the top 2 verts. I need to apply uv coords with 3 points - v1 - 4 meters from v1, towards v2 - 4 meters down from v1 Can anyone help with this? Seems like something simple with a matrix? But I cant figure out how to use those. Thanks Joe

The easiest way to do this would be to use the "Put Texture" Creator Script command. You can easily add this to  your script with the Creator Script Snippet Wizard (the hammer icon) in the OpenFlight Script Editor. This shows a list of Creator tools that can be used while running scripts inside of Creator's OpenFlight Script Editor, inside Batch Run Script or in scripts run with Creator Console.


This particular tool will function just like the one in the UI. it will apply the current texture to the current selection. Below is the default code snippet the Creator Script Snippet Wizard will add. You would need to change the "To Alignment Point," "To Origin Point," and "To Shear Point" values to what you described above.

 

paramBlock = mgGetParamBlock ("Put Texture")
mgParamSetBool (paramBlock, "Follow Subnodes", MG_TRUE)
mgParamSetDouble2 (paramBlock, "From Alignment Point", 1, 0)
mgParamSetDouble2 (paramBlock, "From Origin Point", 0, 0)
mgParamSetDouble2 (paramBlock, "From Shear Point", 1, 1)
mgParamSetInteger (paramBlock, "Map UVs", 2)
mgParamSetDouble (paramBlock, "Texture Tile U", 1)
mgParamSetDouble (paramBlock, "Texture Tile V", 1)
mgParamSetDouble3 (paramBlock, "To Alignment Point", 0, 0, 0)
mgParamSetDouble3 (paramBlock, "To Origin Point", 0, 0, 0)
mgParamSetDouble3 (paramBlock, "To Shear Point", 0, 0, 0)
mgExecute ("Put Texture", paramBlock)

 

Ok I think I can use that but it doesn't appear to be executing, I think because I am not actually running this on a selection but on the whole database, so I am iterating through objects in the database and then faces in the object. I have a currentFace variable, how do I make that the "active" object that the paramBlock executes on?

First you need to clear the selection:


mgDeselectAll(db)


Then you need to select the face:


mgSelectOne(currentFace)


I'm assuming currentFace is the face rec



1 person likes this

ok this is coming along, but now I need to read, or get the texture assigned to a face/poly. how can i do this?

The texture applied to a face is stored in the face attributes as an index.  you can get this index like you get most node attributes using the function mgGetAttList and passing in the attribute code to get. The OpenFlight API Reference has a great document listing all these codes called the Data Dictionary.  For the polygon, here is the section with the base texture and different texture layer codes:


image


So if you have a polygon rec,  your call in python would look something like this:


count, code, textureIndex = mgGetAttList (polyRec, fltPolyTexture)


The count variable that is returned tells you how many attributes were found. You can use this to check for unexpected results. If the thing you passed in wasn't a polygon for instance, this would return 0, fltPolyTexture, None. It seems strange but this function is not limited to one attribute at  a time. You can pass several codes in and get back much more data at once.


Login to post a comment