I hate feeling needy and posting on this board like three times a week but I guess it’s a good thing this board exists other-wise my programming problems wouldn’t get solved :D.
public Point3D translateByAngle(float oX, float oY, float oZ,
float length,
float angleX,float angleY,float angleZ){
float rad, xOld, yOld, zOld;
float x = length, y = 0,z = 0;
//X ANGLE
rad = angleX * (float)(Math.PI / 180);
xOld = x;zOld = z;
z = (float)((zOld * Math.cos(rad)) - (xOld * Math.sin(rad)));
x = (float)((zOld * Math.sin(rad)) + (xOld * Math.cos(rad)));
//Y ANGLE
rad = angleY * (float)(Math.PI / 180);
yOld = y; zOld = z;
y = (float)((yOld * Math.cos(rad))- (zOld * Math.sin(rad)));
z = (float)((yOld * Math.sin(rad)) + (zOld * Math.cos(rad)));
//Z ANGLE
rad = angleZ * (float)(Math.PI / 180);
yOld = y; xOld = x;
x = (float)((xOld * Math.cos(rad)) - (yOld * Math.sin(rad)));
y = (float)((xOld * Math.sin(rad)) + (yOld * Math.cos(rad)));
return new Point3D(oX + x, oY + y, oZ + z);
}
I’m using this code to calculate the point in 3-Space for my camera to look at. It pretty much takes the angle of the camera and the location of the camera and the distance of sight and calculates a new point(LookAt point).
Though there’s some minor problems with it for what I am trying to do. such as if I rotate the Y-Axis the angle in which I am looking up at then changes. When I want it to stay at the same “pitch”.
Is there a Z-Rotation for the camera? Is this not the series of equations I should be using? Is there a better way to do this?
My main problem is having my shooting script work with my camera. So I use that same method to shoot as well.
Thanks for reading, if you don’t understand the problem I can post, you-tube video, a diagram a better explanation, and/or code. Just lemme know