One .obj
file of a CSL model (of which it can have multiple)
More...
#include <CSLModels.h>
|
std::string | cslKey |
| key of the CSL model this belongs to More...
|
|
std::string | path |
| full path to the (potentially copied) .obj file More...
|
|
std::string | pathOrig |
| full path to the original .obj file IF there is the need to create a copy upon load More...
|
|
std::string | texture |
| texture file if defined, to be used in the TEXTURE line of the .obj file More...
|
|
std::string | text_lit |
| texture_lit file if defined, to be used in the TEXTURE_LIT line of the .obj file More...
|
|
One .obj
file of a CSL model (of which it can have multiple)
◆ CSLObj() [1/2]
XPMP2::CSLObj::CSLObj |
( |
const std::string & |
_cslKey, |
|
|
const std::string & |
_path |
|
) |
| |
|
inline |
Constructor doesn't do much.
◆ CSLObj() [2/2]
XPMP2::CSLObj::CSLObj |
( |
CSLObj && |
o | ) |
|
|
default |
Generate standard move constructor.
◆ ~CSLObj()
XPMP2::CSLObj::~CSLObj |
( |
| ) |
|
Destructor makes sure the XP object is removed, too.
◆ CopyAndReplace()
bool XPMP2::CSLObj::CopyAndReplace |
( |
| ) |
|
|
protected |
Perform the copy-on-load functionality, replacing dataRefs and textures, expected to be called via std::async.
◆ DetermineWhichObjToLoad()
void XPMP2::CSLObj::DetermineWhichObjToLoad |
( |
| ) |
|
Determine which file to load and if we need a copied .obj file.
- Determine if we need to access a copied file at all
- Compute that copied file name It will include one of the texture ids if texture replacement is involved It will always end on ".xpmp2.obj"
- Test if that copied file already exists The actual copy operation will only be peformed upon load.
◆ FetchVertOfsFromObjFile()
float XPMP2::CSLObj::FetchVertOfsFromObjFile |
( |
| ) |
const |
Read the obj file to calculate its vertical offset.
The idea behind doing this is taken from the original libxplanemp implementation, particularly XPMPMultiplayerCSLOffset.cpp: CslModelVertOffsetCalculator::findOffsetInObj8
: The vertices and lines defined in the file have coordinates, their outer edges define how much the aircraft would need to be lifted to make its lowest part (typically the gear) appear on the surfaces. So it searches for min/max values of vertical (y) coordinates.
- Note
- I am not sure why the original code returns
-max
if min > 0
, my understanding would be to always return -min
and don't need max
. But I just hope that the original author knows better and I stick to it.
◆ GetAndLoadObj()
XPLMObjectRef XPMP2::CSLObj::GetAndLoadObj |
( |
| ) |
|
Load and return the underlying X-Plane objects.
- Note
- Can return NULL while async load is underway!
◆ GetObjState()
State of the X-Plane object: Is it being loaded or available?
◆ Invalidate()
void XPMP2::CSLObj::Invalidate |
( |
| ) |
|
|
protected |
Marks the CSL Model invalid in case object loading once failed.
◆ IsInvalid()
bool XPMP2::CSLObj::IsInvalid |
( |
| ) |
const |
|
inline |
◆ Load()
void XPMP2::CSLObj::Load |
( |
| ) |
|
Starts loading the XP object.
Async load takes time. Maybe this object exists no longer when the load operaton returns. That's why we do not just pass this
to the XPLMLoadObjectAsync() call, but a separate object, here a pair of copies of the id strings, by which we can try to find the object again in the callback XPObjLoadedCB().
◆ NeedsObjCopy()
bool XPMP2::CSLObj::NeedsObjCopy |
( |
| ) |
const |
|
inline |
Will this object require copying the .obj
file upon load?
◆ operator=()
◆ SetCopyResult()
void XPMP2::CSLObj::SetCopyResult |
( |
bool |
bResult | ) |
|
|
protected |
Update with the result of the copy operation.
◆ SetOtherObjCopyResult()
void XPMP2::CSLObj::SetOtherObjCopyResult |
( |
bool |
bResult | ) |
|
|
staticprotected |
Update another CSLObj with the result of the copy operation.
◆ TriggerCopyAndReplace()
bool XPMP2::CSLObj::TriggerCopyAndReplace |
( |
| ) |
|
|
protected |
Trigger a separate thread to copy the .obj file if needed.
- Returns
- true when copying has finished, false if the loading sequence needs to wait here (for the copy operation to start or finish)
◆ Unload()
void XPMP2::CSLObj::Unload |
( |
| ) |
|
◆ XPObjLoadedCB()
void XPMP2::CSLObj::XPObjLoadedCB |
( |
XPLMObjectRef |
inObject, |
|
|
void * |
inRefcon |
|
) |
| |
|
staticprotected |
callback function called when loading is done
◆ cslKey
std::string XPMP2::CSLObj::cslKey |
key of the CSL model this belongs to
◆ path
std::string XPMP2::CSLObj::path |
full path to the (potentially copied) .obj
file
◆ pathOrig
std::string XPMP2::CSLObj::pathOrig |
full path to the original .obj
file IF there is the need to create a copy upon load
◆ text_lit
std::string XPMP2::CSLObj::text_lit |
texture_lit file if defined, to be used in the TEXTURE_LIT line of the .obj file
◆ texture
std::string XPMP2::CSLObj::texture |
texture file if defined, to be used in the TEXTURE line of the .obj file
◆ xpObj
XPLMObjectRef XPMP2::CSLObj::xpObj = NULL |
|
protected |
The X-Plane object reference to the loaded model as requested with XPLMLoadObjectAsync.
◆ xpObjState
State of the X-Plane object: Is it being loaded or available?
The documentation for this class was generated from the following files: