Rotating Spherical components around a common axis

General discussion related to SketchUp Pro and Make

Rotating Spherical components around a common axis

Postby wozabee » Fri Jun 10, 2011 6:02 am

Hi guys,
Here's the mysterious "moving spherical shells" doohickey I've been working on.
Sun_Face_02.zip

What started as a fun school project with daughter has somewhat snowballed after I theorized that doing the Sun THIS way in Sketchup might be possible. Presently I've just got it to a stage where the 2 "cloud" eyebrows, cheeks, eyes (just both pupils on the same shell underneath), and upper & lower lips, are all made into components, each with all their axis commoned to a point in the back (marked by the arrow tip).
Sun_Face_02a.jpg


I still feel that ideal solution to move these bits around would be to modify the "Key rotate" plug-in, as it does most of precisely what I wanted, and can be modified to do 1 degree steps. So far though, after 2 weeks of beginners level Ruby study, and poking about inside Key Rotate, I'm still none the wiser as to exactly how to change what to get it to rotate the components around anything other than the physical centers of the bits themselves.
Sun_Face_02.jpg


Presently I just need to "pose" the face and its bits in lots & lots of positions/expressions. But ultimately I''d love to use it as a fun key-frame animation learning/exercise.

Thanks once again everybody.

Oh, and here's the previous thread:
viewtopic.php?f=15&t=37372
0

wozabee 
 

Re: Rotating Spherical components around a common axis

Postby kyyu » Fri Jun 10, 2011 5:11 pm

Nice model! I want to learn more on the modeling front myself. I made a few changes to the "key rotate" plugin and I think it now does what you want. I didn't change much, if you look at the code. I commented out the few lines I changed, so you can see what I changed.

You need to remove the current "key rotate" plugin or they will conflict. Changing the file extention to .txt will do, if you don't want to delete it.

ky_Key Rotate_modified for sun animation.rb


-Kwok
0

kyyu 
 

Re: Rotating Spherical components around a common axis

Postby wozabee » Sun Jun 12, 2011 12:18 pm

WOW, WOW ... and tripple WOW!

Thank you sooooo much Kwok!!!

It works a TREAT!!!

What took me ages before I can now just clickety-click 1 degree at a time to reposition the parts anywhere. It just struck me that this might be perfect for anyone wanting to perhaps play "Gondwanaland" by "jigsaw-ing" all the continents on an Earth globe. maybe operating multi-part hemispherical "Airlock" doors on a starship... The mind boggles.

I'm still wading through trying your mods to see what you changed to do the magic. Do the pieces rotate on the origin now or the component centers?

The only thing now is the way using the home/end keys appear to rotate the parts in the z true axis. If you'll notice they "dig in" to the surface as you rotate them.

I wonder, is there a way to get that function still rotating about the component's volume, but centered toward the same axis as the others? Or would that be an extremely complicated thing to do? Somehow, it seems like that might make this modification to your plug-in truly universal for spherical surface work.

At any rate, thanks so much for your help.

Woz




I made a few changes to the "key rotate" plugin and I think it now does what you want. I didn't change much, if you look at the code. I commented out the few lines I changed, so you can see what I changed.

You need to remove the current "key rotate" plugin or they will conflict. Changing the file extention to .txt will do, if you don't want to delete it.

ky_Key Rotate_modified for sun animation.rb


-Kwok[/quote]
0

wozabee 
 

Re: Rotating Spherical components around a common axis

Postby kyyu » Sun Jun 12, 2011 7:26 pm

Woz,

I'm still wading through trying your mods to see what you changed to do the magic. Do the pieces rotate on the origin now or the component centers?

The x and y now rotate about the origin point. The z still rotates about the component's center point. Remember, the are two key parameters. The point of rotation and the axis of rotation.

Other than changing the 90 degrees to 1 degrees, I only changed 4 other lines. They are the ones commented out:

Code: Select all
def rotate_X(angle)
   @sel.each do |e| 
       # pt = e.bounds.center
       pt = [0,0,0]
               v = Geom::Vector3d.new(1,0,0)
       tr = Geom::Transformation.rotation(pt,v,angle.degrees)
       Sketchup.active_model.active_entities.transform_entities(tr,e)
   end
end

def rotate_Y(angle)
   @sel.each do |e| 
       # pt = e.bounds.center
       pt = [0,0,0]
               # v = Geom::Vector3d.new(0,1,0)
               v = Geom::Vector3d.new(0,0,1)
       tr = Geom::Transformation.rotation(pt,v,angle.degrees)
       Sketchup.active_model.active_entities.transform_entities(tr,e)
   end
end

def rotate_Z(angle)
   @sel.each do |e| 
       pt = e.bounds.center
               # v = Geom::Vector3d.new(0,0,1)
               v = Geom::Vector3d.new(0,-1,0)
       tr = Geom::Transformation.rotation(pt,v,angle.degrees)
       Sketchup.active_model.active_entities.transform_entities(tr,e)
   end
end


The only thing now is the way using the home/end keys appear to rotate the parts in the z true axis. If you'll notice they "dig in" to the surface as you rotate them.

Easy enough to fix. I changed the local Z rotation vector from the y axis to a vector pointing to the center of the component. This vector is basically the same as the rotation point (component's center), since the start point is on the origin [0,0,0]. Basically, it's now rotating about the radius of the sphere. I just changed 1 line:

Code: Select all
def rotate_Z(angle)
   @sel.each do |e| 
       pt = e.bounds.center
               # v = Geom::Vector3d.new(0,0,1)
               # v = Geom::Vector3d.new(0,-1,0)
               v = Geom::Vector3d.new(pt.x, pt.y, pt.z)
       tr = Geom::Transformation.rotation(pt,v,angle.degrees)
       Sketchup.active_model.active_entities.transform_entities(tr,e)
   end
end


Here is the new version:
ky_Key Rotate_modified for sun animation_02.rb


-Kwok
0

kyyu 
 

Re: Rotating Spherical components around a common axis

Postby Jim57 » Mon Jun 13, 2011 4:41 am

Beautiful!

But I gotta ask— what's the light source for the shadows?

;—)


Jim
0

Jim57 
 

Re: Rotating Spherical components around a common axis

Postby wozabee » Mon Jun 13, 2011 5:58 am

It's... it's....
"gahhd. I'm a doctor, not a scientist Jim!"



Jim57 wrote:Beautiful!

But I gotta ask— what's the light source for the shadows?

;—)


Jim
0

wozabee 
 

Re: Rotating Spherical components around a common axis

Postby wozabee » Mon Jun 13, 2011 12:50 pm

It works just absolutely spot-on now!!

...now to re-learn some Keyframe animation & such, and see if I can put this chap through his paces.

Thanks so much again Kwok!
0

wozabee 
 

Re: Rotating Spherical components around a common axis

Postby kyyu » Mon Jun 13, 2011 6:14 pm

wozabee wrote:It works just absolutely spot-on now!!

...now to re-learn some Keyframe animation & such, and see if I can put this chap through his paces.

Thanks so much again Kwok!

Woz, you're welcome. Would love to see the animation, when you are done. :enlight:
0

kyyu 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to SketchUp Pro & Make Discussions

Who is online

Users browsing this forum: jcrowley109 and 2 guests

Visit our sponsors: