We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello all, I'm using P3D to try and draw a group of objects each with their own unique position in space and facing direction. For now, they're just boxes. I'm messing with transpose and rotateX/Y/Z, along with push and pullMatrix, but I can't wrap my head around it to place the boxes in the set positions. Does anyone have a good tutorial or example I can look at? Everything I can find just seems to use objects to show lighting examples. Thank you.
Answers
Can you say more about what you are trying to do, or share a short demo sketch?
By transpose, do you mean
translate()
? By pullMatrix, do you meanpopMatrix()
?My guess without seeing any code is that you want to use this approach:
pushMatrix()
translate()
that object to the right relative pointrotateX()
/ Y / Z it to the correct facing.popMatrix()
to return to the origin...then repeat for the next object.
Although, depending on your system of relative reference and how you imagine the space, you might want to do rotating before translating etc.
Have you read the reference pages for the commands listed above, and have you looked at:
...these cover the basics of using the relative positioning commands and the matrix stack in 2D, then 3D contexts.
I agree: Do the tutorials.
Here is a simple example.
Basically, normally you draw on a canvas (x,y). In 3D you draw in a room with a depth (x,y,z). Now imagine a table. You place something (an apple) on the surface. Move it right, you increase x. Move it towards you you increase z. Move it up above the table you decrease y. You use
translate (x,y,z);
.Remember:
Code with functions and rotation.
To have different rotations, make
float a1,a2,a3;
etc. and pass each of them as a parameter to the box function.Chrisir ;-)