oapiCameraGlobalDir

V8Li

Member
Joined
Apr 9, 2008
Messages
200
Reaction score
0
Points
16
I have this simple code:
Code:
VECTOR3 *C;
oapiCameraGlobalDir(C);
And I am calling later in the code the x, y and z like this: C->x, C->y, C->z.
I am doing something wrong since I get this warning message:
Code:
warning C4700: uninitialized local variable 'C' used
Plus I get some crazy values in Orbitersim and a CTD soon after. I think it has something to do with the way I've used the pointer but I have no idea what I've done wrong. Am I missing something?
 

SiameseCat

Addon Developer
Addon Developer
Joined
Feb 9, 2008
Messages
1,699
Reaction score
2
Points
0
Location
Ontario
You don't need to use pointers here;
Code:
VECTOR3 C;
oapiCameraGlobalDir(&C);
will work.

If you want to use a pointer, you should have
Code:
 VECTOR *C=new VECTOR3;
Simply declaring a pointer without initializing it will give you errors when you actually the pointer.
 

V8Li

Member
Joined
Apr 9, 2008
Messages
200
Reaction score
0
Points
16
Thanks!
Code:
VECTOR3 C;
oapiCameraGlobalDir(&C);
worked just fine. In the API_Reference, the function is described as "void oapiCameraGlobalDir (VECTOR3 *gdir)" so I thought it is expecting a pointer as a parameter, not a reference.

Off topic, I am trying to somehow "read" the offset of the camera when the user looks around the virtual cockpit in reference to the centered view. Is there a function that returns the values?
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,655
Reaction score
2,376
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
In the API_Reference, the function is described as "void oapiCameraGlobalDir (VECTOR3 *gdir)" so I thought it is expecting a pointer as a parameter, not a reference.

The &var operator does not return references, it returns either the pointer to a variable or the reference to a variable, depending on what you want to do with it. References are defined over the variable definition:

VECTOR3 &reference;
VECTOR3 *pointer;
 

V8Li

Member
Joined
Apr 9, 2008
Messages
200
Reaction score
0
Points
16
So this was my initial intention: somehow read how much the user has panned the camera, ie. looked around the virtual cockpit. I want my [ame="http://www.orbithangar.com/searchid.php?ID=3349"]HUDdataMFD[/ame] at least to hide the HUD if the user looks around the VC because it's annoying since it obstructs the gauges, dials etc. Also, it would be ideal to somehow read how much the camera has been moved so that I can keep the HUD in a fixed position.

Any suggestions?
 
Top