Float_Script() instead of Lookat_constraint ()

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
Old 03 March 2013   #16
Originally Posted by AlexeyGapon: With 10 points it works fine. But with 20 points i tried to select one and 3D MAX crashed.
Very unexpected Bug (((

try to comment --disablerefmsgs and --enablerefmsgs
 
Old 03 March 2013   #17
Originally Posted by denisT: try to comment --disablerefmsgs and --enablerefmsgs


After that it works fine with 1000 points and i could select any of them without any problems. With 10000 points max crashed trying to create them but i think it is limitation of my computer not 3d studio. So it seems that the bug is in the "UpNode".

I am sorry max crashed with 1000 too. With 200 works fine. And in Upnode "world" = false works fine too. But if try to set the "Upnode" 12- is the maximum that works.

Last edited by AlexeyGapon : 03 March 2013 at 11:11 PM.
 
Old 03 March 2013   #18
this result is what i was expecting...
see what's going on.
we have four points... the 1st looks at 2nd, 2nd looks at 3rd, 3rd looks at 4th
if we don't use up vector our 'look at' depends on only target's position. but if we use up vector it depends on target's rotation too.
so get 1st rotation we have to get 2nd first, but get 2nd we have to get 3rd...
so without up vector we have the order of evaluation: 1-2-3
with up vector: 1-2-3-1, 2-3-2, 3.
and it's a good scenario! the bad scenario is (and it's more likely) if every next in the dependency chain controller sends propagated notification to all dependents. something is about factorial of number of chain members... for 20 members it's 2432902008176640000

Last edited by denisT : 03 March 2013 at 11:38 PM.
 
Old 03 March 2013   #19
Felix Joleanes has a flippingless "look-at" script controller tutorial. Here on his site:

http://joleanes.com/tutorials/flipp...pingless_02.php

He goes thru all the math.
 
Old 03 March 2013   #20
Originally Posted by denisT: this result is what i was expecting...
see what's going on.
we have four points... the 1st looks at 2nd, 2nd looks at 3rd, 3rd looks at 4th
if we don't use up vector our 'look at' depends on only target's position. but if we use up vector it depends on target's rotation too.
so get 1st rotation we have to get 2nd first, but get 2nd we have to get 3rd...
so without up vector we have the order of evaluation: 1-2-3
with up vector: 1-2-3-1, 2-3-2, 3.
and it's a good scenario! the bad scenario is (and it's more likely) if every next in the dependency chain controller sends propagated notification to all dependents. something is about factorial of number of chain members... for 20 members it's 2432902008176640000


Oh... that is very unexpected too. Thank you for explanation! So is it possible to solwe this problem and use lookAt somehow? Or the only way is using the script controllers?
 
Old 03 March 2013   #21
Originally Posted by Archangel35757: Felix Joleanes has a flippingless "look-at" script controller tutorial. Here on his site:

http://joleanes.com/tutorials/flipp...pingless_02.php

He goes thru all the math.

Thank you very much i will check this out!
Oh! It is just what i am looking for!


	theTargetVector=(Target.transform.position * Inverse Parent.transform)-NodePos.value
	theAxis=Normalize (cross theTargetVector [1,0,0])
	theAngle=acos (dot (Normalize theTargetVector) [1,0,0])
	Quat theAngle theAxis


But i need some modifications, could somebody help with it? Spine02 should have the same orientation on X axis as the Target has.

Last edited by AlexeyGapon : 03 March 2013 at 09:31 AM.
 
Old 03 March 2013   #22
Originally Posted by AlexeyGapon: Thank you very much i will check this out!
Oh! It is just what i am looking for!


 	theTargetVector=(Target.transform.position * Inverse Parent.transform)-NodePos.value
 	theAxis=Normalize (cross theTargetVector [1,0,0])
 	theAngle=acos (dot (Normalize theTargetVector) [1,0,0])
 	Quat theAngle theAxis
 


But i need some modifications, could somebody help with it? Spine02 should have the same orientation on X axis as the Target has.


code above is ok but...

well... here is the math:

fn addLookAtScript source target useasup:off = 
(
	c = source.rotation.controller = Rotation_Script()
	c.addnode "source" source
	c.addnode "target" target

	ss = ""
	ss += "front = normalize (target.pos - source.pos)\n" 
	ss += "side = normalize (cross " + (if useasup then "target.transform[3]" else "[0,0,1]") + " front)\n" 
	ss += "up = normalize (cross front side)\n" 
	ss += "(matrix3 front side up [0,0,0]) as quat\n" 

	c.setexpression ss
	c
)	

delete objects
source = point pos:[0,0,0] axistripod:on wirecolor:orange
target = dummy pos:[30,0,0] 

addLookAtScript source target useasup:on


if source and target have parents the code has to be slightly modified
 
Old 03 March 2013   #23
200 works well... 400 crashes. probably it's something about the depth of recursion.

fn addLookAtScript source target useasup:off = 
(
	c = source.rotation.controller = Rotation_Script()
	c.addnode "source" source
	c.addnode "target" target

	ss = ""
	ss += "front = normalize (target.transform[4] - source.pos)\n" 
	ss += "side = normalize (cross " + (if useasup then "target.transform[3]" else "[0,0,1]") + " front)\n" 
	ss += "up = normalize (cross front side)\n" 
	ss += "(matrix3 front side up [0,0,0]) as quat\n" 

	c.setexpression ss
	c
)	

disableRefMsgs()
delete objects 
gc()
max create mode
count = 200
animationrange = interval 0 100
with redraw off, undo off 
(
	path = circle radius:200
	addmodifier path (Bend axis:0 angle:90)
	converttosplineshape path
	
	pp = for k=0 to count-1 collect
	(
		p = point pos:[k,0,0] size:10 axistripod:off wirecolor:orange
		p.pos.controller = createinstance Path_Constraint path:path percent:((k+1)*100./count) follow:off
		p
	)
	for k=1 to pp.count while not keyboard.escpressed do 
	(
		if k < pp.count do addLookAtScript pp[k] pp[k+1] useasup:on
	)
)
enableRefMsgs()
 
Old 03 March 2013   #24
the problem is - this construction is leaking badly in memory. read my old posts about scrip_controller leaking...
 
Old 03 March 2013   #25
but this construction has 'pseudo' circular dependency too. if you will try to change a controller of any point you will never see the end... but selection works well...
 
Old 03 March 2013   #26
Thank You denisT you helped a lot!!! I will try this code today!
 
Old 03 March 2013   #27
Originally Posted by AlexeyGapon: Could you show an exmple?


fn IKLookAt Obj Target =
(
Pt = Point Name:("LookAtPt")
Pt.transform = Target.transform
Pt.parent = Obj
LookAtIK = IKSys.ikChain Obj Pt "IKHISolver"
LookAtIK.name = "LookAtIK"
LookAtIK.parent = Target
)
IKLookAt (teapot pos:[0,0,0]) (teapot pos:[0,0,100])
__________________
http://3dcutout.com/
 
Old 03 March 2013   #28
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.
 
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 11:11 AM.


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