# camera/aim XYZ to angle

### #1

Posted 11 July 2013 - 12:40 AM

Or is it possible to get the Z angle of a searchlight?

### #2

Posted 11 July 2013 - 10:28 AM

*A*pointing to the point

*B*. Isn't the

**GET_ANGLE_BETWEEN_2D_VECTORS**(05A4) command up to your requirements?

### #3

Posted 11 July 2013 - 12:11 PM Edited by fireguy109, 11 July 2013 - 12:14 PM.

E: this would work for static cameras like during some cutscenes I suppose, but it would be pretty difficult to do on the fly.

### #4

Posted 11 July 2013 - 12:44 PM

CODE |

068E: get_camera_target_point_to [email protected] [email protected] [email protected] 068D: get_camera_position_to [email protected] [email protected] [email protected] 0063: [email protected] -= [email protected] // (float) 0063: [email protected] -= [email protected] // (float) 0604: get_Z_angle_for_point [email protected] [email protected] store_to [email protected] |

### #5

Posted 11 July 2013 - 01:00 PM

*068D*and

*068E*. For some reason, it doesn't produce the same result, so I would advice to use Silent's method which have been pointed out so many times (with a quick search you would have avoided to formulate your question).

### #6

Posted 11 July 2013 - 01:10 PM Edited by SilentPL, 11 July 2013 - 01:18 PM.

* If I'm wrong, excuse me - I haven't been looking into it now, but I remember that some vectors-related command was IF and SET.

EDIT:

Checked it now. 05A4 uses arcus cosinus:

http://www.wolframal...nput/?i=acos(x)

0604 uses arcus tangent with two arguments:

http://www.wolframal.../?i=atan2(1, x)

EDIT2:

No wonder they are returning different values:

http://www.wolframal...an2..., acos(x)

I'd stick to 0604

### #9

Posted 11 July 2013 - 02:21 PM Edited by Wesser, 11 July 2013 - 10:53 PM.

Actually, there is a simpler and faster way to retrieve the camera Z angle:

CODE |

const INV_RAD_TO_DEG = -57.324841 end 0A8D: [email protected] = read_memory 0x00B6F178 size 4 virtual_protect 0 // CCamera.m_fYawAngle [email protected] *= INV_RAD_TO_DEG 0656: get_angle [email protected] absolute_degrees_to [email protected] |

### #11

Posted 11 July 2013 - 03:34 PM Edited by Wesser, 11 July 2013 - 10:53 PM.

**Method 1**(*m_fAimPitch*gets set only when the player is aiming on 3rd person view):**CODE**const

INV_RAD_TO_DEG = -57.324841

end

0A8D: [email protected] = read_memory 0x00B7CDF0 size 4 virtual_protect 0 // CPlayer.m_clPlayerData.m_fAimPitch

[email protected] *= INV_RAD_TO_DEG

0656: get_angle [email protected] absolute_degrees_to [email protected]**Method 2**:**CLEO3 compatible**:**CODE**const

INV_RAD_TO_DEG = -57.324841

end

0A9F: [email protected] = current_thread_pointer

[email protected] += 0x10 // CScriptThread.m_iBaseAddress

0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0

[email protected] -= @popFloat

0AA8: call_function_method 0x0050AD40 struct 0x00B6F028 num_params 0 pop 0 fPitchAngle [email protected] // CCamera__getPitchAngle

0AA7: call_function [email protected] num_params 0 pop 0 fValue [email protected]

[email protected] *= INV_RAD_TO_DEG

0656: get_angle [email protected] absolute_degrees_to [email protected]

// [...]

:popFloat

hex

83EC 04 // sub esp, 4

D95C24 00 // fstp [esp+4-4]

8B4424 00 // mov eax, [esp+4-4]

83C4 04 // add esp, 4

C3 // retn

end**CLEO4 only**:**CODE**const

INV_RAD_TO_DEG = -57.324841

end

0AA8: call_function_method 0x0050AD40 struct 0x00B6F028 num_params 0 pop 0 fPitchAngle [email protected] // CCamera__getPitchAngle

0AE9: pop_float [email protected]

[email protected] *= INV_RAD_TO_DEG

0656: get_angle [email protected] absolute_degrees_to [email protected]

### #12

Posted 11 July 2013 - 05:33 PM

QUOTE (Wesser @ Thursday, Jul 11 2013, 08:00) |

Ofcourse, that command was meant to be combined with 068D and 068E. |

Ah, my apologies. I'm not very could with SA coding, don't know all the opcodes.

### #13

Posted 11 July 2013 - 07:13 PM Edited by SilentPL, 11 July 2013 - 07:40 PM.

QUOTE (Wesser @ Thursday, Jul 11 2013, 16:21) |

Actually, there is a simpler and faster way to retrieve the camera Z angle: |

Is is actually CCamera.CCam[0].Alpha? CCam has both Alpha and Beta, so I guess you could use them to get Y/Z (up/down and left/right) angle.

### #14

Posted 11 July 2013 - 10:15 PM Edited by Wesser, 11 July 2013 - 10:52 PM.

*CCamera*'s cams. I would prefer the "Alpha" value as stated by you, even though the amplitude of the angle is almost the same as the value given by that function except for their direction, but it isn't

*FOV*dependent and thus a bit inappropriate (I don't know how much the

*FOV*would compromise the correct result, if it does). Anyway, here is the code in case you are interested (I might screwed up the angle direction):

CODE |

const RAD_TO_DEG = 57.324841 INV_RAD_TO_DEG = -57.324841 end 0A8D: [email protected] = read_memory 0x00B6F081 size 1 virtual_protect 0 // CCamera.m_cActiveCam [email protected] *= 0x0238 // sizeof(CCam) [email protected] += 0x00B6F19C // CCamera.m_astCams 0A8E: [email protected] = [email protected] + 0xAC // CCamera.m_fPitchAngle 0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0 [email protected] *= INV_RAD_TO_DEG 0656: get_angle [email protected] absolute_degrees_to [email protected] 0A8E: [email protected] = [email protected] + 0xBC // CCamera.m_fYawAngle 0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0 [email protected] *= RAD_TO_DEG [email protected] += 90.0 0656: get_angle [email protected] absolute_degrees_to [email protected] |

### #15

Posted 14 July 2013 - 11:54 AM Edited by Wesser, 14 July 2013 - 12:02 PM.

*05A4*opcode computes the angle between two points around a third point and so between two

*2D*vectors. See the sample script below:

CODE |

const POINT_A_X = 0.0 POINT_A_Y = 1.0 POINT_B_X = 0.0 POINT_B_Y = -1.0 POINT_C_X = 1.0 POINT_C_Y = 0.0 end var [email protected]: Float [email protected]: Float [email protected]: Float [email protected]: Float [email protected]: Float [email protected]: Float end [email protected] = POINT_A_X [email protected] = POINT_A_Y [email protected] = POINT_B_X [email protected] = POINT_B_Y [email protected] = POINT_C_X [email protected] = POINT_C_Y // Get vector A. [email protected] -= [email protected] [email protected] -= [email protected] // Get vector B. [email protected] -= [email protected] [email protected] -= [email protected] 05A4: get_angle_between_vectors_origin_to [email protected] [email protected] and_origin_to [email protected] [email protected] store_to [email protected] |

It will return 90 degrees.

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users