Rotating Cylinders

View previous topic View next topic Go down

Rotating Cylinders

Post by Tstageman on Fri Apr 20, 2012 9:50 am

Guys,

Just a quick question that I'm sure someone will know the answer to. I am currently building an object that has handrails, and I am experiencing great difficulty in rotating a particular cylinder I am using for one of these handrails. I have 3 cylinders, all at the same x value, +2.6. The first one is horizontal, about 25m long, and then one that is vertical to be the end support for the handrail. However I can't get the cylinder to rotate in the correct direction, I need it to be 45 degrees but parallel to the x axis if this makes sense. Like so:
__________
/
/
/
/
/
/
|
|
|
|

Any ideas?

Thanks

Tom
avatar
Tstageman

Posts : 154
Join date : 2011-10-21

Back to top Go down

Re: Rotating Cylinders

Post by Dexter on Fri Apr 20, 2012 10:09 am

Rotating Cylinders is easy.
1. Always remember to use 1 rotate rotate command per axis
2. Use rotate BEFORE translate, because the other way around creates the cylinders shifted in an unintended way.

Like This:
Code:
CreateMeshBuilder,
Cylinder, 16, 0.5,0.5,1; (Example dimensions)
Rotate, 1,0,0,45; (Rotates 45 degrees along X-axis)
Rotate, 0,0,1,45; (Rotates 45 degrees along Z-axis, in your case, only a simple rotation along one axis will be needed, this is just an example)
Translate, 0,0,3; (Shifts the ALREADY ROTATED cylinder by 3 meters along Z-axis)
SetColor, 0,0,255; (Assigns a color, this example would be blue)

Hope this helps, you can replace the example values by any of your own and use a texture instead of SetColor, of course.
Also, if you don't need the basis of the cylinder, you can omit it and save some performance by not rendering this complex face. In such case, use

Cylinder, 16, -0.5,-0.5,1; (Example dimensions)
avatar
Dexter

Posts : 1842
Join date : 2011-07-08
Age : 32
Location : Brno, Czech republic

http://www.brnobve.eu

Back to top Go down

Re: Rotating Cylinders

Post by Tstageman on Fri Apr 20, 2012 2:00 pm

Thanks very much Derryck, managed to sort it now, much appreciated!

Tom
avatar
Tstageman

Posts : 154
Join date : 2011-10-21

Back to top Go down

Re: Rotating Cylinders

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum