write shit
This commit is contained in:
parent
69f702a6d2
commit
d66716acd7
|
@ -129,6 +129,18 @@ enum CK_STATECHUNK_CHUNKOPTIONS {
|
|||
CHNK_DONTDELETE_PARSER = 0x80, // m_Parser Ptr is not owned by CKStateChunk , it must not be deleted...
|
||||
};
|
||||
|
||||
typedef enum CK_OBJECT_SHOWOPTION {
|
||||
CKHIDE =0,
|
||||
CKSHOW =1,
|
||||
CKHIERARCHICALHIDE =2
|
||||
} CK_OBJECT_SHOWOPTION;
|
||||
|
||||
typedef enum CK_OBJECT_CANBEHIDE {
|
||||
CKCANNOTHIDE =0, // the object cannot be hidden
|
||||
CKCANHIDE =1, // the object can be hidden
|
||||
CKCANHIERARCHICALHIDE =2 // the object can be hidden and hierarchically hidden
|
||||
} CK_OBJECT_CANBEHIDE;
|
||||
|
||||
/***************************************************
|
||||
{filename:CK_OBJECT_FLAGS}
|
||||
Summary: CKObject Flags
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace LibCmo::CK2 {
|
|||
VxMath::VxDoAlphaBlit(slot, static_cast<CKBYTE>(globalalpha));
|
||||
} else {
|
||||
auto alphabuf = chk->ReadBufferWrapper();
|
||||
VxMath::VxDoAlphaBlit(slot, reinterpret_cast<const CKBYTE*>(alphabuf.get()));
|
||||
VxMath::VxDoAlphaBlit(slot, static_cast<const CKBYTE*>(alphabuf.get()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,10 +102,10 @@ namespace LibCmo::CK2 {
|
|||
// get essential data
|
||||
CKDWORD pixelcount = slot->GetPixelCount();
|
||||
CKBYTE* dst = slot->GetMutableImage(),
|
||||
* redSrc = reinterpret_cast<CKBYTE*>(redBuffer.get()),
|
||||
* greenSrc = reinterpret_cast<CKBYTE*>(greenBuffer.get()),
|
||||
* blueSrc = reinterpret_cast<CKBYTE*>(blueBuffer.get()),
|
||||
* alphaSrc = reinterpret_cast<CKBYTE*>(alphaBuffer.get());
|
||||
* redSrc = static_cast<CKBYTE*>(redBuffer.get()),
|
||||
* greenSrc = static_cast<CKBYTE*>(greenBuffer.get()),
|
||||
* blueSrc = static_cast<CKBYTE*>(blueBuffer.get()),
|
||||
* alphaSrc = static_cast<CKBYTE*>(alphaBuffer.get());
|
||||
for (CKDWORD p = 0; p < pixelcount; ++p) {
|
||||
*(dst++) = *(blueSrc++);
|
||||
*(dst++) = *(greenSrc++);
|
||||
|
|
|
@ -139,6 +139,16 @@ namespace LibCmo::CK2 {
|
|||
CHUNK_DEV_2_1 = 10, /**< Changes in wavesound reading of inside, outside angles */
|
||||
CHUNKDATA_CURRENTVERSION = CHUNK_DEV_2_1,
|
||||
};
|
||||
enum class CK_OBJECT_SHOWOPTION : CKDWORD {
|
||||
CKHIDE = 0x0,
|
||||
CKSHOW = 0x1,
|
||||
CKHIERARCHICALHIDE = 0x2,
|
||||
};
|
||||
enum class CK_OBJECT_CANBEHIDE : CKDWORD {
|
||||
CKCANNOTHIDE = 0, /**< the object cannot be hidden */
|
||||
CKCANHIDE = 1, /**< the object can be hidden */
|
||||
CKCANHIERARCHICALHIDE = 2, /**< the object can be hidden and hierarchically hidden */
|
||||
};
|
||||
/**
|
||||
CKObject Flags
|
||||
@remark
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace LibCmo::CK2 {
|
|||
uLongf _destLen = static_cast<uLongf>(boundary);
|
||||
if (compress2(
|
||||
reinterpret_cast<Bytef*>(DestBuffer), &_destLen,
|
||||
reinterpret_cast<const Bytef*>(Data), static_cast<uLong>(size),
|
||||
static_cast<const Bytef*>(Data), static_cast<uLong>(size),
|
||||
static_cast<int>(compressionlevel)) != Z_OK) {
|
||||
NewSize = 0;
|
||||
delete[] DestBuffer;
|
||||
|
@ -49,7 +49,7 @@ namespace LibCmo::CK2 {
|
|||
uLongf cache = DestSize;
|
||||
if (uncompress(
|
||||
reinterpret_cast<Bytef*>(DestBuffer), &cache,
|
||||
reinterpret_cast<const Bytef*>(SrcBuffer), static_cast<uLong>(SrcSize)) != Z_OK) {
|
||||
static_cast<const Bytef*>(SrcBuffer), static_cast<uLong>(SrcSize)) != Z_OK) {
|
||||
delete[] DestBuffer;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ namespace LibCmo::CK2 {
|
|||
CKDWORD CKComputeDataCRC(const void* data, CKDWORD size, CKDWORD PreviousCRC) {
|
||||
return static_cast<CKDWORD>(adler32(
|
||||
static_cast<uLong>(PreviousCRC),
|
||||
reinterpret_cast<const Bytef*>(data),
|
||||
static_cast<const Bytef*>(data),
|
||||
static_cast<uInt>(size)
|
||||
));
|
||||
}
|
||||
|
|
|
@ -315,15 +315,15 @@ namespace LibCmo::CK2 {
|
|||
// read chunk ver and data ver first
|
||||
// chunk ver always set in the 3rd BYTE in every format
|
||||
this->m_ChunkVersion = static_cast<CK_STATECHUNK_CHUNKVERSION>(
|
||||
reinterpret_cast<const CKBYTE*>(buf)[2]
|
||||
static_cast<const CKBYTE*>(buf)[2]
|
||||
);
|
||||
// data ver always set in the 1st BYTE in every format
|
||||
this->m_DataVersion = static_cast<CK_STATECHUNK_DATAVERSION>(
|
||||
reinterpret_cast<const CKBYTE*>(buf)[0]
|
||||
static_cast<const CKBYTE*>(buf)[0]
|
||||
);
|
||||
|
||||
// switch according to chunk ver
|
||||
const CKDWORD* dwbuf = reinterpret_cast<const CKDWORD*>(buf);
|
||||
const CKDWORD* dwbuf = static_cast<const CKDWORD*>(buf);
|
||||
size_t bufpos = 0u;
|
||||
if (this->m_ChunkVersion < CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSION2) {
|
||||
// very old file
|
||||
|
@ -390,11 +390,11 @@ namespace LibCmo::CK2 {
|
|||
// re-read some extra data
|
||||
// class id located the 2nd BYTE
|
||||
this->m_ClassId = static_cast<CK_CLASSID>(
|
||||
reinterpret_cast<const CKBYTE*>(buf)[1]
|
||||
static_cast<const CKBYTE*>(buf)[1]
|
||||
);
|
||||
// options located the 4th BYTE
|
||||
CK_STATECHUNK_CHUNKOPTIONS options = static_cast<CK_STATECHUNK_CHUNKOPTIONS>(
|
||||
reinterpret_cast<const CKBYTE*>(buf)[3]
|
||||
static_cast<const CKBYTE*>(buf)[3]
|
||||
);
|
||||
|
||||
// read normal data
|
||||
|
@ -464,12 +464,12 @@ namespace LibCmo::CK2 {
|
|||
// if buffer provided, write it
|
||||
if (buf != nullptr) {
|
||||
// write header
|
||||
reinterpret_cast<CKBYTE*>(buf)[0] = static_cast<CKBYTE>(this->m_DataVersion);
|
||||
reinterpret_cast<CKBYTE*>(buf)[1] = static_cast<CKBYTE>(this->m_ClassId);
|
||||
reinterpret_cast<CKBYTE*>(buf)[2] = static_cast<CKBYTE>(this->m_ChunkVersion);
|
||||
reinterpret_cast<CKBYTE*>(buf)[3] = static_cast<CKBYTE>(options);
|
||||
static_cast<CKBYTE*>(buf)[0] = static_cast<CKBYTE>(this->m_DataVersion);
|
||||
static_cast<CKBYTE*>(buf)[1] = static_cast<CKBYTE>(this->m_ClassId);
|
||||
static_cast<CKBYTE*>(buf)[2] = static_cast<CKBYTE>(this->m_ChunkVersion);
|
||||
static_cast<CKBYTE*>(buf)[3] = static_cast<CKBYTE>(options);
|
||||
|
||||
CKDWORD* dwbuf = reinterpret_cast<CKDWORD*>(buf);
|
||||
CKDWORD* dwbuf = static_cast<CKDWORD*>(buf);
|
||||
// write buffer length
|
||||
dwbuf[1] = this->m_DataDwSize;
|
||||
size_t bufpos = 2u;
|
||||
|
|
|
@ -322,7 +322,7 @@ namespace LibCmo::CK2 {
|
|||
|
||||
void CKStateChunk::DeleteBuffer(const void* buf) {
|
||||
if (buf == nullptr) return;
|
||||
delete[] reinterpret_cast<const CKBYTE*>(buf);
|
||||
delete[] static_cast<const CKBYTE*>(buf);
|
||||
}
|
||||
|
||||
CKStateChunk::Buffer_t CKStateChunk::ReadBufferWrapper() {
|
||||
|
|
|
@ -121,7 +121,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||
// read data
|
||||
int x, y, channels_in_file;
|
||||
stbi_uc* data = stbi_load_from_memory(
|
||||
reinterpret_cast<const stbi_uc*>(memory),
|
||||
static_cast<const stbi_uc*>(memory),
|
||||
static_cast<int>(size),
|
||||
&x, &y, &channels_in_file, 4 // 4 == RGBA8888
|
||||
);
|
||||
|
@ -145,7 +145,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||
size_t m_Counter;
|
||||
};
|
||||
static void FileWriteFunction(void* context, void* data, int size) {
|
||||
FileSaveContext* ctx = reinterpret_cast<FileSaveContext*>(context);
|
||||
FileSaveContext* ctx = static_cast<FileSaveContext*>(context);
|
||||
if (ctx->m_Fs != nullptr) {
|
||||
std::fwrite(data, sizeof(CKBYTE), size, ctx->m_Fs);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||
size_t m_Counter;
|
||||
};
|
||||
static void MemoryWriteFunction(void* context, void* data, int size) {
|
||||
MemorySaveContext* ctx = reinterpret_cast<MemorySaveContext*>(context);
|
||||
MemorySaveContext* ctx = static_cast<MemorySaveContext*>(context);
|
||||
if (ctx->m_Mem != nullptr) {
|
||||
std::memcpy(ctx->m_Mem, data, size);
|
||||
ctx->m_Mem = static_cast<CKBYTE*>(ctx->m_Mem) + size;
|
||||
|
|
|
@ -53,9 +53,15 @@ namespace LibCmo::CK2::ObjImpls {
|
|||
XContainer::XObjectPointerArray potentials;
|
||||
chunk->ReadXObjectPointerArray(potentials);
|
||||
for (const auto& ptr : potentials) {
|
||||
if (ptr == nullptr) continue;
|
||||
XContainer::NSXObjectPointerArray::AddIfNotHere(m_PotentialMeshes, ptr);
|
||||
}
|
||||
|
||||
// add current mesh to potential meshes
|
||||
if (m_CurrentMesh != nullptr) {
|
||||
XContainer::NSXObjectPointerArray::AddIfNotHere(m_PotentialMeshes, m_CurrentMesh);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// read core entity data
|
||||
|
@ -88,6 +94,8 @@ namespace LibCmo::CK2::ObjImpls {
|
|||
}
|
||||
|
||||
// read matrix
|
||||
// reset
|
||||
m_WorldMatrix.ResetToIdentity();
|
||||
// force read as vector3
|
||||
chunk->ReadStruct(reinterpret_cast<VxMath::VxVector3*>(&m_WorldMatrix[0]));
|
||||
chunk->ReadStruct(reinterpret_cast<VxMath::VxVector3*>(&m_WorldMatrix[1]));
|
||||
|
@ -139,8 +147,13 @@ namespace LibCmo::CK2::ObjImpls {
|
|||
chunk->ReadStruct(m_ZOrder);
|
||||
}
|
||||
|
||||
} else {
|
||||
// MARK: compatibility code removed because I don't need them
|
||||
return false;
|
||||
}
|
||||
|
||||
// MARK: skin and bone are skipped.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,9 +3,46 @@
|
|||
|
||||
namespace LibCmo::CK2::ObjImpls {
|
||||
|
||||
CKObject::CKObject(CKContext* ctx, CK_ID ckid, CKSTRING name) :
|
||||
m_ID(ckid),
|
||||
m_Name(name),
|
||||
m_Context(ctx),
|
||||
m_ObjectFlags(CK_OBJECT_FLAGS::CK_PARAMETERIN_DISABLED) {}
|
||||
|
||||
CKObject::~CKObject() {}
|
||||
|
||||
#pragma region Non-virtual Functions
|
||||
|
||||
CK_ID CKObject::GetID(void) const {
|
||||
return m_ID;
|
||||
}
|
||||
CKSTRING CKObject::GetName(void) const {
|
||||
return XContainer::NSXString::ToCKSTRING(m_Name);
|
||||
}
|
||||
void CKObject::SetName(CKSTRING u8_name) {
|
||||
XContainer::NSXString::FromCKSTRING(m_Name, u8_name);
|
||||
}
|
||||
CK_OBJECT_FLAGS CKObject::GetObjectFlags(void) const {
|
||||
return m_ObjectFlags;
|
||||
}
|
||||
void CKObject::SetObjectFlags(CK_OBJECT_FLAGS flags) {
|
||||
m_ObjectFlags = flags;
|
||||
}
|
||||
bool CKObject::IsHierarchicallyHide() const {
|
||||
return EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE);
|
||||
}
|
||||
CKContext* CKObject::GetCKContext() const {
|
||||
return m_Context;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
void CKObject::CheckPreDeletion() {}
|
||||
|
||||
void CKObject::CheckPostDeletion() {}
|
||||
|
||||
|
||||
void CKObject::PreSave(CKFileVisitor* file, CKDWORD flags) {}
|
||||
|
||||
bool CKObject::Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags) {
|
||||
|
@ -36,90 +73,36 @@ namespace LibCmo::CK2::ObjImpls {
|
|||
void CKObject::PostLoad() {}
|
||||
|
||||
|
||||
//CKSceneObject::CKSceneObject(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKObject(ctx, ckid, name) {
|
||||
//}
|
||||
//CKSceneObject::~CKSceneObject() {
|
||||
//}
|
||||
void CKObject::Show(CK_OBJECT_SHOWOPTION show) {
|
||||
// clear all visible data of object flags
|
||||
EnumsHelper::Rm(m_ObjectFlags, EnumsHelper::Merge({
|
||||
CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE,
|
||||
CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE
|
||||
}));
|
||||
|
||||
//CKBeObject::CKBeObject(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKSceneObject(ctx, ckid, name) {
|
||||
//}
|
||||
//CKBeObject::~CKBeObject() {
|
||||
//}
|
||||
switch (show) {
|
||||
case CK_OBJECT_SHOWOPTION::CKSHOW:
|
||||
EnumsHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
||||
break;
|
||||
case CK_OBJECT_SHOWOPTION::CKHIERARCHICALHIDE:
|
||||
EnumsHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE);
|
||||
break;
|
||||
case CK_OBJECT_SHOWOPTION::CKHIDE:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//CKGroup::CKGroup(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKBeObject(ctx, ckid, name) {
|
||||
//}
|
||||
//CKGroup::~CKGroup() {
|
||||
//}
|
||||
bool CKObject::IsHiddenByParent() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
//CKMesh::CKMesh(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKBeObject(ctx, ckid, name) {
|
||||
//}
|
||||
//CKMesh::~CKMesh() {
|
||||
//}
|
||||
CK_OBJECT_CANBEHIDE CKObject::CanBeHide() const {
|
||||
return CK_OBJECT_CANBEHIDE::CKCANNOTHIDE;
|
||||
}
|
||||
|
||||
//CKTexture::CKTexture(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKBeObject(ctx, ckid, name) {
|
||||
//}
|
||||
//CKTexture::~CKTexture() {
|
||||
//}
|
||||
bool CKObject::IsVisible() const {
|
||||
return EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
||||
}
|
||||
|
||||
//CKMaterial::CKMaterial(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKBeObject(ctx, ckid, name) {
|
||||
//}
|
||||
//CKMaterial::~CKMaterial() {
|
||||
//}
|
||||
|
||||
//CKRenderObject::CKRenderObject(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKBeObject(ctx, ckid, name) {
|
||||
//}
|
||||
//CKRenderObject::~CKRenderObject() {
|
||||
//}
|
||||
|
||||
//CK3dEntity::CK3dEntity(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKRenderObject(ctx, ckid, name) {
|
||||
//}
|
||||
//CK3dEntity::~CK3dEntity() {
|
||||
//}
|
||||
|
||||
//CK3dObject::CK3dObject(CKContext* ctx, CK_ID ckid, CKSTRING name) : CK3dEntity(ctx, ckid, name) {
|
||||
//}
|
||||
//CK3dObject::~CK3dObject() {
|
||||
//}
|
||||
|
||||
|
||||
//CKParameterIn::CKParameterIn(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKObject(ctx, ckid, name) {
|
||||
//}
|
||||
//CKParameterIn::~CKParameterIn() {
|
||||
//}
|
||||
|
||||
//CKParameter::CKParameter(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKObject(ctx, ckid, name) {
|
||||
//}
|
||||
//CKParameter::~CKParameter() {
|
||||
//}
|
||||
|
||||
//CKParameterOut::CKParameterOut(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKParameter(ctx, ckid, name) {
|
||||
//}
|
||||
//CKParameterOut::~CKParameterOut() {
|
||||
//}
|
||||
|
||||
//CKParameterLocal::CKParameterLocal(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKParameter(ctx, ckid, name) {
|
||||
//}
|
||||
//CKParameterLocal::~CKParameterLocal() {
|
||||
//}
|
||||
|
||||
//CKParameterOperation::CKParameterOperation(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKObject(ctx, ckid, name) {
|
||||
//}
|
||||
//CKParameterOperation::~CKParameterOperation() {
|
||||
//}
|
||||
|
||||
//CKBehaviorLink::CKBehaviorLink(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKObject(ctx, ckid, name) {
|
||||
//}
|
||||
//CKBehaviorLink::~CKBehaviorLink() {
|
||||
//}
|
||||
|
||||
//CKBehaviorIO::CKBehaviorIO(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKObject(ctx, ckid, name) {
|
||||
//}
|
||||
//CKBehaviorIO::~CKBehaviorIO() {
|
||||
//}
|
||||
|
||||
//CKBehavior::CKBehavior(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKSceneObject(ctx, ckid, name) {
|
||||
//}
|
||||
//CKBehavior::~CKBehavior() {
|
||||
//}
|
||||
|
||||
}
|
|
@ -18,15 +18,15 @@ Implement as original meaning:
|
|||
- CanBeHide()
|
||||
- IsVisible()
|
||||
|
||||
- CheckPreDeletion()
|
||||
- CheckPostDeletion()
|
||||
|
||||
No implement because don't care:
|
||||
- GetMemoryOccupation()
|
||||
- IsObjectUsed()
|
||||
- PrepareDependencies()
|
||||
- RemapDependencies()
|
||||
|
||||
- CheckPreDeletion()
|
||||
- CheckPostDeletion()
|
||||
|
||||
Implement moved into other location:
|
||||
- Copy(): Use CKObject::CKObject(CK_ID newid, const CKObject* obj) ctor and CKClassDesc to implement.
|
||||
- PreDelete(): Write in dtor.
|
||||
|
@ -37,44 +37,65 @@ namespace LibCmo::CK2::ObjImpls {
|
|||
|
||||
class CKObject {
|
||||
public:
|
||||
CKObject(CKContext* ctx, CK_ID ckid, CKSTRING name) :
|
||||
m_ID(ckid),
|
||||
m_Name(name),
|
||||
m_Context(ctx),
|
||||
m_ObjectFlags(CK_OBJECT_FLAGS::CK_PARAMETERIN_DISABLED)
|
||||
{}
|
||||
virtual ~CKObject() {}
|
||||
CKObject(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
virtual ~CKObject();
|
||||
LIBCMO_DISABLE_COPY_MOVE(CKObject);
|
||||
|
||||
CK_ID GetID(void) {
|
||||
return m_ID;
|
||||
}
|
||||
CKSTRING GetName(void) {
|
||||
return XContainer::NSXString::ToCKSTRING(m_Name);
|
||||
}
|
||||
void SetName(CKSTRING u8_name) {
|
||||
XContainer::NSXString::FromCKSTRING(m_Name, u8_name);
|
||||
}
|
||||
CK_OBJECT_FLAGS GetObjectFlags(void) {
|
||||
return m_ObjectFlags;
|
||||
}
|
||||
void SetObjectFlags(CK_OBJECT_FLAGS flags) {
|
||||
m_ObjectFlags = flags;
|
||||
}
|
||||
CKContext* GetCKContext() {
|
||||
return m_Context;
|
||||
}
|
||||
CK_ID GetID(void) const;
|
||||
CKSTRING GetName(void) const;
|
||||
void SetName(CKSTRING u8_name);
|
||||
CK_OBJECT_FLAGS GetObjectFlags(void) const;
|
||||
void SetObjectFlags(CK_OBJECT_FLAGS flags);
|
||||
bool IsHierarchicallyHide() const;
|
||||
CKContext* GetCKContext() const;
|
||||
|
||||
virtual CK_CLASSID GetClassID(void) {
|
||||
return CK_CLASSID::CKCID_OBJECT;
|
||||
}
|
||||
|
||||
virtual void CheckPreDeletion();
|
||||
virtual void CheckPostDeletion();
|
||||
|
||||
virtual void PreSave(CKFileVisitor* file, CKDWORD flags);
|
||||
virtual bool Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags);
|
||||
virtual bool Load(CKStateChunk* chunk, CKFileVisitor* file);
|
||||
virtual void PostLoad();
|
||||
|
||||
/**
|
||||
* @brief Shows or hides an object
|
||||
* @remark
|
||||
* + If show is set to CKHIERARCHICALHIDE this object will be hidden along with all its children.
|
||||
* + The render engine renders objets in a hierarchical way and stops iterating a hierarchy if it encounters an object which is hierarchically hidden. The problem is that, for performance reason, children objets visibility flags are left unchanged (ie. if a child object was visible CKObject::IsVisible will still return TRUE). To test is a object is hidden because one of its parent object is hierarchically hidden use CKObject::IsHiddenByParent
|
||||
* + The CKHIERARCHICALHIDE option is only relevant for CK2dEntity and CK3dEntity derived classes.
|
||||
* + If show is set to CKSHOW the object will be shown and it also removes the hierarchically hidden flags.
|
||||
* + If show is set to CKHIDE the object will be hidden and it also removes the hierarchically hidden flags.
|
||||
* + This function is overload by CKGroup,CKMesh and CK3dEntity.
|
||||
*/
|
||||
virtual void Show(CK_OBJECT_SHOWOPTION show = CK_OBJECT_SHOWOPTION::CKSHOW);
|
||||
/**
|
||||
* @brief Returns whether this object is hidden (and also hides its children).
|
||||
* @return true if hierarchically hidden.
|
||||
* @remark
|
||||
* + This methods returns if this object is hidden and also hides all its sub-hierarchy.
|
||||
* + See CKObject::Show¡ì for more details on hierarchically hidden objects.
|
||||
*/
|
||||
virtual bool IsHiddenByParent() const;
|
||||
/**
|
||||
* @brief Returns whether this object class allows it to be shown or hidden.
|
||||
* @return 3 possible value according to its type.
|
||||
* + CKCANNOTHIDE if the object cannot be hidden
|
||||
* + CKCANHIDE if the object can be hidden
|
||||
* + CKCANHIERARCHICALHIDE if the object can be hidden and hierarchically hidden
|
||||
* @remark
|
||||
* + This virtual function is mainly used by the Virtools interface to known if visibility flags have an impact on a specific object class.
|
||||
* + CKRenderObject and derived classes,can be triggered as to be shown or hidden or hierarchically hidden and will return 2 to this function.
|
||||
* + CKMesh and CKGroup can be triggered as to be shown or hidden and will return 1 to this function.
|
||||
* + Other classes will return 0 which means CKObject::Show function will not have any impact on them.
|
||||
|
||||
*/
|
||||
virtual CK_OBJECT_CANBEHIDE CanBeHide() const;
|
||||
virtual bool IsVisible() const;
|
||||
|
||||
protected:
|
||||
CK_ID m_ID;
|
||||
XContainer::XString m_Name;
|
||||
|
@ -82,217 +103,4 @@ namespace LibCmo::CK2::ObjImpls {
|
|||
CKContext* m_Context;
|
||||
};
|
||||
|
||||
//class CKSceneObject : public CKObject {
|
||||
//public:
|
||||
// CKSceneObject(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKSceneObject(const CKSceneObject&) = delete;
|
||||
// CKSceneObject& operator=(const CKSceneObject&) = delete;
|
||||
// virtual ~CKSceneObject();
|
||||
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_SCENEOBJECT; }
|
||||
//protected:
|
||||
// XBitArray m_Scenes;
|
||||
//};
|
||||
|
||||
//class CKBeObject : public CKSceneObject {
|
||||
//public:
|
||||
// CKBeObject(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKBeObject(const CKBeObject&) = delete;
|
||||
// CKBeObject& operator=(const CKBeObject&) = delete;
|
||||
// virtual ~CKBeObject();
|
||||
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_BEOBJECT; }
|
||||
//protected:
|
||||
|
||||
//};
|
||||
//
|
||||
//#pragma region Map Related
|
||||
//
|
||||
// class CKGroup : public CKBeObject {
|
||||
// public:
|
||||
// CKGroup(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKGroup(const CKGroup&) = delete;
|
||||
// CKGroup& operator=(const CKGroup&) = delete;
|
||||
// virtual ~CKGroup();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_GROUP; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
// class CKMesh : public CKBeObject {
|
||||
// public:
|
||||
// CKMesh(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKMesh(const CKMesh&) = delete;
|
||||
// CKMesh& operator=(const CKMesh&) = delete;
|
||||
// virtual ~CKMesh();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_MESH; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
// class CKTexture : public CKBeObject {
|
||||
// public:
|
||||
// CKTexture(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKTexture(const CKTexture&) = delete;
|
||||
// CKTexture& operator=(const CKTexture&) = delete;
|
||||
// virtual ~CKTexture();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_TEXTURE; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
// class CKMaterial : public CKBeObject {
|
||||
// public:
|
||||
// CKMaterial(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKMaterial(const CKMaterial&) = delete;
|
||||
// CKMaterial& operator=(const CKMaterial&) = delete;
|
||||
// virtual ~CKMaterial();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_MATERIAL; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
// class CKRenderObject : public CKBeObject {
|
||||
// public:
|
||||
// CKRenderObject(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKRenderObject(const CKRenderObject&) = delete;
|
||||
// CKRenderObject& operator=(const CKRenderObject&) = delete;
|
||||
// ~CKRenderObject();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_RENDEROBJECT; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
// class CK3dEntity : public CKRenderObject {
|
||||
// public:
|
||||
// CK3dEntity(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CK3dEntity(const CK3dEntity&) = delete;
|
||||
// CK3dEntity& operator=(const CK3dEntity&) = delete;
|
||||
// virtual ~CK3dEntity();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_3DENTITY; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
// class CK3dObject :public CK3dEntity {
|
||||
// public:
|
||||
// CK3dObject(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CK3dObject(const CK3dObject&) = delete;
|
||||
// CK3dObject& operator=(const CK3dObject&) = delete;
|
||||
// ~CK3dObject();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_3DOBJECT; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
//#pragma endregion
|
||||
//
|
||||
//#pragma region Behavior Related
|
||||
//
|
||||
// class CKParameterIn :public CKObject {
|
||||
// public:
|
||||
// CKParameterIn(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKParameterIn(const CKParameterIn&) = delete;
|
||||
// CKParameterIn& operator=(const CKParameterIn&) = delete;
|
||||
// ~CKParameterIn();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_PARAMETERIN; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
// class CKParameter :public CKObject {
|
||||
// public:
|
||||
// CKParameter(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKParameter(const CKParameter&) = delete;
|
||||
// CKParameter& operator=(const CKParameter&) = delete;
|
||||
// ~CKParameter();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_PARAMETER; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
// class CKParameterOut :public CKParameter {
|
||||
// public:
|
||||
// CKParameterOut(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKParameterOut(const CKParameterOut&) = delete;
|
||||
// CKParameterOut& operator=(const CKParameterOut&) = delete;
|
||||
// ~CKParameterOut();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_PARAMETEROUT; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
// class CKParameterLocal :public CKParameter {
|
||||
// public:
|
||||
// CKParameterLocal(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKParameterLocal(const CKParameterLocal&) = delete;
|
||||
// CKParameterLocal& operator=(const CKParameterLocal&) = delete;
|
||||
// ~CKParameterLocal();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_PARAMETERLOCAL; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
// class CKParameterOperation :public CKObject {
|
||||
// public:
|
||||
// CKParameterOperation(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKParameterOperation(const CKParameterOperation&) = delete;
|
||||
// CKParameterOperation& operator=(const CKParameterOperation&) = delete;
|
||||
// ~CKParameterOperation();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_PARAMETEROPERATION; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
// class CKBehaviorLink :public CKObject {
|
||||
// public:
|
||||
// CKBehaviorLink(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKBehaviorLink(const CKBehaviorLink&) = delete;
|
||||
// CKBehaviorLink& operator=(const CKBehaviorLink&) = delete;
|
||||
// ~CKBehaviorLink();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_BEHAVIORLINK; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
// class CKBehaviorIO :public CKObject {
|
||||
// public:
|
||||
// CKBehaviorIO(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKBehaviorIO(const CKBehaviorIO&) = delete;
|
||||
// CKBehaviorIO& operator=(const CKBehaviorIO&) = delete;
|
||||
// ~CKBehaviorIO();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_BEHAVIORIO; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
// class CKBehavior :public CKSceneObject {
|
||||
// public:
|
||||
// CKBehavior(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||
// CKBehavior(const CKBehavior&) = delete;
|
||||
// CKBehavior& operator=(const CKBehavior&) = delete;
|
||||
// ~CKBehavior();
|
||||
//
|
||||
// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_BEHAVIOR; }
|
||||
// protected:
|
||||
//
|
||||
// };
|
||||
//
|
||||
//#pragma endregion
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||
if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_TEXTURE::CK_STATESAVE_TEXSAVEFORMAT)) {
|
||||
auto buf = chunk->ReadBufferWrapper();
|
||||
if (buf != nullptr) {
|
||||
FakeBitmapProperties* props = reinterpret_cast<FakeBitmapProperties*>(buf.get());
|
||||
FakeBitmapProperties* props = static_cast<FakeBitmapProperties*>(buf.get());
|
||||
|
||||
CKBitmapProperties myprops(
|
||||
CKGUID(props->m_ReaderGuid.d1, props->m_ReaderGuid.d2),
|
||||
|
|
|
@ -399,7 +399,7 @@ namespace LibCmo::VxMath {
|
|||
class VxStridedData {
|
||||
public:
|
||||
VxStridedData(_Ty ptr, CKDWORD stride) :
|
||||
m_Ptr(reinterpret_cast<CKBYTE*>(m_Ptr)),
|
||||
m_Ptr(reinterpret_cast<CKBYTE*>(ptr)),
|
||||
m_Stride(stride) {}
|
||||
~VxStridedData() {}
|
||||
|
||||
|
|
|
@ -144,10 +144,13 @@ namespace LibCmo::XContainer {
|
|||
}
|
||||
namespace NSXObjectPointerArray {
|
||||
|
||||
void AddIfNotHere(XObjectPointerArray& objarray, CK2::ObjImpls::CKObject* const obj) {
|
||||
bool AddIfNotHere(XObjectPointerArray& objarray, CK2::ObjImpls::CKObject* const obj) {
|
||||
auto finder = std::find(objarray.begin(), objarray.end(), obj);
|
||||
if (finder == objarray.end()) {
|
||||
objarray.emplace_back(obj);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -181,11 +181,12 @@ namespace LibCmo::XContainer {
|
|||
namespace NSXObjectPointerArray {
|
||||
|
||||
/**
|
||||
* @brief Add object pointer if it is not list.
|
||||
* @brief Inserts the object at the end of the array, if it is not yet present.
|
||||
* @param objarray
|
||||
* @param obj
|
||||
* @return True if the object was already present, false otherwise
|
||||
*/
|
||||
void AddIfNotHere(XObjectPointerArray& objarray, CK2::ObjImpls::CKObject* const obj);
|
||||
bool AddIfNotHere(XObjectPointerArray& objarray, CK2::ObjImpls::CKObject* const obj);
|
||||
|
||||
/**
|
||||
* @brief Check Object pointer validation and remove invalid pointers before deletion.
|
||||
|
|
Loading…
Reference in New Issue
Block a user