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)
First you need to clear the selection:
Then you need to select the face:
I'm assuming currentFace is the face rec
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:
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.