Freeze Rotation, Rotation to Zero for TCB controller

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 02 February 2005   #1
Question Freeze Rotation, Rotation to Zero for TCB controller

Hi,

I would never think I will do something with maxscript. My only experience with programming is a few simple "things" in pascal when I was on high school years ago (good old days ).
But now, I needed to use freeze/restore rotation (in animation quad). I have found out that this works only with Eulers (if you have tcb, it will setup eulers). So I thought I will edit the script to work with TCB. What a heroic thing from me .
I have cut out everything except freeze and restore rotation (there is position and transformation too). Than I have edited the script. It almost works (freezes the rotation), but when I try to use TCB Rotation To Zero it says that rotation was never frozen.

Here is the script:
Quote: */
-- Freeze TCB Rotation Only
macroScript FreezeTCBRotation
enabledIn:#("max", "viz") --pfb: 2003.12.12 added product switch
ButtonText:"Freeze TCB Rotation"
Category:"Animation Tools"
internalCategory:"Animation Tools"
Tooltip:"Freeze TCB Rotation"
(
fn FreezeTCBRotation =
(
local Obj = Selection as array
for i = 1 to Obj.count do
(
Try
(
local CurObj = Obj[i]
CurObj.rotation.controller = TCB_rotation()
CurObj.rotation.controller = Rotation_list()

/* "Localization on" */

CurObj.rotation.controller.setname 1 "Inital Rotation"
CurObj.rotation.controller.available.controller = TCB_rotation()
CurObj.rotation.controller.setname 1 "Inital Rotation"
CurObj.rotation.controller.setname 2 "Keyframe TCB"
CurObj.rotation.controller.SetActive 2

/* "Localization off" */
)

/* "Localization on" */

Catch( messagebox "A failure occurred while freezing an object's rotation." title:"FreezeTCBRotation")

/* "Localization off" */
)
select Obj
)

FreezeTCBRotation()
)


--Set TCB Rotation to Zero
MacroScript TCBRotationToZero
enabledIn:#("max", "viz") --pfb: 2003.12.12 added product switch
ButtonText:"TCB Rotation To Zero"
Category:"Animation Tools"
internalCategory:"Animation Tools"
Tooltip:"TCB Rotation To Zero"
(
fn TCBRotationToZero =
(
local Obj = Selection as array
for i = 1 to Obj.count do
(
Try
(
local CurObj = Obj[i]
CurObj.rotation.controller[2].x_rotation = 0
CurObj.rotation.controller[2].y_rotation = 0
CurObj.rotation.controller[2].z_rotation = 0
CurObj.rotation.controller[2].angle = 0
)

/* "Localization on" */

Catch( messagebox "One of the object's rotation was never frozen." title:"Freeze Transform")

/* "Localization off" */
)
select Obj
)

TCBRotationToZero()
)


I have simply replaced every sign of Euler_xyz with TCB_rotation.
I think problem is here:

Quote: Try
(
local CurObj = Obj[i]
CurObj.rotation.controller[2].x_rotation = 0
CurObj.rotation.controller[2].y_rotation = 0
CurObj.rotation.controller[2].z_rotation = 0
CurObj.rotation.controller[2].angle = 0
)

/* "Localization on" */

Catch( messagebox "One of the object's rotation was never frozen." title:"Freeze Transform")

I don't know how exactly re-set the values of TCB to zero, I have added CurObj.rotation.controller[2].angle = 0 line, but I think that's what is not working.

Could someone help please ???
 
Old 02 February 2005   #2
hi,
tcb controllers dont have separate tracks for each axis so try this instead

Try
(
local CurObj = Obj[i]
CurObj.rotation.controller.value = (quat 0 0 0 1)
)

mark tsang
__________________
Morph Controls Script
*NEW Website*
comming soon!!!



 
Old 02 February 2005   #3
I think that's it, thanks.

-EDIT-

I still get the error message (rotation was never frozen)

-EDIT-

SORRY, IT WORKS. Problem was that after freezing TCB I was using Rotation to Zero and Not TCB to Zero.
But I think that "CurObj.rotation.controller.value = (quat 0 0 0 1)" was important, I think it wouldn't work without that.

Last edited by ulukai33 : 02 February 2005 at 08:47 PM.
 
Old 02 February 2005   #4
Well, I have made some beta testing and it doesn't work as it should.

If I use Freeze TCB rotation, new controler is created, but when I use TCB Rotation to Zero, objects rotation is restored to zero rotation and not the frozen one.

Any ideas?
 
Old 02 February 2005   #5
are you by any chance zeroing the wrong controller? you should be zeroing the one in slot 2

