We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have something like this,
push(); // Start head placement. translate( headPosition, headPosition ); rotate(headRotation); translate( -headPosition, -headPosition ); push(); // Start Eye1 placement. translate( eye1Position, eye1Position ); image(imgEye, 0, 0); pop(); // End Eye1 placement. push(); // Start Eye2 placement. translate( eye2Position, eye2Position ); image(imgEye, 0, 0); pop(); // End Eye2 placement. image(imgHead, 0, 0); pop(); // End head placement.
So basically using a chain of push/pop matrix to place layers in relation to each other. Is there an easy way to find my global position?
If you did something like this,
push() translate(100, 100); a = retrieveGlobalPosition(); push() translate(150, -66); push(); translate(-27, 50); b = retrieveGlobalPosition(); pop(); c = retrieveGlobalPosition(); pop(); pop();
then a should be [100, 100]. b should be [223, 84] and c should be [250, 34]. Or something along those lines. Hopefully that makes sense. So I want to be able to easily tell where an eye is located on the canvas and make calculations based on this position.
Is this possible? Or is there a better way to achieve this? Maybe using p5.Vector ?
This is fairly simple arithmetic when all you're doing is translating, and you could probably just keep track of your transforms via a variable. But once you start using rotate() as I did in my first example its going to get very complicated.
Eventually I think it would make sense to start parenting these objects to each other but my programming skills are not there yet.