[Closed] uvw mapping in scripted geometry plugins
I’m trying to understand uvw mapping with simplegeometry plugins,
here is the squaretube example from the helpfile with a modification to generate a box uvw map for it.
plugin simpleObject squareTube
name:"SquareTube"
classID:#(63445,55332)
category:"Scripted Primitives"
(
local box1, box2
parameters main rollout:params
(
length type:#worldUnits ui:length default:1E-3
width type:#worldUnits ui:width default:1E-3
height type:#worldUnits ui:height default:1E-3
)
rollout params "SquareTube"
(
spinner height "Height" type:#worldUnits range:[1E-3,1E9,1E-3]
spinner width "Width" type:#worldUnits range:[1E-3,1E9,1E-3]
spinner length "Length" type:#worldUnits range:[-1E9,1E9,1E-3]
)
on buildMesh do
(
if box1 == undefined then
(box1 = createInstance box; box2 = createInstance box)
box1.height = height; box2.height = height
box1.width = width; box2.width = width * 2
box1.length = length; box2.length = length * 2
tempmesh=box2.mesh - box1.mesh
meshop.applyUVWMap tempmesh #box utile:1 vtile:1 wtile:1
mesh=tempmesh.mesh
delete tempmesh
)
tool create
(
on mousePoint click do
case click of
(
1: nodeTM.translation = gridPoint
3: #stop
)
on mouseMove click do
case click of
(
2: (width = abs gridDist.x; length = abs gridDist.y)
3: height = gridDist.z
)
)
)
(I’m aware that i could just enable the mapping of the primitives, but that would only work for this very basic example)
I’m using
meshop.applyUVWMap tempmesh #box utile:1 vtile:1 wtile:1
on the generated mesh, to create the same effect as the uvw mapping modifier with box mode.
It does work, but the map scale isn’t the same as the bounding box (as it would be the case with the modifier).
I’m aware of the transformation matrix parameter, to transform and scale the map, but that doesn’t help me aligning it to the bounding box of the mesh (because I have no idea how to do it) ;).
Also I miss a way to generate real world map scale.
The help file is a bit lacking in this area, if anyone got a solution how to do it, I’d greatly appreciate it.
thanks, Marc