Java-Gaming.org Hi !
 Featured games (83) games approved by the League of Dukes Games in Showcase (539) Games in Android Showcase (132) games submitted by our members Games in WIP (603) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 [solved]First Person LookAt Coords /w some code  (Read 1572 times) 0 Members and 1 Guest are viewing this topic.
Cakey

Junior Devvie

 « Posted 2009-03-17 01:44:28 »

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 .
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22 `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

Cakey

Junior Devvie

 « Reply #1 - Posted 2009-03-18 19:20:41 »

To be more specific...

I know you guys have done first person perspective... How'd you all do it?

cylab

JGO Ninja

Medals: 55

 « Reply #2 - Posted 2009-03-18 19:36:31 »

Don't apply a delta-rotation on the coordinates from the last frame. Instead store the overall rotation angles in member variables. Everything else depends on the order of the rotations.

Mathias - I Know What [you] Did Last Summer!
Cakey

Junior Devvie

 « Reply #3 - Posted 2009-03-18 19:58:35 »

On GameDev.net BobJahnova helped me out.

 1  2  3 `tempX = -(float)(Math.cos(Xangle) * Math.sin(Yangle));tempZ = (float)(Math.cos(Xangle) * Math.cos(Yangle));tempY = (float) Math.sin(Xangle);`

is the proper vector thing haha Thanks though cylab!

cylab

JGO Ninja

Medals: 55

 « Reply #4 - Posted 2009-03-18 20:10:29 »

Maybe just use a vector math library vecmath, openmali, joglutils...

Mathias - I Know What [you] Did Last Summer!
Cakey

Junior Devvie

 « Reply #5 - Posted 2009-03-18 20:37:48 »

Didn't even know such things existed haha. I'll have to look into those!

DzzD
 « Reply #6 - Posted 2009-03-19 13:54:29 »

hum... better that you do it yourself once, after use any libraries but for the first time do it yourself, this is really a simple problem what you need is only three method to rotate around X,Y,Z then use them in the correct order. usually for fps (if Y is up an Z going front of you) you just have to rotate around X then around Y.usually for FPS you wont rotate around Z but if you wich to do some kind of roll just rotate around Z at first.

Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 Add your game by posting it in the WIP section, or publish it in Showcase. The first screenshot will be displayed as a thumbnail.
 rwatson462 (35 views) 2014-12-15 09:26:44 Mr.CodeIt (26 views) 2014-12-14 19:50:38 BurntPizza (60 views) 2014-12-09 22:41:13 BurntPizza (95 views) 2014-12-08 04:46:31 JscottyBieshaar (55 views) 2014-12-05 12:39:02 SHC (71 views) 2014-12-03 16:27:13 CopyableCougar4 (73 views) 2014-11-29 21:32:03 toopeicgaming1999 (133 views) 2014-11-26 15:22:04 toopeicgaming1999 (124 views) 2014-11-26 15:20:36 toopeicgaming1999 (34 views) 2014-11-26 15:20:08
 Rayvolution 37x basil_ 31x LiquidNitrogen 27x HeroesGraveDev 27x kpars 18x BurntPizza 18x kevglass 17x appel 17x Gibbo3771 15x gouessej 14x princec 13x SHC 11x Ecumene 10x Riven 10x KevinWorkman 9x VIrtueeL 9x
 Resources for WIP gamesby kpars2014-12-18 10:26:14Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27Resources for WIP games2014-08-01 16:20:17Resources for WIP games2014-08-01 16:19:50List of Learning Resources2014-07-31 16:29:50
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org