Start a new topic

Texture Mapping

Original Post by: brianpow Mon Sep 8 19:42:46 2014


Hey all,


I am trying to build a Creator script in Python for the 4.2 API and I have run in to difficulty regarding the Put Texture command.


I assumed that all of the "To" properties would use typical XYZ space, but no matter how I change these values the texture mapping is not affected. Do I have to convert XYZ coords to UV space coords?


mgParamSet (paramBlock3, "To Origin Point", [0,0,0])

mgParamSet (paramBlock3, "To Alignment Point", [0,0,0])

mgParamSet (paramBlock3, "To Shear Point", [0,0,0])


Original Post by: SteveThompson Mon Sep 8 20:23:25 2014


For the "To" points you do specify X, Y and Z in world space. Can you post the script? Certainly the sample you posted (all points are at the origin) won't work. The points need to be different and form a basis.


If you show the script, maybe we can see something wrong.

Original Post by: brianpow Mon Sep 8 21:46:19 2014


-- variables xyz1-2-etc are all set like:

proj = mgNewProjection (db)

lle1 = mgprojcoord()

lle1.lat = origLat1

lle1.lon = origLong1

lle1.height = origElevation1

ok, xyz1 = mgProjectionConvertLLEtoXYZ (proj, lle1)


then vertices for runway ends...


x1 = mgCoord3dMoveAlongVectord (xyz1, v2, -origWidth1 )

x2 = mgCoord3dMoveAlongVectord (xyz1, v2, origWidth1 )

x3 = mgCoord3dMoveAlongVectord (xyz2, v2, origWidth1 )

x4 = mgCoord3dMoveAlongVectord (xyz2, v2, -origWidth1 )


mgSetCurrentTexture(db, 0)


mgExecute ("Select Similar Faces Texture", None)


paramBlock3 = mgGetParamBlock ("Put Texture")

mgParamSet (paramBlock3, "Follow Subnodes", MG_TRUE)

mgParamSet (paramBlock3, "From Alignment Point", [1, 0])

mgParamSet (paramBlock3, "From Origin Point", [0, 0])

mgParamSet (paramBlock3, "From Shear Point", [1, 1])

mgParamSet (paramBlock3, "Map UVs", "Tiled")

mgParamSet (paramBlock3, "Texture Tile U", 20)

mgParamSet (paramBlock3, "Texture Tile V", 20)

mgParamSet (paramBlock3, "To Origin Point", [x1.x, x1.y, x1.z])

mgParamSet (paramBlock3, "To Alignment Point", [x2.x, x2.y, x2.z])

mgParamSet (paramBlock3, "To Shear Point", [x3.x, x3.y, x3.z])


mgExecute ("Put Texture", paramBlock3)

Original Post by: SteveThompson Mon Sep 8 22:08:28 2014


Thanks for the snippet.


I put your script into Creator and all looks fine here. I tweaked the lat, long values and can see the mapping change each time I run the script.


What makes you think that the To points are not affecting the mapping? Can you provide, for example, two sets of "To Points" for which you think the mapping has not changed?


Again, your script runs here, but I can't tell where you are finding the discrepancy.

Thanks

Original Post by: SteveThompson Mon Sep 8 22:14:53 2014


Your script does depend on the polygons that you are going to run Put Texture on to already have the texture applied (since you're using “Select Similar Faces Texture”). We know these polygons will have index 0 already assigned, could these polygons also have Texture Mappings applied? If they do, that would create a situation that the Put Texture command is completely ignored.

Original Post by: brianpow Tue Sep 9 14:07:07 2014


The polygons I am mapping are generated from points in my script. Here is the polygon construction:


paramBlock2 = mgGetParamBlock ("Polygon")


mgParamSet (paramBlock2, "Type", "Solid")


#RUNWAY 2 POINTS

mgParamSet (paramBlock2, "Points", [y1.x,y1.y,y1.z])

mgParamAppend (paramBlock2, "Points", [y2.x,y2.y,y2.z])

mgParamAppend (paramBlock2, "Points", [y3.x,y3.y,y3.z])

mgParamAppend (paramBlock2, "Points", [y4.x,y4.y,y4.z])


mgSetModelingMode (db, fltPolygon)


# execute the Polygon tool

mgExecute ("Polygon", paramBlock2)



The index of 0 holds an asphalt texture that is a 256x256 square .RGB file

Original Post by: SteveThompson Tue Sep 9 15:57:25 2014


Ok, thanks. Sorry I got you a little side-tracked...


Back to your original problem. I built a script from the snippet you posted and can get the "To" points to affect the texture mapping (as they indeed should). So at this point we need more information from you as to why you believe they are not affecting the UVs on the verts.

Original Post by: SteveThompson Tue Sep 9 16:01:43 2014


And of course, one thing you should try (if you have not already) is to print out the "To" points in your script just to make sure they are what you think they are. Sorry if you've already done this but had to make sure ;-).

Login to post a comment