Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

[Q] Camera Look At Coordinates


Sagoza
 Share

Recommended Posts

Does anyone know how to get the coordinates of a certain point that we are looking at?

 

 

Link to comment
Share on other sites

well you need to get the camera rotation and calculate the direction from this. If you look at source code for the scripthookdotnet you will have examples on how to do the calculations with the vector3s. Then with the direction you can calculate a position in the camera's direction at a range of your choice...

 

 

float distanceDesired;Vector3 cameraPosition, cameraDirection; Vector3 cameraLookingAtPosition = cameraPosition + cameraDirection * distanceDesired;//look at scripthookdotnet source to see how to perform these operations

 

if you use .net, all the operations are defined in the vector3 class. For asi plugins you need to define this stuff.

Link to comment
Share on other sites

Fireboyd78

Try using methods like "CAM::GET_RENDERING_CAM", "CAM::GET_CAM_COORD", and "CAM::GET_CAM_ROT". You might need to look into the decompiled scripts to figure out how they are used.

 

Good luck.

Link to comment
Share on other sites

Everyone talks about .net, what is that, is it easier?, im using visual studio and i'm programming in c++ using the NativeDB

 

can you explain .net and convert that code to c++ and also link me the scripthook source code, with those examples...

Link to comment
Share on other sites

Try using methods like "CAM::GET_RENDERING_CAM", "CAM::GET_CAM_COORD", and "CAM::GET_CAM_ROT". You might need to look into the decompiled scripts to figure out how they are used.

 

Good luck.

 

if you update your natives.h, you will see new natives... CAM::GET _GAMEPLAY_CAM_ROT()... something like that (i wrote from memory)

 

Everyone talks about .net, what is that, is it easier?, im using visual studio and i'm programming in c++ using the NativeDB

 

can you explain .net and convert that code to c++ and also link me the scripthook source code, with those examples...

so you can program with c# or vb (.net languages)

 

If you know c++ stick with it, c# handles pointers so some things are easier. It is preference. C# has events which i think is better for organizing your script's functions. If you are new to programming, yes C# will be easier to understand.

 

http://gtaforums.com/topic/789907-vrel-community-script-hook-v-net/

 

go there and download the source... then review the vector3 class... look at the opertor overloads... i can show you the code in c++ if you want?

Link to comment
Share on other sites

 


Vector3 rot_to_direction(Vector3* rot)//scripthookdotnet source
{
float radiansZ = rot->z * 0.0174532924f;
float radiansX = rot->x * 0.0174532924f;
float num = std::abs((float)std::cos((double)radiansX));
Vector3 dir;
dir.x = (float)((double)((float)(-(float)std::sin((double)radiansZ))) * (double)num);
dir.y = (float)((double)((float)std::cos((double)radiansZ)) * (double) num);
dir.z = (float)std::sin((double)radiansX);
return dir;
}

Vector3 multiply(Vector3* vector, float x)
{
Vector3 result;
result.x = vector->x;
result.y = vector->y;
result.z = vector->z;

result.x *= x;
result.y *= x;
result.z *= x;

return result;
}
Vector3 add(Vector3* vectorA, Vector3* vectorB)
{
Vector3 result;
result.x = vectorA->x;
result.y = vectorA->y;
result.z = vectorA->z;

result.x += vectorB->x;
result.y += vectorB->y;
result.z += vectorB->z;

return result;
}

...

Vector3 camPosition = CAM::GET_GAMEPLAY_CAM_COORD();
Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(0);
Vector3 dir = rot_to_direction(&rot);
float distance = 10.0f;
Vector3 lengthVector = multiply(&dir, distance);
Vector3 posLookAt = add(&camPosition, &lengthVector);

 

Edited by c39687
Link to comment
Share on other sites

c39687 God Bless your soul, serious... i already liked and gave stars and stuff, jesus this is awesome... Thank you!

Link to comment
Share on other sites

make sure you use the latest edit.. no prob man, pass the knowledge on

 

