Align E-Poly Slice Plane Gizmo Direction

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  01 January 2013
Align E-Poly Slice Plane Gizmo Direction

How to orient E_Poly Slice Plane Gizmo by two points (vector)
The problem arises when the object is orienet differently from 0,0.0
On the image i show procedure and correct pos and dir of slice plane that i want to achive.

And this is test code

 delete objects
 obj = converttopoly (Box length:100 width:20 height:10 wirecolor:blue isSelected:on \
 transform:(matrix3 [0.611356,0.551368,0.567659] [-0.76058,0.211288,0.613902] [0.218546,-0.807063,0.548531] [0,40,0]))
 max modify mode
 subobjectLevel = 4
 obj.EditablePoly.resetSlicePlane()
 --------------------------------------
 -- check (turn on) slice plane to see gizmo plane
 -- then run below code
 -- pick two points as i marked on the image
 --------------------------------------
 pnt1 = pickPoint snap:#3D 
 if classof pnt1 == Point3 do
 (
 	pnt2 = pickPoint snap:#3D rubberband:thePoint1
 	if classof pnt2 == Point3 and distance pnt1 pnt2 > 0 do
 	(
 		plane_normal = normalize (pnt2-pnt1)
 		plane_center = pnt1 * inverse obj.transform
 		obj.setSlicePlane &plane_normal &plane_center 20
 		format "first point: %\nsecond point: %\ndirection: %\n" pnt1 pnt2 plane_normal
 	)
 )
 
__________________
Looking in the right side. [bgaTools]
 
  01 January 2013
try to find my sample about the slice plane... it's about some different thing but can give you as idea.
 
  01 January 2013
Originally Posted by denisT: try to find my sample about the slice plane... it's about some different thing but can give you as idea.

Are you referring to this example
http://forums.cgsociety.org/showthr...highlight=slice

 --code 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)
 )

I need en example for polyOp method or simple EPoly slice but not for SliceModifier.
The only problem is direction, but position is OK.
__________________
Looking in the right side. [bgaTools]

Last edited by gazybara : 01 January 2013 at 06:48 PM.
 
  01 January 2013
And this will be solution
 
pnt1 = pickPoint snap:#3D
 if classof pnt1 == Point3 do
 (
	 pnt2 = pickPoint snap:#3D rubberband:thePoint1
	 if classof pnt2 == Point3 and distance pnt1 pnt2 > 0 do
	 (
		 theRay = ray pnt1 (normalize (pnt2-pnt1))
		 polyop.setSlicePlane obj theRay 100.
	 )
 )
__________________
Looking in the right side. [bgaTools]
 
  01 January 2013
Originally Posted by gazybara: How to orient E_Poly Slice Plane Gizmo by two points (vector)


 polyop.setSlicePlane <node> (ray <pos in world> (<normal in world> * <node>.objectoffsetrot)) <size> 
 
 
  01 January 2013
Originally Posted by denisT:

   polyop.setSlicePlane <node> (ray <pos in world> (<normal in world> * <node>.objectoffsetrot)) <size> 
   


which as a function looks like:

 fn twoPointSlicePlane node p0 p1 size:10 = if iskindof node editable_poly do
 (
 	dir = normalize (p1 - p0)
 	polyop.setSlicePlane node (ray p0 (dir * node.objectoffsetrot)) size
 	update node
 )
 
 
  01 January 2013
Originally Posted by denisT:

   polyop.setSlicePlane <node> (ray <pos in world> (<normal in world> * <node>.objectoffsetrot)) <size> 
   

Nice. I've started using hard way. But polyOp method allow "world" value input which helps a lot.
Only thing that i don't understand is "<node>.objectofsetrot".
I suppose that represents
Object LocalCS -> WorldCS

  p3VectorWorld = p3VectorLocal * (object.transform.rotationPart as Matrix3)
 
__________________
Looking in the right side. [bgaTools]
 
  01 January 2013
Originally Posted by denisT: which as a function looks like:

  fn twoPointSlicePlane node p0 p1 size:10 = if iskindof node editable_poly do
  (
  	dir = normalize (p1 - p0)
  	polyop.setSlicePlane node (ray p0 (dir * node.objectoffsetrot)) size
  	update node
  )
  

There is a problem. Big One.
When you set manualy pivot position and rotation (without ResetXform) and try something like this

--#1st SOLUTION
(
	local pnt1, pnt2, theDir
	pnt1 = pickPoint snap:#3D
	if classof pnt1 == Point3 do
	(
		pnt2 = pickPoint snap:#3D rubberband:thePoint1
		if classof pnt2 == Point3 and distance pnt1 pnt2 > 0 do
		(
			local coords = #(5,15,40,10,30)
			local selObj = selection[1]
			local theDir = normalize (pnt2-pnt1)
			for c in coords do
			(
				polySlice selObj #{1..selObj.numfaces} (ray (pnt1+=(c*theDir)) theDir)
			)
		)
	)
)
--#2st SOLUTION
(
	local pnt1, pnt2, theDir
	pnt1 = pickPoint snap:#3D
	if classof pnt1 == Point3 do
	(
		pnt2 = pickPoint snap:#3D rubberband:thePoint1
		if classof pnt2 == Point3 and distance pnt1 pnt2 > 0 do
		(
			local coords = #(5,15,40,10,30)
			local selObj = selection[1]
			local theDir = (normalize (pnt2-pnt1)) *selObj.objectoffsetrot
			for c in coords do
			(
				polySlice selObj #{1..selObj.numfaces} (ray (pnt1+=(c*theDir)) theDir)
			)
		)
	)
)

you will get this result

It is obvious that in this case should be avoided "selObj.objectoffsetrot"
Your opinion?
__________________
Looking in the right side. [bgaTools]
 
  01 January 2013
Originally Posted by gazybara: Your opinion?

i think that must be the right combination of .transform or/and .objecttransform values to solve the plane.
so... you have to find this combination.

Last edited by denisT : 01 January 2013 at 12:34 AM.
 
  01 January 2013
Originally Posted by denisT: i think that must be the right combination of .transform or/and .objecttransform values to solve the plane.
so... you have to find this combination.

I agree. 1st solution works fine for now. I will do more tests and if I notice strange behavior
I'll try to find the right combination that you suggested.
Thank Denis. I really appreciate your help and wise answers to all questions
Cheers!
__________________
Looking in the right side. [bgaTools]
 
  01 January 2013
Originally Posted by gazybara: I agree. 1st solution works fine for now. I will do more tests and if I notice strange behavior
I'll try to find the right combination that you suggested.
Thank Denis. I really appreciate your help and wise answers to all questions
Cheers!

polyop.setSlicePlane sets in world space. so it doen't need any extra transformations... so the function should be simple as:

 fn twoPointSlicePlane node p0 p1 size:10 = if iskindof node editable_poly do
 (
 	dir = normalize (p1 - p0)
 	polyop.setSlicePlane node (ray p0 dir) size
 	update node
 )
 
 
  01 January 2013
Originally Posted by denisT: polyop.setSlicePlane sets in world space. so it doen't need any extra transformations... so the function should be simple as:

  fn twoPointSlicePlane node p0 p1 size:10 = if iskindof node editable_poly do
  (
  	dir = normalize (p1 - p0)
  	polyop.setSlicePlane node (ray p0 dir) size
  	update node
  )
  

Of course. Also and polyop.slice. The adventage of this is that you may slice any epoly object even after you scale them and mess around with pivot position and orientation. My last image confirms that.
__________________
Looking in the right side. [bgaTools]
 
  01 January 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:13 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.