Simplemod - world coordinates

Simplemod - world coordinates

Anonymous
Not applicable
271 Views
2 Replies
Message 1 of 3

Simplemod - world coordinates

Anonymous
Not applicable
I`m writing a scripted modifier that snaps vertices to a grid position in world space.
The only problem I`m having is finding out the world position of each vertex.
I only need to get this position as I can then alter the local position accordingly.
Does anyone know a way of getting the world position of 'p'?
I`ve included the WIP plug-in below;


--------------------------------------------------
plugin simpleMod SnapToGrid

name:"Snap to Grid"

classID:#(0x3891aa38, 0x51b5e565)

version:1

(

parameters main rollout:params

(
amount type:#integer ui:amtSpin default:2
)

rollout params "Snap Parameters"
(
spinner amtSpin "Grid Val: " type:#integer range:
)

on map i p do
(
p.x = P.x-(Mod (p.x+min.x) (amount*39.3701))
p.y = P.y-(Mod (p.y+min.y) (amount*39.3701))
p.z = P.z-(Mod (p.z+min.z) (amount*39.3701))
p
)

)
0 Likes
272 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
The vertices obviously live in the local coordinate space of the object the mod is applied to, so you'll need to add the local pos to the object pos.
You could store the baseObject in the parameters with a weak reference and access it's position in the map handler to calculate the worldPos.
0 Likes
Message 3 of 3

Anonymous
Not applicable
That's a great idea. I`m not sure you can access the object directly from within the map handler as it's referencing itself causing an infinite loop.
I`m starting to wonder if this is actually possible to do as a simplemod can also be applied as an instanced modifier over multiple objects.


Thanks
0 Likes