mark
__________________
Morph Controls Script
*NEW Website*
comming soon!!!



 
Old 02 February 2005   #6
I'm doing it this way:
1.) I have put Freeze TCB Rotation and TCB Rotation To Zero to animation quad menu
2.) than I select a object, rotate it a bit (to take it out of default rotation)
3.) than - quad menu/freeze tcb rotation
4.) than I rotate the object to completely different orientation
5.) and finaly - quad/tcb rotation to zero

and the problem is that object rotation is not restored to frozen one, but to the default 0,0,0 (as it was when the object was created)

You think that the script is OKi?
 
Old 02 February 2005   #7
show me the entire script and i will see if i spot anything wrong

mark
__________________
Morph Controls Script
*NEW Website*
comming soon!!!



 
Old 02 February 2005   #8
Complete script:

Quote: /*
Freeze Transform MacroScript File



Author : Frederick Ruff

Revision History:

Dec 1 2000, created

Aug 22 2003, Larry Minton

12 dec 2003, Pierre-Felix Breton,
added product switcher: this macroscript file can be shared with all Discreet products
Feb 1 2005, Ulukai, changed to freeze/restore TCB rotation



This script adds tools for freezing a transform
This is done via adding a second controller to the controllers stack.
--************************************************** *********************************************
-- MODIFY THIS AT YOUR OWN RISK
*/
-- Freeze TCB Rotation Only
macroScript FreezeTCBRotation
enabledIn:#("max", "viz") --pfb: 2003.12.12 added product switch
ButtonText:"Freeze TCB Rotation"
Category:"Animation Tools"
internalCategory:"Animation Tools"
Tooltip:"Freeze TCB Rotation"
(
fn FreezeTCBRotation =
(
local Obj = Selection as array
for i = 1 to Obj.count do
(
Try
(
local CurObj = Obj[i]
CurObj.rotation.controller = TCB_rotation()
CurObj.rotation.controller = Rotation_list()

/* "Localization on" */

CurObj.rotation.controller.setname 1 "Inital Rotation"
CurObj.rotation.controller.available.controller = TCB_rotation()
CurObj.rotation.controller.setname 1 "Inital Rotation"
CurObj.rotation.controller.setname 2 "Keyframe TCB"
CurObj.rotation.controller.SetActive 2

/* "Localization off" */
)

/* "Localization on" */

Catch( messagebox "A failure occurred while freezing an object's rotation." title:"FreezeTCBRotation")

/* "Localization off" */
)
select Obj
)

FreezeTCBRotation()
)


--Set TCB Rotation to Zero
MacroScript TCBRotationToZero
enabledIn:#("max", "viz") --pfb: 2003.12.12 added product switch
ButtonText:"TCB Rotation To Zero"
Category:"Animation Tools"
internalCategory:"Animation Tools"
Tooltip:"TCB Rotation To Zero"
(
fn TCBRotationToZero =
(
local Obj = Selection as array
for i = 1 to Obj.count do
(
Try
(
local CurObj = Obj[i]
CurObj.rotation.controller.value = (quat 0 0 0 1)
)

/* "Localization on" */

Catch( messagebox "One of the object's rotation was never frozen." title:"Freeze Transform")

/* "Localization off" */
)
select Obj
)

TCBRotationToZero()
)


I don't know if formating can do something "bad" to the script, so here is a link to file:

http://test333.szm.sk/Macro_FreezeTCBRotation.zip

And thanks for the help!
Great site with great people here.
 
Old 02 February 2005   #9
as i susected you were zeroing the wrong controller - which is partial my fault as when i answered earlier i didn't specify that you need to indicate which controller.- any way

fn TCBRotationToZero =
(
local Obj = Selection as array
for i = 1 to Obj.count do
(
Try
(
local CurObj = Obj[i]
CurObj.rotation.controller[2].value = (quat 0 0 0 1)
)

/* "Localization on" */

Catch( messagebox "One of the object's rotation was never frozen." title:"Freeze Transform")

/* "Localization off" */
)
select Obj
)

TCBRotationToZero()


mark
__________________
Morph Controls Script
*NEW Website*
comming soon!!!



 
Old 02 February 2005   #10
Oh..., you thought by "if I'm zeroing wrong controller" if I'm zeroing wrong controller in script? I thought If I'm not using the script somehow wrong.... But I really never did anything in maxscript or any other programming language, so I apologize for my amateurism .

It works perfectly now!
Really, really BIG THANK YOU !!!

There is a one disadvantage with internet, I really don't like that I can't buy you a beer (or whatever you are drinking) on times like these .

SO ONCE AGAIN - THANKS
 
Old 02 February 2006   #11
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 07:00 AM.


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