Simple but hard

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
  08 August 2005
Unhappy Simple but hard

Hi all,

I'd like to assign a 1st selected objects rotate values to a float variable, then apply those values to the secondly selected objects varibles.

This is what I have so far:
string $newone[] = `ls -selection`;
float $newobjectrot[] = `xform -q -ws -rotation $newone`;

/// why doesn't this work? ( I want to take the values and apply
// it to the rotation of this other object)

rotate $newobectrot pSphere1;

??? This doesn't work for some reason. Any ideas??
 
  08 August 2005
string $newone[] = `ls -selection`;

float $newobjectrot[] = `xform -q -ws -rotation $newone`;

$newobjectrotX=$newobjectrot[0];

$newobjectrotY=$newobjectrot[1];

$newobjectrotZ=$newobjectrot[2];

// just split the array to the single axis - then it works like a charm..

rotate $newobjectrotX $newobjectrotY $newobjectrotZ pSphere1;
 
  08 August 2005
//get selected object
string $sel[]=`ls -sl`;
//re-assign first element in array
string $firstObject = $sel[0];
//re-assign second element in array
string $secondObject = $sel[1];
//Get rotation values of first element
float $rot[]=`xform -q -ws -rotation $firstObject`;
//assign them to second object
xform -ws -rotation $rot[0] $rot[1] $rot[2]  $secondObject;
 
  08 August 2005
Wink thanks

Thanks guys. That turned out to be very useful info. But now Im stuck when I go to move the object to the new objects position.

Say for example the object to be moved has been frozen a few times and is somewhere in worldspace. It assumes that that area it is in is 0 0 0 xyz, when in fact its somewhere 5 units in the x and 4 units in the y. How do I get it's current "Actual position" in the world?
 
  08 August 2005
You should use this then:
xform -q -ws -rp; 
 
  08 August 2005
Hey. I've used the drGonzo code, and completed it. Now it checks the rotationPivot in the world space, an then he applies those values in the absolute mode using the move command. its the same thing as going to that text box at right of render globals icon, choose "Numeric Input: Absolute", and assign the values that the xform -q -ws -rp returned, but its done all in one time by the code. I think this will work for you. Cheers guys...


//check the objects that are selected
  string $sel[]=`ls -sl`;
  //the first object in the array
  string $firstObject = $sel[0];
  //the second object in the array
  string $secondObject = $sel[1];
  //Get the rotation values of first object
  float $rot[]=`xform -q -ws -rotation $firstObject`;
  //Assign the rotation values on to the seconf object
  xform -ws -rotation $rot[0] $rot[1] $rot[2]  $secondObject;
  //Get the translation values of first object
  float $trans[]=`xform -q -ws -rp $firstObject`;
  //Assign the translation values on to the second Object
  move -rpr $trans[0] $trans[1] $trans[2] $secondObject;
  //Print the done Work
  print "Done: The objects are in same place now!";


-S


P.S.: This also works for translation!
__________________
My name is Leo Getz!! Anything you need, Leo gets, get it?!?!?

My Homepage

Last edited by Stucky : 08 August 2005 at 09:34 AM.
 
  08 August 2005
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 09:52 AM.


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