add more struct and enum. impl some functions

This commit is contained in:
yyc12345 2023-09-05 22:23:05 +08:00
parent ab8a9da526
commit 2ec66131cf
15 changed files with 713 additions and 76 deletions

View File

@ -183,3 +183,148 @@ typedef enum CK_OBJECT_FLAGS {
CKBEHAVIORLINK_ACTIVATEDLASTFRAME = 0x20000000, // This link had been activated last frame
CK_OBJECT_BEHAVIORLINKMASK = 0x30000000,
} CK_OBJECT_FLAGS;
/*************************************************
{filename:CK_3DENTITY_FLAGS}
Summary: 3dEntity Flags
Remarks:
+ Flags give user and engine more information about the 3dEntity.
See also: CK3dEntity::SetFlags,CK3dEntity::GetFlags,
*************************************************/
typedef enum CK_3DENTITY_FLAGS {
CK_3DENTITY_DUMMY = 0x00000001, // Entity is a dummy used to represent a position
CK_3DENTITY_FRAME = 0x00000002, // Entity is a frame used to represent an orientation
CK_3DENTITY_RESERVED0 = 0x00000020, // Obsolete Flag
CK_3DENTITY_TARGETLIGHT = 0x00000100, // Entity is a target of a light
CK_3DENTITY_TARGETCAMERA = 0x00000200, // Entity is a target of a camera
CK_3DENTITY_IGNOREANIMATION = 0x00000400, // Animation using this entity can't modify it
CK_3DENTITY_HIERARCHICALOBSTACLE= 0x00000800, // Used by the Collision Manager
CK_3DENTITY_UPDATELASTFRAME = 0x00001000, // Store the last world matrix for this Entity after each render
CK_3DENTITY_CAMERAIGNOREASPECT = 0x00002000, // Ignore aspect ratio setting for cameras
CK_3DENTITY_DISABLESKINPROCESS = 0x00004000, // Force skin processing to be disabled
CK_3DENTITY_ENABLESKINOFFSET = 0x00008000, // If not set the skin stay attached to the bones the vertices are linked to, otherwise the skin can be freely rotated,translated or scaled according to its owner entity matrix.
CK_3DENTITY_PLACEVALID = 0x00010000, // Used internally when saving
CK_3DENTITY_PARENTVALID = 0x00020000, // Used internally when saving
CK_3DENTITY_IKJOINTVALID = 0x00040000, // Special flag for Bodyparts : IK Joint data is valid
CK_3DENTITY_PORTAL = 0x00080000, // The 3dEntity is a portal
CK_3DENTITY_ZORDERVALID = 0x00100000, // The 3dEntity has a non-zero ZOrder
CK_3DENTITY_CHARACTERDOPROCESS = 0x80000000, // Special flag for Characters : Automatic process of animation
} CK_3DENTITY_FLAGS;
/*****************************************************************
{filename:VX_MOVEABLE_FLAGS}
Summary: 3dEntity additionnal flags Options
Remarks:
+ The VX_MOVEABLE_FLAGS is used by CK3dEntity::SetMoveableFlags to specify different hints to the render engine about the entity.
+ The (Engine) flags are set by the render engine and should not be modified by user. They can be checked with the CK3dEntity::GetMoveableFlags method.
+ The (User) flags are to be set by the user or can be set by a specific method of CK3dEntity.
See Also: CK3dEntity::SetMoveableFlags
******************************************************************/
typedef enum VX_MOVEABLE_FLAGS {
VX_MOVEABLE_PICKABLE =0x00000001, // (User)If not set this entity cannot be returned by CKRenderContext::Pick() or CKRenderContext::RectPict() functions.
VX_MOVEABLE_VISIBLE =0x00000002, // (Engine) See CKObject::Show,CK3dEntity::IsVisible
VX_MOVEABLE_UPTODATE =0x00000004, // (Engine) Used to Notify change in the data of the entity.
VX_MOVEABLE_RENDERCHANNELS =0x00000008, // (User) If not set, additional material channels on the mesh used by this entity won't be rendered (CK3dEntity::SetRenderChannels)
VX_MOVEABLE_USERBOX =0x00000010, // (Engine) When CK3dEntity::SetBoundingBox is called with a user box, this flag is set.
VX_MOVEABLE_EXTENTSUPTODATE =0x00000020, // (Engine) Indicate that object 2D extents are up to date
VX_MOVEABLE_BOXVALID =0x00004000, // (Engine) If not set the moveable has no mesh associated so its bounding box is irrelevant (a point).
VX_MOVEABLE_RENDERLAST =0x00010000, // (User) If set the moveable will be rendered with the transparent objects (i.e in last) (CK3dEntity::SetRenderAsTransparent)
VX_MOVEABLE_HASMOVED =0x00020000, // (Engine) Set when its position or orientation has changed. (Reset every frame when rendering starts)
VX_MOVEABLE_WORLDALIGNED =0x00040000, // (User) Hint for render engine : this object is aligned with world position and orientation.
VX_MOVEABLE_NOZBUFFERWRITE =0x00080000, // (User) Set by the user to warn Render Engine that this object must not write information to Z buffer
VX_MOVEABLE_RENDERFIRST =0x00100000, // (User) If set the moveable will be rendered within the firsts objects
VX_MOVEABLE_NOZBUFFERTEST =0x00200000, // (User) Set by the user to warn Render Engine that this object must not test against Z buffer (This override settings of all materials used by this Entity)
VX_MOVEABLE_INVERSEWORLDMATVALID =0x00400000, // (Engine) Inverse world matrix is not up to date and should be recomputed
VX_MOVEABLE_DONTUPDATEFROMPARENT =0x00800000, // (User) This object will not be updated by parent (neither World nor Local matrix wil be updated) . This flags can be used by physic engine for example in which hierarchy is not relevant for physicalised objects
VX_MOVEABLE_INDIRECTMATRIX =0x01000000, // (User/Engine) Set by the engine at load time : The object matrix is in left hand referential, culling needs to be inverted
VX_MOVEABLE_ZBUFONLY =0x02000000, // (User) The object will only be rendered in depth buffer
VX_MOVEABLE_STENCILONLY =0x04000000, // (User) The object will only be rendered in stencil buffer
VX_MOVEABLE_HIERARCHICALHIDE =0x10000000, // (Engine) If Object has this flags and is hidden its children won't be rendered
VX_MOVEABLE_CHARACTERRENDERED =0x20000000, // (Engine) Set if a character was rendered last frame...
VX_MOVEABLE_RESERVED2 =0x40000000, // (Engine)
} VX_MOVEABLE_FLAGS;
/*****************************************************************
{filename:VXMESH_FLAGS}
Summary:Mesh Flags Options
Remarks:
+ The VXMESH_FLAGS is used by CKMesh::SetFlags to specify different hints to the render engine about the mesh.
+ Most of this flags can be set or asked using the appropriate method of CKMesh (given between () in the members documentation).
See Also: CKMesh,CKMesh::SetFlags
******************************************************************/
typedef enum VXMESH_FLAGS
{
VXMESH_BOUNDINGUPTODATE = 0x00000001, // If set the bounding box is up to date (internal).
VXMESH_VISIBLE = 0x00000002, // If not set the mesh will not be rendered (CKMesh::Show)
VXMESH_OPTIMIZED = 0x00000004, // Set by the render engine if the mesh is optimized for rendering. Unset it to force to recreate optimized structures (when changing materials or face organization ) (CKMesh::VertexMove)
VXMESH_RENDERCHANNELS = 0x00000008, // If not set Additional material channels won't be rendered.
VXMESH_HASTRANSPARENCY = 0x00000010, // If set indicates that one or more of the faces of this mesh use a transparent material (internal)
VXMESH_PRELITMODE = 0x00000080, // If set, no lightning should occur for this mesh, vertex color should be used instead (CKMesh::SetLitMode)
VXMESH_WRAPU = 0x00000100, // Texture coordinates wrapping among u texture coordinates. (CKMesh::SetWrapMode)
VXMESH_WRAPV = 0x00000200, // Texture coordinates wrapping among v texture coordinates. (CKMesh::SetWrapMode)
VXMESH_FORCETRANSPARENCY = 0x00001000, // Forces this mesh to be considered as transparent even if no material is tranparent. (CKMesh::SetTransparent)
VXMESH_TRANSPARENCYUPTODATE = 0x00002000, // If set, the flags VXMESH_HASTRANSPARENCY is up to date. (internal)
VXMESH_UV_CHANGED = 0x00004000, // Must be set if texture coordinates changed to enable the render engine to reconstruct potential display lists or vertex buffers. (CKMesh::UVChanged)
VXMESH_NORMAL_CHANGED = 0x00008000, // Must be set if normal coordinates changed to enable the render engine to reconstruct potential display lists or vertex buffers. (CKMesh::NormalChanged)
VXMESH_COLOR_CHANGED = 0x00010000, // Must be set if colors changed to enable the render engine to reconstruct potential display lists or vertex buffers. (CKMesh::ColorChanged)
VXMESH_POS_CHANGED = 0x00020000, // Must be set if vertex position changed to enable the render engine to reconstruct potential display lists or vertex buffers. (CKMesh::VertexMove)
VXMESH_HINTDYNAMIC = 0x00040000, // Hint for render engine : Mesh geometry is updated frequently
VXMESH_GENNORMALS = 0x00080000, // Hint : Normals were generated by BuildNormals : Do not save (internal)
VXMESH_PROCEDURALUV = 0x00100000, // Hint : UVs are generated : Do not save (internal)
VXMESH_PROCEDURALPOS = 0x00200000, // Hint : Vertices postions are generated : Do not save (internal)
VXMESH_STRIPIFY = 0x00400000, // If set the mesh will be stripified.
VXMESH_MONOMATERIAL = 0x00800000, // Set by the render engine if the mesh use only one material.
VXMESH_PM_BUILDNORM = 0x01000000, // Build normals when performing progressive meshing : Do not save (internal)
VXMESH_BWEIGHTS_CHANGED = 0x02000000, // Must be set if vertex blend weights have changed to enable the render engine to reconstruct potential display lists or vertex buffers. (CKMesh::VertexMove)
VXMESH_ALLFLAGS = 0x007FF39F
} VXMESH_FLAGS;
/*************************************************
{filename:CK_TEXTURE_SAVEOPTIONS}
Summary: Specify the way textures or sprites will be saved
Remarks :
+ Textures can be stored inside Virtools files or kept as references to external files.
+ These options can be used for a specific texture (or sprite) or as a global setting.
See also: CKBitmapData::SetSaveOptions,CKSprite::SetSaveOptions,CKContext::SetGlobalImagesSaveOptions
*************************************************/
typedef enum CK_TEXTURE_SAVEOPTIONS
{
CKTEXTURE_RAWDATA =0, // Save raw data inside file. The bitmap is saved in a raw 32 bit per pixel format.
CKTEXTURE_EXTERNAL =1, // Store only the file name for the texture. The bitmap file must be present in the bitmap paths
// when loading the composition.
CKTEXTURE_IMAGEFORMAT =2, // Save using format specified. The bitmap data will be converted to the
// specified format by the correspondant bitmap plugin and saved inside file.
CKTEXTURE_USEGLOBAL =3, // Use Global settings, that is the settings given with CKContext::SetGlobalImagesSaveOptions. (Not valid when using CKContext::SetImagesSaveOptions).
CKTEXTURE_INCLUDEORIGINALFILE =4, // Insert original image file inside CMO file. The bitmap file that
// was used originally for the texture or sprite will be append to
// the composition file and extracted when the file is loaded.
} CK_TEXTURE_SAVEOPTIONS;
/*************************************************
{filename:CK_SOUND_SAVEOPTIONS}
Summary: Specify the way sounds will be saved
Remarks :
+ Sounds can kept as references to external files or the original sound file can
be appended to the composition file.
+ These options can be used for a specific sound or as a global setting.
See also: CKSound::SetSaveOptions,CKContext::SetGlobalSoundSaveOptions
*************************************************/
typedef enum CK_SOUND_SAVEOPTIONS
{
CKSOUND_EXTERNAL =0, // Store only the file name for the sound. The sound file must be present
// in one of the sound paths when the composition is loaded.
CKSOUND_INCLUDEORIGINALFILE =1, // Insert original sound file inside the CMO file. The sound file that
// was used originally will be append to the composition file and
// extracted when the file is loaded.
CKSOUND_USEGLOBAL =2, // Use Global settings. This flag is only valid for the CKSound::SetSaveOptions method.
} CK_SOUND_SAVEOPTIONS;

