feat: add 4 new added classes in Unvirt.

- fix a fatal issue that make the output message from CKContext is empty.
- fix argument type error for CKCamera::GetAspect and CKCamera::SetAspect.
- add enums annotation and struct diaplay function in Unvirt for showing 4 new added classes.
This commit is contained in:
yyc12345 2024-12-25 13:58:39 +08:00
parent eef3a352d9
commit 86b27557c9
6 changed files with 94 additions and 7 deletions

View File

@ -264,8 +264,7 @@ namespace LibCmo::CK2 {
va_list argptr;
va_start(argptr, fmt);
XContainer::XString result;
YYCC::StringHelper::VPrintf(fmt, argptr);
XContainer::XString result(YYCC::StringHelper::VPrintf(fmt, argptr));
va_end(argptr);
// use c_str(), not XContainer::NSXString::ToCKSTRING because we want make sure this paramter is not nullptr.

View File

@ -117,11 +117,11 @@ SetObjectFlags(obj_flags); \
REMOVE_UPTODATE_FLAG;
}
void CKCamera::GetAspectRatio(int& width, int& height) const {
void CKCamera::GetAspectRatio(CKDWORD& width, CKDWORD& height) const {
width = m_Width;
height = m_Height;
}
void CKCamera::SetAspectRatio(int width, int height) {
void CKCamera::SetAspectRatio(CKDWORD width, CKDWORD height) {
m_Width = width;
m_Height = height;
REMOVE_UPTODATE_FLAG;

View File

@ -33,8 +33,8 @@ namespace LibCmo::CK2::ObjImpls {
void SetBackPlane(CKFLOAT back);
void SetFov(CKFLOAT fov);
void GetAspectRatio(int& width, int& height) const;
void SetAspectRatio(int width, int height);
void GetAspectRatio(CKDWORD& width, CKDWORD& height) const;
void SetAspectRatio(CKDWORD width, CKDWORD height);
void ComputeProjectionMatrix(VxMath::VxMatrix& mat) const;

View File

@ -383,6 +383,10 @@ namespace Unvirt::AccessibleValue {
{ LibCmo::CK2::CK_BITMAPDATA_FLAGS::CKBITMAPDATA_FREEVIDEOMEMORY, { u8"CKBITMAPDATA_FREEVIDEOMEMORY" } },
{ LibCmo::CK2::CK_BITMAPDATA_FLAGS::CKBITMAPDATA_DYNAMIC, { u8"CKBITMAPDATA_DYNAMIC" } },
};
const GeneralReflectionArray<LibCmo::CK2::CK_CAMERA_PROJECTION> CK_CAMERA_PROJECTION {
{ LibCmo::CK2::CK_CAMERA_PROJECTION::CK_PERSPECTIVEPROJECTION, { u8"CK_PERSPECTIVEPROJECTION" } },
{ LibCmo::CK2::CK_CAMERA_PROJECTION::CK_ORTHOGRAPHICPROJECTION, { u8"CK_ORTHOGRAPHICPROJECTION" } },
};
const GeneralReflectionArray<LibCmo::VxMath::VX_PIXELFORMAT> VX_PIXELFORMAT {
{ LibCmo::VxMath::VX_PIXELFORMAT::UNKNOWN_PF, { u8"UNKNOWN_PF" } },
@ -418,6 +422,12 @@ namespace Unvirt::AccessibleValue {
{ LibCmo::VxMath::VX_PIXELFORMAT::_4_ABGR8888_CLUT, { u8"_4_ABGR8888_CLUT" } },
{ LibCmo::VxMath::VX_PIXELFORMAT::_4_ARGB8888_CLUT, { u8"_4_ARGB8888_CLUT" } },
};
const GeneralReflectionArray<LibCmo::VxMath::VXLIGHT_TYPE> VXLIGHT_TYPE {
{ LibCmo::VxMath::VXLIGHT_TYPE::VX_LIGHTPOINT, { u8"VX_LIGHTPOINT" } },
{ LibCmo::VxMath::VXLIGHT_TYPE::VX_LIGHTSPOT, { u8"VX_LIGHTSPOT" } },
{ LibCmo::VxMath::VXLIGHT_TYPE::VX_LIGHTDIREC, { u8"VX_LIGHTDIREC" } },
{ LibCmo::VxMath::VXLIGHT_TYPE::VX_LIGHTPARA, { u8"VX_LIGHTPARA" } },
};
const GeneralReflectionArray<LibCmo::VxMath::VXTEXTURE_BLENDMODE> VXTEXTURE_BLENDMODE {
{ LibCmo::VxMath::VXTEXTURE_BLENDMODE::VXTEXTUREBLEND_DECAL, { u8"VXTEXTUREBLEND_DECAL" } },
{ LibCmo::VxMath::VXTEXTURE_BLENDMODE::VXTEXTUREBLEND_MODULATE, { u8"VXTEXTUREBLEND_MODULATE" } },

View File

@ -102,8 +102,10 @@ namespace Unvirt {
extern const GeneralReflectionArray<LibCmo::CK2::CK_3DENTITY_FLAGS> CK_3DENTITY_FLAGS;
extern const GeneralReflectionArray<LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS> CK_TEXTURE_SAVEOPTIONS;
extern const GeneralReflectionArray<LibCmo::CK2::CK_BITMAPDATA_FLAGS> CK_BITMAPDATA_FLAGS;
extern const GeneralReflectionArray<LibCmo::CK2::CK_CAMERA_PROJECTION> CK_CAMERA_PROJECTION;
extern const GeneralReflectionArray<LibCmo::VxMath::VX_PIXELFORMAT> VX_PIXELFORMAT;
extern const GeneralReflectionArray<LibCmo::VxMath::VXLIGHT_TYPE> VXLIGHT_TYPE;
extern const GeneralReflectionArray<LibCmo::VxMath::VXTEXTURE_BLENDMODE> VXTEXTURE_BLENDMODE;
extern const GeneralReflectionArray<LibCmo::VxMath::VXTEXTURE_FILTERMODE> VXTEXTURE_FILTERMODE;
extern const GeneralReflectionArray<LibCmo::VxMath::VXBLEND_MODE> VXBLEND_MODE;

View File

@ -165,7 +165,7 @@ namespace Unvirt::StructFormatter {
// print current mesh
{
auto curmesh = obj->GetCurrentMesh();
Console::Format(u8"->\t%s\t%s",
Console::FormatLine(u8"->\t%s\t%s",
PrintPointer(curmesh).c_str(),
(curmesh != nullptr ? PrintCKSTRING(curmesh->GetName()).c_str() : u8"")
);
@ -181,6 +181,70 @@ namespace Unvirt::StructFormatter {
}
}
static void PrintCKLightDetail(LibCmo::CK2::ObjImpls::CKLight* obj) {
PrintCK3dEntityDetail(obj);
Console::WriteLine(YYCC_COLOR_LIGHT_YELLOW(u8"CKLight"));
Console::WriteLine(u8"== Basics ==");
Console::FormatLine(u8"Type: %s", AccessibleValue::GetEnumName(obj->GetType(), AccessibleValue::EnumDesc::VXLIGHT_TYPE).c_str());
Console::FormatLine(u8"Color: %s", PrintColor(obj->GetColor()).c_str());
Console::FormatLine(u8"Light Power: %.2" PRIfCKFLOAT, obj->GetLightPower());
Console::WriteLine(u8"== Switches ==");
Console::FormatLine(u8"Activity: %s", PrintBool(obj->GetActivity()).c_str());
Console::FormatLine(u8"Specular Flag: %s", PrintBool(obj->GetSpecularFlag()).c_str());
Console::WriteLine(u8"== Attenuation ==");
Console::FormatLine(u8"Constant Attenuation: %.2" PRIfCKFLOAT, obj->GetConstantAttenuation());
Console::FormatLine(u8"Linear Attenuation: %.2" PRIfCKFLOAT, obj->GetLinearAttenuation());
Console::FormatLine(u8"Quadratic Attenuation: %.2" PRIfCKFLOAT, obj->GetQuadraticAttenuation());
Console::WriteLine(u8"== Spot Cone ==");
Console::FormatLine(u8"Range: %.2" PRIfCKFLOAT, obj->GetRange());
Console::FormatLine(u8"Hot Spot: %.2" PRIfCKFLOAT, obj->GetHotSpot());
Console::FormatLine(u8"Falloff: %.2" PRIfCKFLOAT, obj->GetFalloff());
Console::FormatLine(u8"Falloff Shape: %.2" PRIfCKFLOAT, obj->GetFalloffShape());
Console::WriteLine(u8"== Target ==");
auto thistarget = obj->GetTarget();
Console::FormatLine(u8"Target Address: %s", PrintPointer(thistarget).c_str());
if (thistarget != nullptr)
Console::FormatLine(u8"Target Name: %s", PrintCKSTRING(thistarget->GetName()).c_str());
}
static void PrintCKTargetLightDetail(LibCmo::CK2::ObjImpls::CKTargetLight* obj) {
PrintCKLightDetail(obj);
Console::WriteLine(YYCC_COLOR_LIGHT_YELLOW(u8"CKTargetLight"));
Console::WriteLine(YYCC_COLOR_LIGHT_RED(u8"No Data"));
}
static void PrintCKCameraDetail(LibCmo::CK2::ObjImpls::CKCamera* obj) {
PrintCK3dEntityDetail(obj);
Console::WriteLine(YYCC_COLOR_LIGHT_YELLOW(u8"CKCamera"));
Console::WriteLine(u8"== Basics ==");
Console::FormatLine(u8"Projection Type: %s", AccessibleValue::GetEnumName(obj->GetProjectionType(), AccessibleValue::EnumDesc::CK_CAMERA_PROJECTION).c_str());
Console::FormatLine(u8"Orthographic Zoom: %.2" PRIfCKFLOAT, obj->GetOrthographicZoom());
Console::FormatLine(u8"Front Plane: %.2" PRIfCKFLOAT, obj->GetFrontPlane());
Console::FormatLine(u8"Back Plane: %.2" PRIfCKFLOAT, obj->GetBackPlane());
Console::FormatLine(u8"Fov: %.2" PRIfCKFLOAT, obj->GetFov());
LibCmo::CKDWORD width, height;
obj->GetAspectRatio(width, height);
Console::FormatLine(u8"Aspect Ratio: %" PRIuCKDWORD " : %" PRIuCKDWORD, width, height);
Console::WriteLine(u8"== Target ==");
auto thistarget = obj->GetTarget();
Console::FormatLine(u8"Target Address: %s", PrintPointer(thistarget).c_str());
if (thistarget != nullptr)
Console::FormatLine(u8"Target Name: %s", PrintCKSTRING(thistarget->GetName()).c_str());
}
static void PrintCKTargetCameraDetail(LibCmo::CK2::ObjImpls::CKTargetCamera* obj) {
PrintCKCameraDetail(obj);
Console::WriteLine(YYCC_COLOR_LIGHT_YELLOW(u8"CKTargetCamera"));
Console::WriteLine(YYCC_COLOR_LIGHT_RED(u8"No Data"));
}
static void PrintCK3dObjectDetail(LibCmo::CK2::ObjImpls::CK3dObject* obj) {
PrintCK3dEntityDetail(obj);
@ -560,6 +624,18 @@ namespace Unvirt::StructFormatter {
case LibCmo::CK2::CK_CLASSID::CKCID_3DENTITY:
PrintCK3dEntityDetail(static_cast<LibCmo::CK2::ObjImpls::CK3dEntity*>(mobj));
break;
case LibCmo::CK2::CK_CLASSID::CKCID_LIGHT:
PrintCKLightDetail(static_cast<LibCmo::CK2::ObjImpls::CKLight*>(mobj));
break;
case LibCmo::CK2::CK_CLASSID::CKCID_TARGETLIGHT:
PrintCKTargetLightDetail(static_cast<LibCmo::CK2::ObjImpls::CKTargetLight*>(mobj));
break;
case LibCmo::CK2::CK_CLASSID::CKCID_CAMERA:
PrintCKCameraDetail(static_cast<LibCmo::CK2::ObjImpls::CKCamera*>(mobj));
break;
case LibCmo::CK2::CK_CLASSID::CKCID_TARGETCAMERA:
PrintCKTargetCameraDetail(static_cast<LibCmo::CK2::ObjImpls::CKTargetCamera*>(mobj));
break;
case LibCmo::CK2::CK_CLASSID::CKCID_3DOBJECT:
PrintCK3dObjectDetail(static_cast<LibCmo::CK2::ObjImpls::CK3dObject*>(mobj));
break;