# [JASS]Turning camera

Status
Not open for further replies.

#### wd40bomber7

Level 11
OMG AFTER ALL THAT WORK!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Jeez, I spent so much time setting up this post and I realize SetCameraField needs to go after all my other code. Then it works fine. SOB!

Anyway If you'd still like to see my post just open up the hidden text.

(Please refer to the attached diagram)
Key
Circle = Camera
Square = Camera Target (This is the basis of all mathematical operations, it is the only given data)
Black Line = Line of sight
Red Line = Current mathematical operation
Grey Square = Represents the new target
Circle = The way the camera rotates.
First Diagram
In the upper right you see a box.
This shows how the camera rotates. It rotates relative to itself but keeps the target in view at all times never turning the direction of the rotation.
Second Diagram
In the upper left you see a box. This box shows how I want the camera to rotates. When you rotate you automatically see something different. Your view rotates with your perspective angle.
Third Diagram
This shows my current method of trying to move the camera. The only known fact is the position of the first camera target and how much I would like to rotate.

So in the first frame, I use an equivalent of polar projection to determine point A. (Using the previous rotation, not the new rotation)
In the second frame I apply my new rotation, and use *note* Post has been 100% Rewritten.

(Please refer to the attached diagram)
Key
Circle = Camera
Square = Camera Target (This is the basis of all mathematical operations, it is the only given data)
Black Line = Line of sight
Red Line = Current mathematical operation
Grey Square = Represents the new target
Circle = The way the camera rotates.
First Diagram
In the upper right you see a box.
This shows how the camera rotates. It rotates relative to itself but keeps the target in view at all times never turning the direction of the rotation.
Second Diagram
In the upper left you see a box. This box shows how I want the camera to rotates. When you rotate you automatically see something different. Your view rotates with your perspective angle.
Third Diagram
This shows my current method of trying to move the camera. The only known fact is the position of the first camera target and how much I would like to rotate.

So in the first frame, I use an equivalent of polar projection to trace backward to determine point A. (Without applying my rotation change, I use the previous rotation.)
In the second frame I apply the angle change. Then I use polar projection to trace forward to find point C. I apply it as my new camera target.
Finally I rotate my camera location to the new location.

However this doesn't seem to work. It ends up with exactly the same camera movement as I set out to change. If you remove a few lines of code it makes the camera crazy. (This proving that those lines of code are doing something)
JASS:
``````    set NX = You_x - CAM_DIST * Cos(You_Facing * bj_DEGTORAD)//Find point 'O'
set NY = You_y - CAM_DIST * Sin(You_Facing * bj_DEGTORAD)
set You_Facing = CAT(You_Facing + vm) //Apply angle change
set NX = NX + CAM_DIST * Cos(You_Facing * bj_DEGTORAD) //Find new point 'you'
set NY = NY + CAM_DIST * Sin(You_Facing * bj_DEGTORAD)
call SetCameraField(CAMERA_FIELD_ROTATION,You_Facing,0)
call CameraSetupSetDestPosition(gg_cam_MAIN,You_x,You_y, 1)
call CameraSetupApply(gg_cam_MAIN,true,false)
call SetCameraPosition(NX,NY)
set You_x = NX
set You_y = NY``````
You_x and You_y are the first camera's destination point.
You_Facing is the angle. vm is the angle change. CAT just makes the angle valid. (-1 = 359)

#### Attachments

• CameraMovement.JPG
22.1 KB · Views: 362
Last edited:

#### Silvenon

Level 13
Nice post, btw. It really touched me.

Status
Not open for further replies.

Replies
1
Views
418
Replies
5
Views
645
Replies
4
Views
670
Replies
2
Views
1K
Replies
11
Views
855