View File

@ -0,0 +1,43 @@
/*****************************************************************
{filename:VX_PIXELFORMAT}
Name: VX_PIXELFORMAT
Summary: Pixel format types.
See Also: VxImageDesc2PixelFormat,VxPixelFormat2ImageDesc
******************************************************************/
typedef enum VX_PIXELFORMAT {
UNKNOWN_PF = 0, // Unknown pixel format
_32_ARGB8888 = 1, // 32-bit ARGB pixel format with alpha
_32_RGB888 = 2, // 32-bit RGB pixel format without alpha
_24_RGB888 = 3, // 24-bit RGB pixel format
_16_RGB565 = 4, // 16-bit RGB pixel format
_16_RGB555 = 5, // 16-bit RGB pixel format (5 bits per color)
_16_ARGB1555 = 6, // 16-bit ARGB pixel format (5 bits per color + 1 bit for alpha)
_16_ARGB4444 = 7, // 16-bit ARGB pixel format (4 bits per color)
_8_RGB332 = 8, // 8-bit RGB pixel format
_8_ARGB2222 = 9, // 8-bit ARGB pixel format
_32_ABGR8888 = 10, // 32-bit ABGR pixel format
_32_RGBA8888 = 11, // 32-bit RGBA pixel format
_32_BGRA8888 = 12, // 32-bit BGRA pixel format
_32_BGR888 = 13, // 32-bit BGR pixel format
_24_BGR888 = 14, // 24-bit BGR pixel format
_16_BGR565 = 15, // 16-bit BGR pixel format
_16_BGR555 = 16, // 16-bit BGR pixel format (5 bits per color)
_16_ABGR1555 = 17, // 16-bit ABGR pixel format (5 bits per color + 1 bit for alpha)
_16_ABGR4444 = 18, // 16-bit ABGR pixel format (4 bits per color)
_DXT1 = 19, // S3/DirectX Texture Compression 1
_DXT2 = 20, // S3/DirectX Texture Compression 2
_DXT3 = 21, // S3/DirectX Texture Compression 3
_DXT4 = 22, // S3/DirectX Texture Compression 4
_DXT5 = 23, // S3/DirectX Texture Compression 5
_16_V8U8 = 24, // 16-bit Bump Map format format (8 bits per color)
_32_V16U16 = 25, // 32-bit Bump Map format format (16 bits per color)
_16_L6V5U5 = 26, // 16-bit Bump Map format format with luminance
_32_X8L8V8U8 = 27, // 32-bit Bump Map format format with luminance
_8_ABGR8888_CLUT = 28, // 8 bits indexed CLUT (ABGR)
_8_ARGB8888_CLUT = 29, // 8 bits indexed CLUT (ARGB)
_4_ABGR8888_CLUT = 30, // 4 bits indexed CLUT (ABGR)
_4_ARGB8888_CLUT = 31 // 4 bits indexed CLUT (ARGB)
} VX_PIXELFORMAT;

