Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Orbiter SDK Orbiter software developers post your questions and answers about the SDK, the API interface, LUA, meshing, etc.

Reply
 
Thread Tools
Old 01-04-2018, 08:19 PM   #1
TCR_500
Biblical Creationist
Default Difference between OBJHANDLE and Vessel

What exactly is the difference between these two types?
Code:
class Vessel;
typedef void *OBJHANDLE;
I'm confused as to why the "Vessel" class is needed if whatever's behind the "OBJHANDLE" implements all of the objects that can respond to a force.
TCR_500 is offline   Reply With Quote
Old 01-04-2018, 08:54 PM   #2
Face
Beta Tester
 
Face's Avatar

Default

Quote:
Originally Posted by TCR_500 View Post
 What exactly is the difference between these two types?
Code:
class Vessel;
typedef void *OBJHANDLE;
I'm confused as to why the "Vessel" class is needed if whatever's behind the "OBJHANDLE" implements all of the objects that can respond to a force.
A handle is just a number that some authority (OAPI) uses to reference an object. You can't cast the handle to something and work directly on it.
Face is offline   Reply With Quote
Old 01-05-2018, 02:14 AM   #3
TCR_500
Biblical Creationist
Default

So, the Vessel class would be responsible for applying the correct forces to the object?
TCR_500 is offline   Reply With Quote
Old 01-05-2018, 04:25 AM   #4
ADSWNJ
Scientist
 
ADSWNJ's Avatar
Default

It's not "object" as in a strange sphere in space (or not even a Probe), but object in a computer science sense.

Basically - treat the OBJHANDLE as a simple pointer. E.g. if you have a vessel name (C string) such as "DG-01", then OBJHANDLE oh = oapiGetVesselByName("DG-01"); will get you a pointer to this object.

If you want to do anything serious with the vessel, then get the vessel's interface - e.g. VESSEL *pV - oapiGetVesselInterface(oh);

With this pointer to the vessel class instance, you can then do things like pv->SetThrusterGroupLevel(...) or pv->ShiftCG(vec), as you wish.
ADSWNJ is offline   Reply With Quote
Old 01-05-2018, 09:29 AM   #5
Face
Beta Tester
 
Face's Avatar

Default

Quote:
Originally Posted by TCR_500 View Post
 So, the Vessel class would be responsible for applying the correct forces to the object?
AFAIK, yes. The implementation for that is of course in the Orbiter core, but the class definition is exposed via the API, so you can derive from the VESSEL class (or even newer interfaces) and extend the core implementation with your own code.

Whether or not it is some VESSEL method directly that calculates the forces from gbody reference, thrusters, and so on, or some "global" function that does it is not so important IMHO. More important is that all vessel-specific data is encapsulated in the VESSEL class.
Face is offline   Reply With Quote
Thanked by:
Reply

  Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 01:58 PM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.