We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Setting the origin (Read 1190 times)
Setting the origin
Nov 23rd, 2005, 8:53pm
 
I have a series of triangles forming a model and would like to set one vert as the origin, is it possbile? at the moment i have a 3d model but when i try to rotate it, it rotates around one of its feet instead of the center of the model.
Re: Setting the origin
Reply #1 - Nov 23rd, 2005, 9:32pm
 
Can you please show us your example?

I'm guessing that you're using some 3D import library, and it's importing it at an origin not specified by you.

OR... you're making really simple geometry in processing but you didn't make it around the center (0,0), and that's why your geometry is rotating from (0,0) as one of your geometry's legs...
Re: Setting the origin
Reply #2 - Nov 23rd, 2005, 9:38pm
 
i exported a 3d model as raw data in another prog, manually inputed the vertices into triangle polygons in processing. Ive no problem with shapes i put in myself in processing but i do with the model.
Re: Setting the origin
Reply #3 - Nov 23rd, 2005, 10:08pm
 
...

Can you please elaborate on

Quote:
Ive no problem with shapes i put in myself in processing but i do with the model.

Re: Setting the origin
Reply #4 - Nov 23rd, 2005, 10:31pm
 
i just mean if i like put a box into processing i can rotate on its spot on each axis etc. With the data for the model tho ive put it in a method i call the method try to rotate it the exact same way as anything else but it rotates around its foot instead of the center. If i knew how to set the origin in that method to a vert in the center of the model maybe i might be able to get it to work. So if anyone has information on anything related to the origin it would be a great help.
Re: Setting the origin
Reply #5 - Nov 23rd, 2005, 11:35pm
 
It sounds like the co-ordinates 0,0,0 in your model is at one corner of it, if that's so, then any rotate call is going to rotate it around that point. You can get it to appear to rotate aroudn the origin, by doing a rotate, then translate by half the width/height/depth of the object, before drawing it (I think)

As for why it works on box() etc with no hassle, it's because those objects are centered around 0,0,0 e.g. some verticies have negative values compared to the position you place the object.

This code will draw a cube, notice how half the co-ordinates are negative, and they're evenly spread about the position 0,0,0, and hence will be able to be rotated around the origin without any messing around.
Code:
beginShape(QUADS);
vertex(-5,-5,-5); vertex(5,-5,-5); vertex(5,5,-5); vertex(-5,5,-5);

vertex(-5,-5,5); vertex(5,-5,5); vertex(5,5,5); vertex(-5,5,5);

vertex(-5,-5,-5); vertex(-5,5,-5); vertex(-5,5,5); vertex(-5,-5,5);

vertex(5,-5,-5); vertex(5,5,-5); vertex(5,5,5); vertex(5,-5,5);

vertex(-5,-5,-5); vertex(5,-5,-5); vertex(5,-5,5); vertex(-5,-5,5);

vertex(-5,5,-5); vertex(5,5,-5); vertex(5,5,5); vertex(-5,5,5);
endShape();
Re: Setting the origin
Reply #6 - Nov 25th, 2005, 4:07pm
 
the translate() function will set the origin so that you can rotate objects, etc.
Re: Setting the origin
Reply #7 - Dec 6th, 2005, 12:44am
 
You can create around any origin.

You have to first translate back to (0,0) , do the desired rotation and then translate back.
Page Index Toggle Pages: 1