• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Turning camera

Status
Not open for further replies.
Level 11
Joined
Aug 25, 2006
Messages
971
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
    CameraMovement.JPG
    22.1 KB · Views: 362
Last edited:
Status
Not open for further replies.
Top