View File

@ -1,5 +1,8 @@
#include "CKContext.hpp"
#include "ObjImpls/CKObject.hpp"
#include "MgrImpls/CKBaseManager.hpp"
#include "MgrImpls/CKObjectManager.hpp"
#include "MgrImpls/CKPathManager.hpp"
#include "../XContainer/XBitArray.hpp"
#include <cstdarg>
@ -14,9 +17,16 @@ namespace LibCmo::CK2 {
#pragma region Ctor Dtor
CKContext::CKContext() :
m_ObjectsList(), m_ReturnedObjectOffsets(),
m_GroupGlobalIndex(), m_SceneGlobalIndex(),
m_CompressionLevel(5), m_FileWriteMode(CK_FILE_WRITEMODE::CKFILE_UNCOMPRESSED),
// setup manager
m_ManagerList(),
m_ObjectManager(nullptr), m_PathManager(nullptr),
// setup file save/load options
m_CompressionLevel(5),
m_FileWriteMode(CK_FILE_WRITEMODE::CKFILE_UNCOMPRESSED),
m_GlobalImagesSaveOptions(CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_RAWDATA),
m_GlobalSoundsSaveOptions(CK_SOUND_SAVEOPTIONS::CKSOUND_EXTERNAL),
m_GlobalImagesSaveFormat(nullptr), // todo: setup save format
// misc init
m_NameEncoding(), m_TempFolder(),
m_OutputCallback(nullptr)
{
@ -26,24 +36,125 @@ namespace LibCmo::CK2 {
m_TempFolder = std::filesystem::temp_directory_path();
m_TempFolder /= g_UniqueFolder;
std::filesystem::create_directory(m_TempFolder);
// setup managers
m_ObjectManager = new MgrImpls::CKObjectManager(this);
m_ManagerList.emplace_back(m_ObjectManager);
m_PathManager = new MgrImpls::CKPathManager(this);
m_ManagerList.emplace_back(m_PathManager);
}
CKContext::~CKContext() {
// reset context
ClearAll();
// free all manager
for (auto& mgrptr : m_ManagerList) {
delete mgrptr;
}
}
#pragma endregion
#pragma region Objects Management
#pragma region Engine runtime
void CKContext::ClearAll() {
// pre clear all
ExecuteManagersOnPreClearAll();
// order object manager clear all objects
m_ObjectManager->DestroyAllObjects();
// post clear all
ExecuteManagersOnPostClearAll();
}
#pragma endregion
#pragma region Common Manager Functions
#pragma region Objects Management / Access
ObjImpls::CKObject* CKContext::CreateObject(CK_CLASSID cls, CKSTRING name, CK_OBJECTCREATION_OPTIONS options, CK_CREATIONMODE* res) {
return m_ObjectManager->CreateObject(cls, name, options, res);
}
ObjImpls::CKObject* CKContext::GetObject(CK_ID ObjID) {
return m_ObjectManager->GetObject(ObjID);
}
CKDWORD CKContext::GetObjectCount() {
return m_ObjectManager->GetObjectCount();
}
void CKContext::DestroyObject(ObjImpls::CKObject* obj) {
CK_ID id = obj->GetID();
return m_ObjectManager->DestroyObjects(&id, 1);
}
void CKContext::DestroyObject(CK_ID id) {
return m_ObjectManager->DestroyObjects(&id, 1);
}
void CKContext::DestroyObjects(CK_ID* obj_ids, CKDWORD Count) {
return m_ObjectManager->DestroyObjects(obj_ids, Count);
}
ObjImpls::CKObject* CKContext::GetObjectByName(CKSTRING name, ObjImpls::CKObject* previous) {
if (name == nullptr) return nullptr;
auto result = m_ObjectManager->GetObjectByNameAndClass(name, CK_CLASSID::CKCID_OBJECT, true);
auto finder = std::find(result.begin(), result.end(), previous);
if (finder == result.end()) return nullptr;
++finder;
if (finder == result.end()) return nullptr;
return *finder;
}
ObjImpls::CKObject* CKContext::GetObjectByNameAndClass(CKSTRING name, CK_CLASSID cid, ObjImpls::CKObject* previous) {
if (name == nullptr) return nullptr;
auto result = m_ObjectManager->GetObjectByNameAndClass(name, cid, false);
auto finder = std::find(result.begin(), result.end(), previous);
if (finder == result.end()) return nullptr;
++finder;
if (finder == result.end()) return nullptr;
return *finder;
}
ObjImpls::CKObject* CKContext::GetObjectByNameAndParentClass(CKSTRING name, CK_CLASSID pcid, ObjImpls::CKObject* previous) {
if (name == nullptr) return nullptr;
auto result = m_ObjectManager->GetObjectByNameAndClass(name, pcid, true);
auto finder = std::find(result.begin(), result.end(), previous);
if (finder == result.end()) return nullptr;
++finder;
if (finder == result.end()) return nullptr;
return *finder;
}
const XContainer::XObjectPointerArray CKContext::GetObjectListByType(CK_CLASSID cid, bool derived) {
return m_ObjectManager->GetObjectByNameAndClass(nullptr, cid, derived);
}
CKDWORD CKContext::GetObjectsCountByClassID(CK_CLASSID cid) {
auto result = m_ObjectManager->GetObjectByNameAndClass(nullptr, cid, false);
return static_cast<CKDWORD>(result.size());
}
CK_ID* CKContext::GetObjectsListByClassID(CK_CLASSID cid) {
// todo: impl internal buffer
}
#pragma endregion
#pragma region Common Managers
MgrImpls::CKObjectManager* CKContext::GetObjectManager() {
return m_ObjectManager;
}
MgrImpls::CKPathManager* CKContext::GetPathManager() {
return m_PathManager;
}
CKDWORD CKContext::GetManagerCount() {
return m_ManagerList.size();
}
@ -53,6 +164,36 @@ namespace LibCmo::CK2 {
return m_ManagerList[index];
}
void CKContext::ExecuteManagersOnPreClearAll() {
ExecuteManagersGeneral([](MgrImpls::CKBaseManager* mgr) -> void {
mgr->PreClearAll();
});
}
void CKContext::ExecuteManagersOnPostClearAll() {
ExecuteManagersGeneral([](MgrImpls::CKBaseManager* mgr) -> void {
mgr->PostClearAll();
});
}
void CKContext::ExecuteManagersOnSequenceToBeDeleted(const CK_ID* objids, CKDWORD count) {
ExecuteManagersGeneral([objids, count](MgrImpls::CKBaseManager* mgr) -> void {
mgr->SequenceToBeDeleted(objids, count);
});
}
void CKContext::ExecuteManagersOnSequenceDeleted(const CK_ID* objids, CKDWORD count) {
ExecuteManagersGeneral([objids, count](MgrImpls::CKBaseManager* mgr) -> void {
mgr->SequenceDeleted(objids, count);
});
}
void CKContext::ExecuteManagersGeneral(std::function<void(MgrImpls::CKBaseManager*)> fct) {
for (auto& mgrptr : m_ManagerList) {
fct(mgrptr);
}
}
#pragma endregion
#pragma region File Save/Load Options
@ -75,6 +216,34 @@ namespace LibCmo::CK2 {
return m_FileWriteMode;
}
CK_TEXTURE_SAVEOPTIONS CKContext::GetGlobalImagesSaveOptions() {
return m_GlobalImagesSaveOptions;
}
void CKContext::SetGlobalImagesSaveOptions(CK_TEXTURE_SAVEOPTIONS Options) {
if (Options != CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_USEGLOBAL) {
m_GlobalImagesSaveOptions = Options;
}
}
const CKBitmapProperties* CKContext::GetGlobalImagesSaveFormat() {
return m_GlobalImagesSaveFormat;
}
void CKContext::SetGlobalImagesSaveFormat(const CKBitmapProperties* Format) {
// todo: copy CKBitmapProperties
}
CK_SOUND_SAVEOPTIONS CKContext::GetGlobalSoundsSaveOptions() {
return m_GlobalSoundsSaveOptions;
}
void CKContext::SetGlobalSoundsSaveOptions(CK_SOUND_SAVEOPTIONS Options) {
if (Options != CK_SOUND_SAVEOPTIONS::CKSOUND_USEGLOBAL) {
m_GlobalSoundsSaveOptions = Options;
}
}
#pragma endregion

View File

@ -23,14 +23,36 @@ namespace LibCmo::CK2 {
CKContext();
~CKContext();
LIBCMO_DISABLE_COPY_MOVE(CKContext);
// ========== Engine runtime ==========
public:
/**
* @brief Simply clear all CKContext to restore its status.
*/
void ClearAll();
// ========== Common Managers ==========
// ========== Objects Management / Access ==========
// These functions is a simply redirect to CKObjectManager
ObjImpls::CKObject* CreateObject(CK_CLASSID cls, CKSTRING name,
CK_OBJECTCREATION_OPTIONS options = CK_OBJECTCREATION_OPTIONS::CK_OBJECTCREATION_NONAMECHECK,
CK_CREATIONMODE* res = nullptr);
ObjImpls::CKObject* GetObject(CK_ID ObjID);
CKDWORD GetObjectCount();
void DestroyObject(ObjImpls::CKObject *obj);
void DestroyObject(CK_ID id);
void DestroyObjects(CK_ID* obj_ids, CKDWORD Count);
ObjImpls::CKObject* GetObjectByName(CKSTRING name, ObjImpls::CKObject *previous = nullptr);
ObjImpls::CKObject* GetObjectByNameAndClass(CKSTRING name, CK_CLASSID cid, ObjImpls::CKObject *previous = nullptr);
ObjImpls::CKObject* GetObjectByNameAndParentClass(CKSTRING name, CK_CLASSID pcid, ObjImpls::CKObject* previous);
const XContainer::XObjectPointerArray GetObjectListByType(CK_CLASSID cid, bool derived);
CKDWORD GetObjectsCountByClassID(CK_CLASSID cid);
CK_ID* GetObjectsListByClassID(CK_CLASSID cid);
// ========== Common Managers ==========
public:
MgrImpls::CKObjectManager* GetObjectManager();
MgrImpls::CKPathManager* GetPathManager();
@ -39,11 +61,18 @@ namespace LibCmo::CK2 {
void ExecuteManagersOnPreClearAll();
void ExecuteManagersOnPostClearAll();
void ExecuteManagersSequenceToBeDeleted();
void ExecuteManagersSequenceDeleted();
void ExecuteManagersOnSequenceToBeDeleted(const CK_ID* objids, CKDWORD count);
void ExecuteManagersOnSequenceDeleted(const CK_ID* objids, CKDWORD count);
protected:
void ExecuteManagersGeneral(std::function<void(MgrImpls::CKBaseManager*)> fct);
XContainer::XArray<MgrImpls::CKBaseManager*> m_ManagerList;
MgrImpls::CKObjectManager* m_ObjectManager;
MgrImpls::CKPathManager* m_PathManager;
// ========== File Save/Load Options ==========
public:
void SetCompressionLevel(CKINT level);
CKINT GetCompressionLevel();
@ -53,36 +82,13 @@ namespace LibCmo::CK2 {
CK_TEXTURE_SAVEOPTIONS GetGlobalImagesSaveOptions();
void SetGlobalImagesSaveOptions(CK_TEXTURE_SAVEOPTIONS Options);
CKBitmapProperties* GetGlobalImagesSaveFormat();
void SetGlobalImagesSaveFormat(CKBitmapProperties* Format);
const CKBitmapProperties* GetGlobalImagesSaveFormat();
void SetGlobalImagesSaveFormat(const CKBitmapProperties* Format);
CK_SOUND_SAVEOPTIONS GetGlobalSoundsSaveOptions();
void SetGlobalSoundsSaveOptions(CK_SOUND_SAVEOPTIONS Options);
// ========== Encoding utilities ==========
void GetUtf8String(const std::string& native_name, std::string& u8_name);
void GetNativeString(const std::string& u8_name, std::string& native_name);
void SetEncoding(const std::vector<std::string> encoding_series);
// ========== Temp IO utilities ==========
void SetTempPath(CKSTRING u8_temp);
std::string GetTempFilePath(CKSTRING u8_filename);
// ========== Print utilities ==========
using OutputCallback = std::function<void(CKSTRING)>;
void OutputToConsole(CKSTRING str);
void OutputToConsoleEx(CKSTRING fmt, ...);
void SetOutputCallback(OutputCallback cb);
protected:
// ========== Common Managers ==========
void ExecuteManagersGeneral(std::function<void(MgrImpls::CKBaseManager*)> fct);
XContainer::XArray<MgrImpls::CKBaseManager*> m_ManagerList;
// ========== File Save/Load Options ==========
CKINT m_CompressionLevel;
CK_FILE_WRITEMODE m_FileWriteMode;
CK_TEXTURE_SAVEOPTIONS m_GlobalImagesSaveOptions;
@ -90,15 +96,30 @@ namespace LibCmo::CK2 {
CKBitmapProperties* m_GlobalImagesSaveFormat;
// ========== Encoding utilities ==========
public:
void GetUtf8String(const std::string& native_name, std::string& u8_name);
void GetNativeString(const std::string& u8_name, std::string& native_name);
void SetEncoding(const std::vector<std::string> encoding_series);
protected:
std::vector<EncodingHelper::ENCODING_TOKEN> m_NameEncoding;
// ========== Temp IO utilities ==========
public:
void SetTempPath(CKSTRING u8_temp);
std::string GetTempFilePath(CKSTRING u8_filename);
protected:
std::filesystem::path m_TempFolder;
// ========== Print utilities ==========
public:
using OutputCallback = std::function<void(CKSTRING)>;
void OutputToConsole(CKSTRING str);
void OutputToConsoleEx(CKSTRING fmt, ...);
void SetOutputCallback(OutputCallback cb);
protected:
OutputCallback m_OutputCallback;
};

View File

@ -1,5 +1,6 @@
#pragma once
#include "../VTUtils.hpp"
#include "CKTypes.hpp"
#include "../XContainer/XTypes.hpp"
#include <string>

View File

@ -54,7 +54,7 @@ namespace LibCmo::CK2 {
controls whether compression is enabled and also if the Virtools Dev Interface specific data
should be stored in the file (if CKFILE_FORVIEWER flag is set , no interface data is saved)
See also: CKContext::SetFileWriteMode, CKContext::GetFileWriteMode, CKContext::SetCompressionLevel,
@see CKContext::SetFileWriteMode, CKContext::GetFileWriteMode, CKContext::SetCompressionLevel,
CKContext::SetGlobalImagesSaveOptions, CKContext::SetGlobalSoundsSaveOptions
*/
enum class CK_FILE_WRITEMODE : uint32_t {
@ -97,7 +97,7 @@ namespace LibCmo::CK2 {
CK_FO_DONTLOADOBJECT, /**< Object chunk will not be read either because it is a reference or because the loaded object already exist in the current level and the user choose to keep the existing one. */
};
/**
Summary: Specify the way an object just loaded should be handled when it already exists in the level.
@brief Specify the way an object just loaded should be handled when it already exists in the level.
*/
enum class CK_LOADMODE : int32_t {
CKLOAD_INVALID = -1, /**< Use the existing object instead of loading */
@ -186,7 +186,7 @@ namespace LibCmo::CK2 {
+ Some of this flags are shared with sub-classes such as CKParameterIn,CKParameterOut and CKBehaviorIO.
+ You rarely need to modify directly this flags through CKObject::SetFlags or CKObject::ModifyObjectFlags instead
you should always use the specific acces function (given between ()) which may need to perform additionnal operations.
See also: CKObject, CKObject::GetObjectFlags, CKObject::ModifyObjectFlags
@see CKObject, CKObject::GetObjectFlags, CKObject::ModifyObjectFlags
*/
enum class CK_OBJECT_FLAGS : uint32_t {
CK_OBJECT_INTERFACEOBJ = 0x00000001, /**< Reserved for Inteface Use */
@ -224,4 +224,126 @@ namespace LibCmo::CK2 {
CK_OBJECT_BEHAVIORLINKMASK = 0x30000000,
};
/**
@brief 3dEntity Flags
@remark
+ Flags give user and engine more information about the 3dEntity.
@see CK3dEntity::SetFlags,CK3dEntity::GetFlags
*/
enum class CK_3DENTITY_FLAGS : uint32_t {
CK_3DENTITY_DUMMY = 0x00000001, /**< Entity is a dummy used to represent a position */
CK_3DENTITY_FRAME = 0x00000002, /**< Entity is a frame used to represent an orientation */
CK_3DENTITY_RESERVED0 = 0x00000020, /**< Obsolete Flag */
CK_3DENTITY_TARGETLIGHT = 0x00000100, /**< Entity is a target of a light */
CK_3DENTITY_TARGETCAMERA = 0x00000200, /**< Entity is a target of a camera */
CK_3DENTITY_IGNOREANIMATION = 0x00000400, /**< Animation using this entity can't modify it */
CK_3DENTITY_HIERARCHICALOBSTACLE = 0x00000800, /**< Used by the Collision Manager */
CK_3DENTITY_UPDATELASTFRAME = 0x00001000, /**< Store the last world matrix for this Entity after each render */
CK_3DENTITY_CAMERAIGNOREASPECT = 0x00002000, /**< Ignore aspect ratio setting for cameras */
CK_3DENTITY_DISABLESKINPROCESS = 0x00004000, /**< Force skin processing to be disabled */
CK_3DENTITY_ENABLESKINOFFSET = 0x00008000, /**< If not set the skin stay attached to the bones the vertices are linked to, otherwise the skin can be freely rotated,translated or scaled according to its owner entity matrix. */
CK_3DENTITY_PLACEVALID = 0x00010000, /**< Used internally when saving */
CK_3DENTITY_PARENTVALID = 0x00020000, /**< Used internally when saving */
CK_3DENTITY_IKJOINTVALID = 0x00040000, /**< Special flag for Bodyparts : IK Joint data is valid */
CK_3DENTITY_PORTAL = 0x00080000, /**< The 3dEntity is a portal */
CK_3DENTITY_ZORDERVALID = 0x00100000, /**< The 3dEntity has a non-zero ZOrder */
CK_3DENTITY_CHARACTERDOPROCESS = 0x80000000, /**< Special flag for Characters : Automatic process of animation */
};
/**
@brief 3dEntity additionnal flags Options
@remark
+ The VX_MOVEABLE_FLAGS is used by CK3dEntity::SetMoveableFlags to specify different hints to the render engine about the entity.
+ The (Engine) flags are set by the render engine and should not be modified by user. They can be checked with the CK3dEntity::GetMoveableFlags method.
+ The (User) flags are to be set by the user or can be set by a specific method of CK3dEntity.
@see CK3dEntity::SetMoveableFlags
*/
enum class VX_MOVEABLE_FLAGS : uint32_t {
VX_MOVEABLE_PICKABLE = 0x00000001, /**< (User)If not set this entity cannot be returned by CKRenderContext::Pick() or CKRenderContext::RectPict() functions. */
VX_MOVEABLE_VISIBLE = 0x00000002, /**< (Engine) See CKObject::Show,CK3dEntity::IsVisible */
VX_MOVEABLE_UPTODATE = 0x00000004, /**< (Engine) Used to Notify change in the data of the entity. */
VX_MOVEABLE_RENDERCHANNELS = 0x00000008, /**< (User) If not set, additional material channels on the mesh used by this entity won't be rendered (CK3dEntity::SetRenderChannels) */
VX_MOVEABLE_USERBOX = 0x00000010, /**< (Engine) When CK3dEntity::SetBoundingBox is called with a user box, this flag is set. */
VX_MOVEABLE_EXTENTSUPTODATE = 0x00000020, /**< (Engine) Indicate that object 2D extents are up to date */
VX_MOVEABLE_BOXVALID = 0x00004000, /**< (Engine) If not set the moveable has no mesh associated so its bounding box is irrelevant (a point). */
VX_MOVEABLE_RENDERLAST = 0x00010000, /**< (User) If set the moveable will be rendered with the transparent objects (i.e in last) (CK3dEntity::SetRenderAsTransparent) */
VX_MOVEABLE_HASMOVED = 0x00020000, /**< (Engine) Set when its position or orientation has changed. (Reset every frame when rendering starts) */
VX_MOVEABLE_WORLDALIGNED = 0x00040000, /**< (User) Hint for render engine : this object is aligned with world position and orientation. */
VX_MOVEABLE_NOZBUFFERWRITE = 0x00080000, /**< (User) Set by the user to warn Render Engine that this object must not write information to Z buffer */
VX_MOVEABLE_RENDERFIRST = 0x00100000, /**< (User) If set the moveable will be rendered within the firsts objects */
VX_MOVEABLE_NOZBUFFERTEST = 0x00200000, /**< (User) Set by the user to warn Render Engine that this object must not test against Z buffer (This override settings of all materials used by this Entity) */
VX_MOVEABLE_INVERSEWORLDMATVALID = 0x00400000, /**< (Engine) Inverse world matrix is not up to date and should be recomputed */
VX_MOVEABLE_DONTUPDATEFROMPARENT = 0x00800000, /**< (User) This object will not be updated by parent (neither World nor Local matrix wil be updated) . This flags can be used by physic engine for example in which hierarchy is not relevant for physicalised objects */
VX_MOVEABLE_INDIRECTMATRIX = 0x01000000, /**< (User/Engine) Set by the engine at load time : The object matrix is in left hand referential, culling needs to be inverted */
VX_MOVEABLE_ZBUFONLY = 0x02000000, /**< (User) The object will only be rendered in depth buffer */
VX_MOVEABLE_STENCILONLY = 0x04000000, /**< (User) The object will only be rendered in stencil buffer */
VX_MOVEABLE_HIERARCHICALHIDE = 0x10000000, /**< (Engine) If Object has this flags and is hidden its children won't be rendered */
VX_MOVEABLE_CHARACTERRENDERED = 0x20000000, /**< (Engine) Set if a character was rendered last frame... */
VX_MOVEABLE_RESERVED2 = 0x40000000, /**< (Engine) */
};
/**
****************************************************************
@briefMesh Flags Options
@remark
+ The VXMESH_FLAGS is used by CKMesh::SetFlags to specify different hints to the render engine about the mesh.
+ Most of this flags can be set or asked using the appropriate method of CKMesh (given between () in the members documentation).
@see CKMesh,CKMesh::SetFlags
***************************************************************
*/
enum class VXMESH_FLAGS : uint32_t {
VXMESH_BOUNDINGUPTODATE = 0x00000001, /**< If set the bounding box is up to date (internal). */
VXMESH_VISIBLE = 0x00000002, /**< If not set the mesh will not be rendered (CKMesh::Show) */
VXMESH_OPTIMIZED = 0x00000004, /**< Set by the render engine if the mesh is optimized for rendering. Unset it to force to recreate optimized structures (when changing materials or face organization ) (CKMesh::VertexMove) */
VXMESH_RENDERCHANNELS = 0x00000008, /**< If not set Additional material channels won't be rendered. */
VXMESH_HASTRANSPARENCY = 0x00000010, /**< If set indicates that one or more of the faces of this mesh use a transparent material (internal) */
VXMESH_PRELITMODE = 0x00000080, /**< If set, no lightning should occur for this mesh, vertex color should be used instead (CKMesh::SetLitMode) */
VXMESH_WRAPU = 0x00000100, /**< Texture coordinates wrapping among u texture coordinates. (CKMesh::SetWrapMode) */
VXMESH_WRAPV = 0x00000200, /**< Texture coordinates wrapping among v texture coordinates. (CKMesh::SetWrapMode) */
VXMESH_FORCETRANSPARENCY = 0x00001000, /**< Forces this mesh to be considered as transparent even if no material is tranparent. (CKMesh::SetTransparent) */
VXMESH_TRANSPARENCYUPTODATE = 0x00002000, /**< If set, the flags VXMESH_HASTRANSPARENCY is up to date. (internal) */
VXMESH_UV_CHANGED = 0x00004000, /**< Must be set if texture coordinates changed to enable the render engine to reconstruct potential display lists or vertex buffers. (CKMesh::UVChanged) */
VXMESH_NORMAL_CHANGED = 0x00008000, /**< Must be set if normal coordinates changed to enable the render engine to reconstruct potential display lists or vertex buffers. (CKMesh::NormalChanged) */
VXMESH_COLOR_CHANGED = 0x00010000, /**< Must be set if colors changed to enable the render engine to reconstruct potential display lists or vertex buffers. (CKMesh::ColorChanged) */
VXMESH_POS_CHANGED = 0x00020000, /**< Must be set if vertex position changed to enable the render engine to reconstruct potential display lists or vertex buffers. (CKMesh::VertexMove) */
VXMESH_HINTDYNAMIC = 0x00040000, /**< Hint for render engine : Mesh geometry is updated frequently */
VXMESH_GENNORMALS = 0x00080000, /**< Hint : Normals were generated by BuildNormals : Do not save (internal) */
VXMESH_PROCEDURALUV = 0x00100000, /**< Hint : UVs are generated : Do not save (internal) */
VXMESH_PROCEDURALPOS = 0x00200000, /**< Hint : Vertices postions are generated : Do not save (internal) */
VXMESH_STRIPIFY = 0x00400000, /**< If set the mesh will be stripified. */
VXMESH_MONOMATERIAL = 0x00800000, /**< Set by the render engine if the mesh use only one material. */
VXMESH_PM_BUILDNORM = 0x01000000, /**< Build normals when performing progressive meshing : Do not save (internal) */
VXMESH_BWEIGHTS_CHANGED = 0x02000000, /**< Must be set if vertex blend weights have changed to enable the render engine to reconstruct potential display lists or vertex buffers. (CKMesh::VertexMove) */
VXMESH_ALLFLAGS = 0x007FF39F,
};
/**
************************************************
@brief Specify the way textures or sprites will be saved
@remark
+ Textures can be stored inside Virtools files or kept as references to external files.
+ These options can be used for a specific texture (or sprite) or as a global setting.
@see CKBitmapData::SetSaveOptions,CKSprite::SetSaveOptions,CKContext::SetGlobalImagesSaveOptions
**********************************************
*/
enum class CK_TEXTURE_SAVEOPTIONS : uint32_t {
CKTEXTURE_RAWDATA = 0, /**< Save raw data inside file. The bitmap is saved in a raw 32 bit per pixel format. */
CKTEXTURE_EXTERNAL = 1, /**< Store only the file name for the texture. The bitmap file must be present in the bitmap paths when loading the composition. */
CKTEXTURE_IMAGEFORMAT = 2, /**< Save using format specified. The bitmap data will be converted to the specified format by the correspondant bitmap plugin and saved inside file. */
CKTEXTURE_USEGLOBAL = 3, /**< Use Global settings, that is the settings given with CKContext::SetGlobalImagesSaveOptions. (Not valid when using CKContext::SetImagesSaveOptions). */
CKTEXTURE_INCLUDEORIGINALFILE = 4, /**< Insert original image file inside CMO file. The bitmap file that was used originally for the texture or sprite will be append to the composition file and extracted when the file is loaded. */
};
/**
************************************************
@brief Specify the way sounds will be saved
@remark
+ Sounds can kept as references to external files or the original sound file can
be appended to the composition file.
+ These options can be used for a specific sound or as a global setting.
@see CKSound::SetSaveOptions,CKContext::SetGlobalSoundSaveOptions
**********************************************
*/
enum class CK_SOUND_SAVEOPTIONS : uint32_t {
CKSOUND_EXTERNAL = 0, /**< Store only the file name for the sound. The sound file must be present in one of the sound paths when the composition is loaded. */
CKSOUND_INCLUDEORIGINALFILE = 1, /**< Insert original sound file inside the CMO file. The sound file that was used originally will be append to the composition file and extracted when the file is loaded. */
CKSOUND_USEGLOBAL = 2, /**< Use Global settings. This flag is only valid for the CKSound::SetSaveOptions method. */
};
}

View File

@ -1,5 +1,6 @@
#pragma once
#include "../VTUtils.hpp"
#include <string>
#include <vector>
#include <cstring>

View File

@ -1,4 +1,5 @@
#include "CKObjectManager.hpp"
#include "../CKContext.hpp"
#include "../ObjImpls/CKObject.hpp"
namespace LibCmo::CK2::MgrImpls {
@ -67,21 +68,29 @@ namespace LibCmo::CK2::MgrImpls {
desc->ReleaseFct(m_Context, obj);
}
void CKObjectManager::DestroyObject(CK_ID id) {
CKDWORD off = Id2Offset(id);
if (off >= m_ObjectsList.size()) return;
void CKObjectManager::DestroyObjects(CK_ID* ids, CKDWORD count) {
// notice pre
m_Context->ExecuteManagersOnSequenceToBeDeleted(ids, count);
// get object and free it
ObjImpls::CKObject* obj = m_ObjectsList[off];
if (obj == nullptr) return;
InternalDestroy(obj);
for (CKDWORD i = 0; i < count; ++i) {
CKDWORD off = Id2Offset(ids[i]);
if (off >= m_ObjectsList.size()) continue;
// return its allocated id.
// and dec count
m_ObjectsList[off] = nullptr;
m_ReturnedObjectOffsets.emplace_back(off);
--m_ObjectCount;
// get object and free it
ObjImpls::CKObject* obj = m_ObjectsList[off];
if (obj == nullptr) continue;
InternalDestroy(obj);
// return its allocated id.
// and dec count
m_ObjectsList[off] = nullptr;
m_ReturnedObjectOffsets.emplace_back(off);
--m_ObjectCount;
}
// notice post
m_Context->ExecuteManagersOnSequenceDeleted(ids, count);
}
void CKObjectManager::DestroyAllObjects() {
@ -110,7 +119,7 @@ namespace LibCmo::CK2::MgrImpls {
XContainer::XObjectPointerArray CKObjectManager::GetObjectByNameAndClass(CKSTRING name, CK_CLASSID cid, bool derived) {
XContainer::XObjectPointerArray result;
for (size_t i = 0; i < m_ObjectsListByClass.size(); ++i) {
// check class id first
if (derived) {
@ -118,7 +127,7 @@ namespace LibCmo::CK2::MgrImpls {
} else {
if (static_cast<CK_CLASSID>(i) != cid) continue;
}
// iterate all sub object and check name
for (const auto& objoff : m_ObjectsListByClass[i]) {
ObjImpls::CKObject* obj = m_ObjectsList[objoff];

View File

@ -35,7 +35,7 @@ namespace LibCmo::CK2::MgrImpls {
ObjImpls::CKObject* GetObject(CK_ID id);
CKDWORD GetObjectCount();
void DestroyObject(CK_ID id);
void DestroyObjects(CK_ID* ids, CKDWORD count);
void DestroyAllObjects();
// ========== Objects Access ==========

View File

@ -217,6 +217,8 @@
<ClInclude Include="VTEncoding.hpp" />
<ClInclude Include="CK2\ObjImpls\CKObject.hpp" />
<ClInclude Include="VTUtils.hpp" />
<ClInclude Include="VxMath\VxEnums.hpp" />
<ClInclude Include="VxMath\VxMath.hpp" />
<ClInclude Include="VxMath\VxMemoryMappedFile.hpp" />
<ClInclude Include="VxMath\VxTypes.hpp" />
<ClInclude Include="XContainer\XBitArray.hpp" />

View File

@ -179,5 +179,11 @@
<ClInclude Include="CK2\MgrImpls\CKPathManager.hpp">
<Filter>Headers\CK2\MgrImpls</Filter>
</ClInclude>
<ClInclude Include="VxMath\VxEnums.hpp">
<Filter>Headers\VxMath</Filter>
</ClInclude>
<ClInclude Include="VxMath\VxMath.hpp">
<Filter>Headers\VxMath</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -9,7 +9,8 @@ This header only fulfill type requirements. If you want
some implement based operations, such as calling
CKStateChunk or CKContext function. You should include them manually.
This file is used as Pre-compiled header in Visual Studio.
All header or cpp file should include this file first.
Except the file listed in there, they should include "VTUtils.hpp" first.
*/
#include "VTUtils.hpp"
@ -21,6 +22,8 @@ This file is used as Pre-compiled header in Visual Studio.
#include "CK2/CKIdentifiers.hpp" // CKStateChunk identifiers.
#include "CK2/CKGlobals.hpp" // CK global functions, such as CKUnPack and etc.
#include "VxMath/VxEnums.hpp"
#include "VxMath/VxTypes.hpp"
#include "VxMath/VxMath.hpp"
#include "XContainer/XTypes.hpp"

48
LibCmo/VxMath/VxEnums.hpp Normal file
View File

@ -0,0 +1,48 @@
#pragma once
#include "../VTUtils.hpp"
#include <cinttypes>
#include <cstdint>
namespace LibCmo::VxMath {
/**
@brief Pixel format types.
@see VxImageDesc2PixelFormat, VxPixelFormat2ImageDesc
*/
enum class VX_PIXELFORMAT : uint32_t {
UNKNOWN_PF = 0, /**< Unknown pixel format */
_32_ARGB8888 = 1, /**< 32-bit ARGB pixel format with alpha */
_32_RGB888 = 2, /**< 32-bit RGB pixel format without alpha */
_24_RGB888 = 3, /**< 24-bit RGB pixel format */
_16_RGB565 = 4, /**< 16-bit RGB pixel format */
_16_RGB555 = 5, /**< 16-bit RGB pixel format (5 bits per color) */
_16_ARGB1555 = 6, /**< 16-bit ARGB pixel format (5 bits per color + 1 bit for alpha) */
_16_ARGB4444 = 7, /**< 16-bit ARGB pixel format (4 bits per color) */
_8_RGB332 = 8, /**< 8-bit RGB pixel format */
_8_ARGB2222 = 9, /**< 8-bit ARGB pixel format */
_32_ABGR8888 = 10, /**< 32-bit ABGR pixel format */
_32_RGBA8888 = 11, /**< 32-bit RGBA pixel format */
_32_BGRA8888 = 12, /**< 32-bit BGRA pixel format */
_32_BGR888 = 13, /**< 32-bit BGR pixel format */
_24_BGR888 = 14, /**< 24-bit BGR pixel format */
_16_BGR565 = 15, /**< 16-bit BGR pixel format */
_16_BGR555 = 16, /**< 16-bit BGR pixel format (5 bits per color) */
_16_ABGR1555 = 17, /**< 16-bit ABGR pixel format (5 bits per color + 1 bit for alpha) */
_16_ABGR4444 = 18, /**< 16-bit ABGR pixel format (4 bits per color) */
_DXT1 = 19, /**< S3/DirectX Texture Compression 1 */
_DXT2 = 20, /**< S3/DirectX Texture Compression 2 */
_DXT3 = 21, /**< S3/DirectX Texture Compression 3 */
_DXT4 = 22, /**< S3/DirectX Texture Compression 4 */
_DXT5 = 23, /**< S3/DirectX Texture Compression 5 */
_16_V8U8 = 24, /**< 16-bit Bump Map format format (8 bits per color) */
_32_V16U16 = 25, /**< 32-bit Bump Map format format (16 bits per color) */
_16_L6V5U5 = 26, /**< 16-bit Bump Map format format with luminance */
_32_X8L8V8U8 = 27, /**< 32-bit Bump Map format format with luminance */
_8_ABGR8888_CLUT = 28, /**< 8 bits indexed CLUT (ABGR) */
_8_ARGB8888_CLUT = 29, /**< 8 bits indexed CLUT (ARGB) */
_4_ABGR8888_CLUT = 30, /**< 4 bits indexed CLUT (ABGR) */
_4_ARGB8888_CLUT = 31, /**< 4 bits indexed CLUT (ARGB) */
};
}

49
LibCmo/VxMath/VxMath.hpp Normal file
View File

@ -0,0 +1,49 @@
#include "../VTUtils.hpp"
#include "../CK2/CKTypes.hpp"
#include "VxTypes.hpp"
namespace LibCmo::VxMath {
// ========== Structure copying ==========
/**
* @brief Fills a memory buffer with a source buffer pattern.
* @param Count[in] Number of element to set in the destination buffer
* @param Dst[out] Destination buffer
* @param Stride[in] Amount in bytes between each element in the destination buffer
* @param SizeSrc[in] Size in bytes (but must be a multiple of 4) of an element int the Src buffer
* @param Src[in] Source buffer
* @remark This function can be used to initialized an array of structure when only some members should be modified.
*/
void VxFillStructure(CK2::CKDWORD Count, void* Dst, CK2::CKDWORD Stride, CK2::CKDWORD SizeSrc, const void* Src);
/**
* @brief copies an array of elements between two memory buffers.
* @param Count[in] Number of element to copy in the destination buffer
* @param Dst[out] Destination buffer
* @param OutStride[in] Amount in bytes between each element in the destination buffer
* @param SizeSrc[in] Size in bytes (but must be a multiple of 4) of an element
* @param Src[in] Source buffer.
* @param InStride[in] Amount in bytes between each element in the source buffer
* @remark This function can be used to initialized an array of structure when only some members should be modified.
*/
void VxCopyStructure(CK2::CKDWORD Count, void* Dst, CK2::CKDWORD OutStride, CK2::CKDWORD SizeSrc, const void* Src,CK2::CKDWORD InStride);
// ========== Graphic Utilities ==========
/**
* @brief Sets the alpha component of an image.
* @param dst_desc[in] A pointer to a structure describing the destination image format.
* @param AlphaValue[in] A CKBYTE value containing the alpha value to set to the whole image
* @remark If the destination image does not have alpha information the function returns immediatly.
*/
void VxDoAlphaBlit(const VxImageDescEx* dst_desc, CK2::CKBYTE AlphaValue);
/**
* @brief Sets the alpha component of an image.
* @param dst_desc[in] A pointer to a structure describing the destination image format.
* @param AlphaValues[in] A BYTE array containing the alpha values for each pixel. This array should be allocated to Width*Height bytes.
* @remark If the destination image does not have alpha information the function returns immediatly.
*/
void VxDoAlphaBlit(const VxImageDescEx* dst_desc, CK2::CKBYTE* AlphaValues);
}

View File

@ -1,10 +1,12 @@
#pragma once
#include "../VTUtils.hpp"
#include "../CK2/CKTypes.hpp"
#include "VxEnums.hpp"
#include <string>
#include <vector>
#include <cstring>
#include <cinttypes>
#include "../CK2/CKTypes.hpp"
/**
* @brief The VxMath part of LibCmo.
@ -73,36 +75,52 @@ namespace LibCmo::VxMath {
* Colormap, Image pointer and is ready for future enhancements.
*/
struct VxImageDescEx {
CK2::CKINT Size; ///< Size of the structure
CK2::CKDWORD Flags; ///< Reserved for special formats (such as compressed ) 0 otherwise
VX_PIXELFORMAT Flags; /**< Reserved for special formats (such as compressed ) 0 otherwise */
CK2::CKINT Width; ///< Width in pixel of the image
CK2::CKINT Height; ///< Height in pixel of the image
CK2::CKDWORD Width; /**< Width in pixel of the image */
CK2::CKDWORD Height; /**< Height in pixel of the image */
union {
CK2::CKINT BytesPerLine; ///< Pitch (width in bytes) of the image
CK2::CKINT TotalImageSize; ///< For compressed image (DXT1...) the total size of the image
CK2::CKDWORD BytesPerLine; /**< Pitch (width in bytes) of the image */
CK2::CKDWORD TotalImageSize; /**< For compressed image (DXT1...) the total size of the image */
};
CK2::CKINT BitsPerPixel; ///< Number of bits per pixel
CK2::CKINT BitsPerPixel; /**< Number of bits per pixel */
union {
CK2::CKDWORD RedMask; ///< Mask for Red component
CK2::CKDWORD BumpDuMask; ///< Mask for Bump Du component
CK2::CKDWORD RedMask; /**< Mask for Red component */
CK2::CKDWORD BumpDuMask; /**< Mask for Bump Du component */
};
union {
CK2::CKDWORD GreenMask; ///< Mask for Green component
CK2::CKDWORD BumpDvMask; ///< Mask for Bump Dv component
CK2::CKDWORD GreenMask; /**< Mask for Green component */
CK2::CKDWORD BumpDvMask; /**< Mask for Bump Dv component */
};
union {
CK2::CKDWORD BlueMask; ///< Mask for Blue component
CK2::CKDWORD BumpLumMask; ///< Mask for Luminance component
CK2::CKDWORD BlueMask; /**< Mask for Blue component */
CK2::CKDWORD BumpLumMask; /**< Mask for Luminance component */
};
CK2::CKDWORD AlphaMask; ///< Mask for Alpha component
CK2::CKDWORD AlphaMask; /**< Mask for Alpha component */
CK2::CKWORD BytesPerColorEntry; ///< ColorMap Stride
CK2::CKWORD ColorMapEntries; ///< If other than 0 image is palletized
CK2::CKWORD BytesPerColorEntry; /**< ColorMap Stride */
CK2::CKWORD ColorMapEntries; /**< If other than 0 image is palletized */
CK2::CKBYTE* ColorMap; /**< Palette colors */
CK2::CKBYTE* Image; /**< Image */
bool HasAlpha() {
return (AlphaMask == 0 || Flags >= VX_PIXELFORMAT::_DXT1);
}
bool operator==(const VxImageDescEx& rhs) const {
return (
Height == rhs.Height && Width == rhs.Width &&
BitsPerPixel == rhs.BitsPerPixel && BytesPerLine == rhs.BytesPerLine &&
RedMask == rhs.RedMask && GreenMask == rhs.GreenMask && BlueMask == rhs.BlueMask && AlphaMask == rhs.AlphaMask &&
BytesPerColorEntry == rhs.BytesPerColorEntry && ColorMapEntries == rhs.ColorMapEntries
);
}
bool operator!=(const VxImageDescEx& rhs) const {
return !((*this) == rhs);
}
CK2::CKBYTE* ColorMap; ///< Palette colors
CK2::CKBYTE* Image; ///< Image
};
}