i had an error in the code, i wrote "return vector" i changed to "return result" ;)

Edited by c39687
Link to comment
Share on other sites

ye i had fixed it, dont worry and again thank you thanks to you i have different views on the modding comunity!

Link to comment
Share on other sites

  • 2 weeks later...

 

Vector3 rot_to_direction(Vector3* rot)//scripthookdotnet source{    float radiansZ = rot->z * 0.0174532924f;     return result;} .......... Vector3 lengthVector = multiply(&dir, distance);Vector3 posLookAt = add(&camPosition, &lengthVector);

 

 

when i use your code i get the error "Pointers and fixed size buffers may only be used in an unsafe context" should it not work without unsafe? if you could make a quick script shooting anything in the direction of aim it will be highly appreciated.

Edited by [email protected]
Link to comment
Share on other sites

 

Vector3 rot_to_direction(Vector3* rot)//scripthookdotnet source{    float radiansZ = rot->z * 0.0174532924f;     return result;} .......... Vector3 lengthVector = multiply(&dir, distance);Vector3 posLookAt = add(&camPosition, &lengthVector);

 

 

when i use your code i get the error "Pointers and fixed size buffers may only be used in an unsafe context" should it not work without unsafe? if you could make a quick script shooting anything in the direction of aim it will be highly appreciated.

 

you are using .net it sounds like... i will paste the code from the old scripthookdotnet helper class to achieve this

public static Vector3 RotationToDirection(Vector3 Rotation){    float z = Rotation.Z;    float num = z * 0.0174532924f;    float x = Rotation.X;    float num2 = x * 0.0174532924f;    float num3 = Math.Abs((float)Math.Cos((double)num2));    return new Vector3    {        X = (float)((double)((float)(-(float)Math.Sin((double)num))) * (double)num3),        Y = (float)((double)((float)Math.Cos((double)num)) * (double)num3),        Z = (float)Math.Sin((double)num2)    };}

also scripthookdotnet knows how to perform different operations with vector3 objects. So this would be the last couple lines in c#

Vector3 camPosition = Function.Call<Vector3>(Hash.GET_GAMEPLAY_CAM_COORD);//i assume he handles this in the shvdnVector3 rot = Function.Call<Vector3>(Hash.GET_GAMEPLAY_CAM_ROT, 0);//make sure the above code is correct im just guessingVector3 dir = RotationToDirection(rot);float distance = 10f;Vector3 posLookAt = camPosition +  dir * distance;
Edited by c39687
Link to comment
Share on other sites

  • 4 weeks later...

Has anyone seen if these "get cam co-ordinates" functions could work inside the rockstar editor when viewing a clip?

 

I guess as this is just the game engine running but from different camera positions, it might be possible to retrive the x,y,z co-ordinates.

 

What is desirable is when editing a clip inside the editor and you have set a freecam angle, you could display the x, y and z co-ordinates of its position, perhaps with realtime update. Even better if you could copy your cam co-ordinates and apply them to another similar clip.

 

Quite annoying that R* overlooked this feature which would have made it possible to string together multiple 30 second clips into one long segment with continuity i.e matching camera angles.

 

I know this might be against the rules but if anyone thinks they could mod this (not seen a mod in rockstar editor yet), i would "donate" Its an incredibly useful feature for this tool.


Someone had suggested....

 

 

There is nothing stopping a mod running and executing while in editor clip edit mode right?

 

Wait, now I see that I mixed up the two thing, the director mode and clip editing mode.

So back to basics, the first thing is to check what scripts are loaded, when you are in the edit mode.

 

similiar in a for to iterate through an array containing the 700 scriptname:

 

if (natives.SCRIPT.HAS_SCRIPT_LOADED("maintransition")) then
print("maintransition");
end

 

After this we could tell probably what is scripted and what is hardcoded in the exe.

 

 

Do we know if its possible to run any sort of script while in this editor mode?

Link to comment
Share on other sites

