WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   how to "spin/spinto" an rectangular around its center or edge? (https://forum.worldviz.com/showthread.php?t=2803)

znchb 06-27-2010 12:50 AM

how to "spin/spinto" an rectangular around its center or edge?
 
Please see the program below, I build an rectangular using polygon, and I want to make it spin around its Center point or around its Edge Line of rectangular ?
Is there anyone would like to help me?
Thank you very much!

import viz
import vizact
viz.go()
viz.clearcolor(viz.WHITE)
bg = viz.add('tut_ground.wrl')
pos = bg.getPosition()
viz.MainView.setPosition(pos[0],pos[1]+5,pos[2]-20)
A = [pos[0]-2, pos[1]+8, pos[2]+10 ]
B = [pos[0]+2, pos[1]+8, pos[2]+10 ]
C = [pos[0]+2, pos[1]+4, pos[2]+10 ]
D = [pos[0]-2, pos[1]+4, pos[2]+10 ]
viz.startlayer(viz.POLYGON)
viz.vertex(A)
viz.vertex(B)
viz.vertex(C)
viz.vertex(D)
Rectangular = viz.endlayer()
Rectangular.color(viz.RED)
#make it spin/spinto
#Rectangular.addAction(vizact.spinto(0,0,1, 180, 30))
Rectangular.addAction(vizact.spin(0,0,1, 90))
#---- How to make it spin around the Center of the rectangular ?-------
#---- or how to make it spin around the Edge Line of rectangular ? -----

znchb 06-27-2010 07:25 PM

Is there anyone can help me? I really need to solve this problem, which is one function of my project.
I will be very appreciated.

farshizzo 06-28-2010 09:45 AM

You should create the rectangle so that it is centered around the axis you want it to rotate about. Instead of adding the position to the vertex positions, specify the vertices so they are centered about the origin (0,0,0), and then add the position to the entire model using the Rectangular.setPosition command.


All times are GMT -7. The time now is 05:59 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC