[Closed] SlicePlane and world coordinates
I’m working on a script for water in a bottle. The water surface is made with help of a slice plane that moves horizontal. For that movement I would like to use world coordinates but the slice modifier only works with local coordinates of the object that it’s mounted on.
how can I switch the system?
It looks like
sliceplane_position = [0,0,0]
liquid.modifiers[#Slice].Slice_Plane.position = sliceplane_position
I would like to enter world coordinates for the sliceplane_position. Any ideas?
I think you can convert from world to local coordinate by using this function
sliceplane_position = [x,y,z]*(inverse liquid.transform)
liquid.modifiers[#Slice].Slice_Plane.position = sliceplane_position
thanks for the hint. I’m already using the inverse to keep the Plane horizontal. It works fine but the Plane position is in the world coordinate system an not in the lokal system of the object with the modifier.
When I move the SlicePlane in the Viewport I can enter World coordinates. But when using the Script (Fluessigkeit.modifiers[#Slice].Slice_Plane.rotation = q1) I need local ones.
Finaly I found a solution by using Transformation mentioned here
http://forums.cgsociety.org/archive/index.php/t-947562.html
pretty simple.
Example by denisT
(
n = box pos:[10,20,30]
m = sliceModifier Slice_Type:2
addModifier n m
objTM = n.objectTransform
modTM = getModContextTM n m
-- set slice plane position at world coordinates [0,0,300]
m.Slice_Plane.pos = [0,0,300] * modTM * (inverse objTM)
)