Has anyone seen if these "get cam co-ordinates" functions could work inside the rockstar editor when viewing a clip?

 

I guess as this is just the game engine running but from different camera positions, it might be possible to retrive the x,y,z co-ordinates.

 

What is desirable is when editing a clip inside the editor and you have set a freecam angle, you could display the x, y and z co-ordinates of its position, perhaps with realtime update. Even better if you could copy your cam co-ordinates and apply them to another similar clip.

 

Quite annoying that R* overlooked this feature which would have made it possible to string together multiple 30 second clips into one long segment with continuity i.e matching camera angles.

 

I know this might be against the rules but if anyone thinks they could mod this (not seen a mod in rockstar editor yet), i would "donate" Its an incredibly useful feature for this tool.

Someone had suggested....

 

 

 

There is nothing stopping a mod running and executing while in editor clip edit mode right?

 

Wait, now I see that I mixed up the two thing, the director mode and clip editing mode.

So back to basics, the first thing is to check what scripts are loaded, when you are in the edit mode.

 

similiar in a for to iterate through an array containing the 700 scriptname:

 

if (natives.SCRIPT.HAS_SCRIPT_LOADED("maintransition")) then

print("maintransition");

end

 

After this we could tell probably what is scripted and what is hardcoded in the exe.

 

Do we know if its possible to run any sort of script while in this editor mode?

Can you explain the mod you want in a detailed way? I might consider making a r* editor mode mod.

Link to comment
Share on other sites

FixingG00D

 

Has anyone seen if these "get cam co-ordinates" functions could work inside the rockstar editor when viewing a clip?

 

I guess as this is just the game engine running but from different camera positions, it might be possible to retrive the x,y,z co-ordinates.

 

What is desirable is when editing a clip inside the editor and you have set a freecam angle, you could display the x, y and z co-ordinates of its position, perhaps with realtime update. Even better if you could copy your cam co-ordinates and apply them to another similar clip.

 

Quite annoying that R* overlooked this feature which would have made it possible to string together multiple 30 second clips into one long segment with continuity i.e matching camera angles.

 

I know this might be against the rules but if anyone thinks they could mod this (not seen a mod in rockstar editor yet), i would "donate" Its an incredibly useful feature for this tool.

Someone had suggested....

 

 

There is nothing stopping a mod running and executing while in editor clip edit mode right?

Wait, now I see that I mixed up the two thing, the director mode and clip editing mode.

So back to basics, the first thing is to check what scripts are loaded, when you are in the edit mode.

 

similiar in a for to iterate through an array containing the 700 scriptname:

 

if (natives.SCRIPT.HAS_SCRIPT_LOADED("maintransition")) then

print("maintransition");

end

 

After this we could tell probably what is scripted and what is hardcoded in the exe.

Do we know if its possible to run any sort of script while in this editor mode?

Can you explain the mod you want in a detailed way? I might consider making a r* editor mode mod.

 

 

Well to keep things "simple" to begin with, user would be in clip edit mode in editor. They have just set a maker and set up a freecam position.

 

Wherever you are on the timeline, you could press a hotkey that on press = bring up a small window, retrieve camera's current x, y and z decimal position (at that point on the timeline / currently displayed) and detail these readings in the window. Same hotkey or another could hide this window. Window could be small and run along the bottom or the top of the screen.

 

If it could realtime update x,y and z readings based on where you are / move to in the timeline, it would be extremly helpful.

 

I think a few of the camera natives are listed in this topic but i have no idea if they extend to working inside the editor rather than normal story mode.

 

A great addition to this, if you could both read and write-to using scripts, would be to to press another hotkey that would copy the camera's currently displayed x, y and z co-ordinates, then you could go to another marker in the same or next sequential similar clip and apply these copied co-ordinates to the new marker. Freecam position would then update to these applied readings.

 

This would mean in theory that when recording two sequential clips in same location, you could closely match the end of clip 1's camera position to the start of clip 2's camera position. This is currently not possible.

 

Does this sound technically impossible?

 

I think you would be the first modder to make anything for the editor. Not seen a single mod for it which tells me it might be extremly hard to do.

 

This is interesting ground as if modding works in editor, its potential can be elevated further e.g removing tight camera restrictions when moving away from player (red bubble).

 

If you fancied having a go, let me know if there is anything you need from me, or any further details. I've used the editor a lot now so quite tuned to how it all works.

Edited by FixingG00D
Link to comment
Share on other sites

Enumerator

 

 

Has anyone seen if these "get cam co-ordinates" functions could work inside the rockstar editor when viewing a clip?

 

I guess as this is just the game engine running but from different camera positions, it might be possible to retrive the x,y,z co-ordinates.

 

What is desirable is when editing a clip inside the editor and you have set a freecam angle, you could display the x, y and z co-ordinates of its position, perhaps with realtime update. Even better if you could copy your cam co-ordinates and apply them to another similar clip.

 

Quite annoying that R* overlooked this feature which would have made it possible to string together multiple 30 second clips into one long segment with continuity i.e matching camera angles.

 

I know this might be against the rules but if anyone thinks they could mod this (not seen a mod in rockstar editor yet), i would "donate" Its an incredibly useful feature for this tool.

Someone had suggested....

 

 

 

There is nothing stopping a mod running and executing while in editor clip edit mode right?

 

Wait, now I see that I mixed up the two thing, the director mode and clip editing mode.

So back to basics, the first thing is to check what scripts are loaded, when you are in the edit mode.

 

similiar in a for to iterate through an array containing the 700 scriptname:

 

if (natives.SCRIPT.HAS_SCRIPT_LOADED("maintransition")) then

print("maintransition");

end

 

After this we could tell probably what is scripted and what is hardcoded in the exe.

Do we know if its possible to run any sort of script while in this editor mode?

Can you explain the mod you want in a detailed way? I might consider making a r* editor mode mod.

 

Well to keep things "simple" to begin with, user would be in clip edit mode in editor. They have just set a maker and set up a freecam position.

 

Wherever you are on the timeline, you could press a hotkey that on press = bring up a small window, retrieve camera's current x, y and z decimal position (at that point on the timeline / currently displayed) and detail these readings in the window. Same hotkey or another could hide this window. Window could be small and run along the bottom or the top of the screen.

 

If it could realtime update x,y and z readings based on where you are / move to in the timeline, it would be extremly helpful.

 

I think a few of the camera natives are listed in this topic but i have no idea if they extend to working inside the editor rather than normal story mode.

 

A great addition to this, if you could both read and write-to using scripts, would be to to press another hotkey that would copy the camera's currently displayed x, y and z co-ordinates, then you could go to another marker in the same or next sequential similar clip and apply these copied co-ordinates to the new marker. Freecam position would then update to these applied readings.

 

This would mean in theory that when recording two sequential clips in same location, you could closely match the end of clip 1's camera position to the start of clip 2's camera position. This is currently not possible.

 

Does this sound technically impossible?

 

I think you would be the first modder to make anything for the editor. Not seen a single mod for it which tells me it might be extremly hard to do.

 

This is interesting ground as if modding works in editor, its potential can be elevated further e.g removing tight camera restrictions when moving away from player (red bubble).

 

If you fancied having a go, let me know if there is anything you need from me, or any further details. I've used the editor a lot now so quite tuned to how it all works.

Add me to Skype and tomorrow I'll contact you regarding this.

Link to comment
Share on other sites

FixingG00D

Cool. Do you want to pm your skype name and a time? I'm UK time.

Link to comment
Share on other sites

Enumerator

Cool. Do you want to pm your skype name and a time? I'm UK time.

Skype me now, My skype id is in my signature lol.

Edited by Enumerator
Link to comment
Share on other sites

FixingG00D

 

Cool. Do you want to pm your skype name and a time? I'm UK time.

Skype me now, My skype id is in my signature lol.

 

 

I was tired :-) i've added you

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.