Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
feat(PxWorld,PxMesh): implement various APIs
Browse files Browse the repository at this point in the history
Co-authored-by: JaXt0r <[email protected]>
  • Loading branch information
JucanAndreiDaniel and JaXt0r authored Oct 20, 2023
1 parent 339ed58 commit 369bf95
Show file tree
Hide file tree
Showing 4 changed files with 838 additions and 3 deletions.
17 changes: 16 additions & 1 deletion include/phoenix/cffi/Mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Api.h"
#include "Buffer.h"
#include "Material.h"
#include "Texture.h"
#include "Vfs.h"

#include <stdint.h>
Expand All @@ -15,7 +16,6 @@ typedef phoenix::mesh PxMesh;
typedef struct PxInternal_Mesh PxMesh;
#endif

// TODO: Lightmaps
PXC_API PxMesh* pxMshLoad(PxBuffer* buffer);
PXC_API PxMesh* pxMshLoadFromVfs(PxVfs const* vfs, char const* name);
PXC_API void pxMshDestroy(PxMesh* msh);
Expand All @@ -28,6 +28,21 @@ PXC_API uint32_t pxMshGetVertexCount(PxMesh const* msh);
PXC_API PxVec3 pxMshGetVertex(PxMesh const* msh, uint32_t i);
PXC_API uint32_t pxMshGetFeatureCount(PxMesh const* msh);
PXC_API void pxMshGetFeature(PxMesh const* msh, uint32_t i, PxVec2* texture, uint32_t* light, PxVec3* normal);
PXC_API uint32_t pxMshGetLightMapCount(PxMesh const* msh);
// TODO: Lightmaps add normals vector
PXC_API void pxMshGetLightMap(PxMesh const* msh, uint32_t i, PxTexture const** image, PxVec3* origin);
PXC_API uint32_t const* pxMshGetPolygonMaterialIndices(PxMesh const* msh, uint32_t* length);
PXC_API uint32_t const* pxMshGetPolygonFeatureIndices(PxMesh const* msh, uint32_t* length);
PXC_API uint32_t const* pxMshGetPolygonVertexIndices(PxMesh const* msh, uint32_t* length);
PXC_API int32_t const* pxMshGetPolygonLightMapIndices(PxMesh const* msh, uint32_t* length);
PXC_API uint32_t pxMshGetPolygonFlagCount(PxMesh const* msh, uint32_t i);
PXC_API uint8_t pxMshGetPolygonFlagGetIsPortal(PxMesh const* msh, uint32_t i);
PXC_API uint8_t pxMshGetPolygonFlagGetIsOccluder(PxMesh const* msh, uint32_t i);
PXC_API uint8_t pxMshGetPolygonFlagGetIsSector(PxMesh const* msh, uint32_t i);
PXC_API uint8_t pxMshGetPolygonFlagGetShouldRelight(PxMesh const* msh, uint32_t i);
PXC_API uint8_t pxMshGetPolygonFlagGetIsOutdoor(PxMesh const* msh, uint32_t i);
PXC_API uint8_t pxMshGetPolygonFlagGetIsGhostGccluder(PxMesh const* msh, uint32_t i);
PXC_API uint8_t pxMshGetPolygonFlagGetIsDynamicallyLit(PxMesh const* msh, uint32_t i);
PXC_API int16_t pxMshGetPolygonFlagGetSector_Index(PxMesh const* msh, uint32_t i);
PXC_API uint8_t pxMshGetPolygonFlagGetIsLod(PxMesh const* msh, uint32_t i);
PXC_API uint8_t pxMshGetPolygonFlagGetNormalAxis(PxMesh const* msh, uint32_t i);
172 changes: 170 additions & 2 deletions include/phoenix/cffi/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ typedef enum {
PxVob_unknown = 45,
} PxVobType;

typedef enum {
PxVobLightModePoint = 0,
PxVobLightModeSpot = 1,
PxVobLightModeReserved0 = 2,
PxVobLightModeReserved1 = 3,
} PxVobLightMode;

typedef enum {
PxVobLightQualityHigh = 0,
PxVobLightQualityMedium = 1,
PxVobLightQualityLow = 2,
} PxVobLightQuality;

typedef enum {
PxVobShadowNone = 0,
PxVobShadowBlob = 1,
Expand Down Expand Up @@ -291,11 +304,166 @@ PXC_API PxBool pxVobGetDecalIgnoreDaylight(PxVob const* vob);

// TODO Vob - Camera

// Light Preset
PXC_API char const* pxLightPresetGetPreset(PxVobLightPreset const* lightPreset);
PXC_API PxVobLightMode pxLightPresetGetLightType(PxVobLightPreset const* lightPreset);
PXC_API float pxLightPresetGetRange(PxVobLightPreset const* lightPreset);
PXC_API PxColor pxLightPresetGetColor(PxVobLightPreset const* lightPreset);
PXC_API float pxLightPresetGetConeAngle(PxVobLightPreset const* lightPreset);
PXC_API PxBool pxLightPresetGetIsStatic(PxVobLightPreset const* lightPreset);
PXC_API PxVobLightQuality pxLightPresetGetQuality(PxVobLightPreset const* lightPreset);
PXC_API char const* pxLightPresetGetLensFlareFx(PxVobLight const* light);
PXC_API PxBool pxLightPresetGetOn(PxVobLightPreset const* lightPreset);
PXC_API uint32_t pxLightPresetGetRangeAnimationScaleCount(PxVobLightPreset const* lightPreset);
PXC_API float pxLightPresetGetRangeAnimationScale(PxVobLightPreset const* lightPreset, uint32_t i);
PXC_API float pxLightPresetGetRangeAnimationFps(PxVobLightPreset const* lightPreset);
PXC_API PxBool pxLightPresetGetRangeAnimationSmooth(PxVobLightPreset const* lightPreset);
PXC_API uint32_t pxLightPresetGetColorAnimationListCount(PxVobLightPreset const* lightPreset);
PXC_API PxColor pxLightPresetGetColorAnimationList(PxVobLightPreset const* lightPreset, uint32_t i);
PXC_API float pxLightPresetGetColorAnimationFps(PxVobLightPreset const* lightPreset);
PXC_API PxBool pxLightPresetGetColorAnimationSmooth(PxVobLightPreset const* lightPreset);
PXC_API PxBool pxLightPresetGetCanMove(PxVobLightPreset const* lightPreset);

// Vob - Light
PXC_API char const* pxVobLightGetPreset(PxVobLight const* light);
PXC_API PxVobLightMode pxVobLightGetLightType(PxVobLight const* light);
PXC_API float pxVobLightGetRange(PxVobLight const* light);
PXC_API PxColor pxVobLightGetColor(PxVobLight const* light);
PXC_API float pxVobLightGetConeAngle(PxVobLight const* light);
PXC_API PxBool pxVobLightGetIsStatic(PxVobLight const* light);
PXC_API PxVobLightQuality pxVobLightGetQuality(PxVobLight const* light);
PXC_API char const* pxVobLightGetLensFlareFx(PxVobLight const* light);
PXC_API PxBool pxVobLightGetOn(PxVobLight const* light);
PXC_API uint32_t pxVobLightGetRangeAnimationScaleCount(PxVobLight const* light);
PXC_API float pxVobLightGetRangeAnimationScale(PxVobLight const* light, uint32_t i);
PXC_API float pxVobLightGetRangeAnimationFps(PxVobLight const* light);
PXC_API PxBool pxVobLightGetRangeAnimationSmooth(PxVobLight const* light);
PXC_API uint32_t pxVobLightGetColorAnimationListCount(PxVobLight const* light);
PXC_API PxColor pxVobLightGetColorAnimationList(PxVobLight const* light, uint32_t i);
PXC_API float pxVobLightGetColorAnimationFps(PxVobLight const* light);
PXC_API PxBool pxVobLightGetColorAnimationSmooth(PxVobLight const* light);
PXC_API PxBool pxVobLightGetCanMove(PxVobLight const* light);

// Vob - Animate
PXC_API PxBool pxVobAnimateGetStartOn(PxVobAnimate const* animate);

// Vob - Item
PXC_API char const* pxVobItemGetInstance(PxVobItem const* item);

// TODO Vob properties - Light
// TODO Vob properties - Misc
// Vob - Lens Flare
PXC_API char const* pxVobLensFlareGetFx(PxVobLensFlare const* lensFlare);

// Vob - Pfx Controller
PXC_API char const* pxVobPfxControllerGetPfxName(PxVobPfxController const* pfxController);
PXC_API PxBool pxVobPfxControllerGetKillWhenDone(PxVobPfxController const* pfxController);
PXC_API PxBool pxVobPfxControllerGetInitiallyRunning(PxVobPfxController const* pfxController);

// Vob - Message Filter
PXC_API char const* pxVobMessageFilterGetTarget(PxVobMessageFilter const* messageFilter);
PXC_API uint32_t pxVobMessageFilterGetOnTrigger(PxVobMessageFilter const* messageFilter);
PXC_API uint32_t pxVobMessageFilterGetOnUntrigger(PxVobMessageFilter const* messageFilter);

// Vob - Code Master
PXC_API char const* pxVobCodeMasterGetTarget(PxVobCodeMaster const* codeMaster);
PXC_API PxBool pxVobCodeMasterGetOrdered(PxVobCodeMaster const* codeMaster);
PXC_API PxBool pxVobCodeMasterGetFirstFalseIsFailure(PxVobCodeMaster const* codeMaster);
PXC_API char const* pxVobCodeMasterGetFailureTarget(PxVobCodeMaster const* codeMaster);
PXC_API PxBool pxVobCodeMasterGetUntriggeredCancels(PxVobCodeMaster const* codeMaster);
PXC_API uint32_t pxVobCodeMasterGetSlavesCount(PxVobCodeMaster const* codeMaster);
PXC_API char const* pxVobCodeMasterGetSlaves(PxVobCodeMaster const* codeMaster, uint32_t i);

// Vob - Mover Controller
PXC_API char const* pxVobMoverControllerGetTarget(PxVobMoverController const* moverController);
PXC_API uint32_t pxVobMoverControllerGetMessage(PxVobMoverController const* moverController);
PXC_API int32_t pxVobMoverControllerGetKey(PxVobMoverController const* moverController);

// Vob - Touch Damage
PXC_API float pxVobTouchDamageGetDamage(PxVobTouchDamage const* touchDamage);
PXC_API PxBool pxVobTouchDamageGetBarrier(PxVobTouchDamage const* touchDamage);
PXC_API PxBool pxVobTouchDamageGetBlunt(PxVobTouchDamage const* touchDamage);
PXC_API PxBool pxVobTouchDamageGetEdge(PxVobTouchDamage const* touchDamage);
PXC_API PxBool pxVobTouchDamageGetFire(PxVobTouchDamage const* touchDamage);
PXC_API PxBool pxVobTouchDamageGetFly(PxVobTouchDamage const* touchDamage);
PXC_API PxBool pxVobTouchDamageGetMagic(PxVobTouchDamage const* touchDamage);
PXC_API PxBool pxVobTouchDamageGetPoint(PxVobTouchDamage const* touchDamage);
PXC_API PxBool pxVobTouchDamageGetFall(PxVobTouchDamage const* touchDamage);
PXC_API float pxVobTouchDamageGetRepearDelaySec(PxVobTouchDamage const* touchDamage);
PXC_API float pxVobTouchDamageGetVolumeScale(PxVobTouchDamage const* touchDamage);
PXC_API uint32_t pxVobTouchDamageGetCollision(PxVobTouchDamage const* touchDamage);

// Vob - Earthquake
PXC_API float pxVobEarthquakeGetRadius(PxVobEarthquake const* earthquake);
PXC_API float pxVobEarthquakeGetDuration(PxVobEarthquake const* earthquake);
PXC_API PxVec3 pxVobEarthquakeGetAmplitude(PxVobEarthquake const* earthquake);

// Vob - Npc
PXC_API char const* pxVobNpcGetNpcInstance(PxVobNpc const* npc);
PXC_API PxVec3 pxVobNpcGetModelScale(PxVobNpc const* npc);
PXC_API float pxVobNpcGetModelFatness(PxVobNpc const* npc);
PXC_API uint32_t pxVobNpcGetOverlaysCount(PxVobNpc const* npc);
PXC_API char const* pxVobNpcGetOverlays(PxVobNpc const* npc, uint32_t i);
PXC_API int pxVobNpcGetFlags(PxVobNpc const* npc);
PXC_API int pxVobNpcGetGuild(PxVobNpc const* npc);
PXC_API int pxVobNpcGetGuildTrue(PxVobNpc const* npc);
PXC_API int pxVobNpcGetLevel(PxVobNpc const* npc);
PXC_API int pxVobNpcGetXp(PxVobNpc const* npc);
PXC_API int pxVobNpcGetXpNextLevel(PxVobNpc const* npc);
PXC_API int pxVobNpcGetLp(PxVobNpc const* npc);
PXC_API uint32_t pxVobNpcGetTalentsCount(PxVobNpc const* npc);
PXC_API void pxVobNpcGetTalents(PxVobNpc const* npc, uint32_t i, int* talent, int* value, int* skill);
PXC_API int pxVobNpcGetFightTactic(PxVobNpc const* npc);
PXC_API int pxVobNpcGetFightMode(PxVobNpc const* npc);
PXC_API PxBool pxVobNpcGetWounded(PxVobNpc const* npc);
PXC_API PxBool pxVobNpcGetMad(PxVobNpc const* npc);
PXC_API int pxVobNpcGetMadTime(PxVobNpc const* npc);
PXC_API PxBool pxVobNpcGetPlayer(PxVobNpc const* npc);
PXC_API uint32_t pxVobNpcGetAttributesCount(PxVobNpc const* npc);
PXC_API int pxVobNpcGetAttributes(PxVobNpc const* npc, uint32_t i);
PXC_API uint32_t pxVobNpcGetHcsCount(PxVobNpc const* npc);
PXC_API int pxVobNpcGetHcs(PxVobNpc const* npc, uint32_t i);
PXC_API uint32_t pxVobNpcGetMissionsCount(PxVobNpc const* npc);
PXC_API int pxVobNpcGetMissions(PxVobNpc const* npc, uint32_t i);
PXC_API char const* pxVobNpcGetStartAiState(PxVobNpc const* npc);
PXC_API uint32_t pxVobNpcGetAivarCount(PxVobNpc const* npc);
PXC_API int pxVobNpcGetAivar(PxVobNpc const* npc, uint32_t i);
PXC_API char const* pxVobNpcGetScriptWaypoint(PxVobNpc const* npc);
PXC_API int pxVobNpcGetAttitude(PxVobNpc const* npc);
PXC_API int pxVobNpcGetAttitudeTemp(PxVobNpc const* npc);
PXC_API int pxVobNpcGetNameNr(PxVobNpc const* npc);
PXC_API PxBool pxVobNpcGetMoveLock(PxVobNpc const* npc);
PXC_API uint32_t pxVobNpcGetPackedCount(PxVobNpc const* npc);
PXC_API char const* pxVobNpcGetPacked(PxVobNpc const* npc, uint32_t i);
PXC_API uint32_t pxVobNpcGetItemsCount(PxVobNpc const* npc);
PXC_API PxVobItem const* pxVobNpcGetItems(PxVobNpc const* npc, uint32_t i);
PXC_API uint32_t pxVobNpcGetSlotsCount(PxVobNpc const* npc);
PXC_API void
pxVobNpcGetSlots(PxVobNpc const* npc, uint32_t i, PxBool* used, char const** name, int* itemIndex, PxBool* inInventory);
PXC_API PxBool pxVobNpcGetCurrentStateValid(PxVobNpc const* npc);
PXC_API char const* pxVobNpcGetCurrentStateName(PxVobNpc const* npc);
PXC_API int pxVobNpcGetCurrentStateIndex(PxVobNpc const* npc);
PXC_API PxBool pxVobNpcGetCurrentStateIsRoutine(PxVobNpc const* npc);
PXC_API PxBool pxVobNpcGetNextStateValid(PxVobNpc const* npc);
PXC_API char const* pxVobNpcGetNextStateName(PxVobNpc const* npc);
PXC_API int pxVobNpcGetNextStateIndex(PxVobNpc const* npc);
PXC_API PxBool pxVobNpcGetNextStateIsRoutine(PxVobNpc const* npc);
PXC_API int pxVobNpcGetLastAiState(PxVobNpc const* npc);
PXC_API PxBool pxVobNpcGetHasRoutine(PxVobNpc const* npc);
PXC_API PxBool pxVobNpcGetRoutineChanged(PxVobNpc const* npc);
PXC_API PxBool pxVobNpcGetRoutineOverlay(PxVobNpc const* npc);
PXC_API int pxVobNpcGetRoutineOverlayCount(PxVobNpc const* npc);
PXC_API int pxVobNpcGetWalkmodeRoutine(PxVobNpc const* npc);
PXC_API PxBool pxVobNpcGetWeaponmodeRoutine(PxVobNpc const* npc);
PXC_API PxBool pxVobNpcGetStartNewRoutine(PxVobNpc const* npc);
PXC_API int pxVobNpcGetAiStateDriven(PxVobNpc const* npc);
PXC_API PxVec3 pxVobNpcGetAiStatePos(PxVobNpc const* npc);
PXC_API char const* pxVobNpcGetCurrentRoutine(PxVobNpc const* npc);
PXC_API PxBool pxVobNpcGetRespawn(PxVobNpc const* npc);
PXC_API int pxVobNpcGetRespawnTime(PxVobNpc const* npc);
PXC_API uint32_t pxVobNpcGetProtectionCount(PxVobNpc const* npc);
PXC_API int pxVobNpcGetProtection(PxVobNpc const* npc, uint32_t i);
PXC_API int pxVobNpcGetBsInterruptableOverride(PxVobNpc const* npc);
PXC_API int pxVobNpcGetNpcType(PxVobNpc const* npc);
PXC_API int pxVobNpcGetSpellMana(PxVobNpc const* npc);

// Vob - Mob
PXC_API char const* pxVobMobGetName(PxVobMob const* mob);
Expand Down
65 changes: 65 additions & 0 deletions src/Mesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ void pxMshGetFeature(PxMesh const* msh, uint32_t i, PxVec2* texture, uint32_t* l
normal->y = ft.normal.y;
normal->z = ft.normal.z;
}
uint32_t pxMshGetLightMapCount(PxMesh const* msh) {
return (uint32_t) msh->lightmaps.size();
}
void pxMshGetLightMap(PxMesh const* msh, uint32_t i, PxTexture const** image, PxVec3* origin) {
auto& lm = msh->lightmaps[i];

// PxVec3 normal[] = {
// {lm.normals[0].x, lm.normals[0].y, lm.normals[0].z},
// {lm.normals[1].x, lm.normals[1].y, lm.normals[1].z},
// };

*image = lm.image.get();
// *normals = normal;
*origin = PxVec3 {lm.origin.x, lm.origin.y, lm.origin.z};
}

uint32_t const* pxMshGetPolygonMaterialIndices(PxMesh const* msh, uint32_t* length) {
auto& polys = msh->polygons;
Expand All @@ -94,3 +109,53 @@ uint32_t const* pxMshGetPolygonVertexIndices(PxMesh const* msh, uint32_t* length
*length = (uint32_t) polys.vertex_indices.size();
return polys.vertex_indices.data();
}

int32_t const* pxMshGetPolygonLightMapIndices(PxMesh const* msh, uint32_t* length) {
auto& polys = msh->polygons;
*length = (uint32_t) polys.lightmap_indices.size();
return polys.lightmap_indices.data();
}

uint32_t pxMshGetPolygonFlagCount(PxMesh const* msh) {
return (uint32_t) msh->polygons.flags.size();
}

uint8_t pxMshGetPolygonFlagGetIsPortal(PxMesh const* msh, uint32_t i) {
return msh->polygons.flags[i].is_portal;
}

uint8_t pxMshGetPolygonFlagGetIsOccluder(PxMesh const* msh, uint32_t i) {
return msh->polygons.flags[i].is_occluder;
}

uint8_t pxMshGetPolygonFlagGetIsSector(PxMesh const* msh, uint32_t i) {
return msh->polygons.flags[i].is_sector;
}

uint8_t pxMshGetPolygonFlagGetShouldRelight(PxMesh const* msh, uint32_t i) {
return msh->polygons.flags[i].should_relight;
}

uint8_t pxMshGetPolygonFlagGetIsOutdoor(PxMesh const* msh, uint32_t i) {
return msh->polygons.flags[i].is_outdoor;
}

uint8_t pxMshGetPolygonFlagGetIsGhostGccluder(PxMesh const* msh, uint32_t i) {
return msh->polygons.flags[i].is_ghost_occluder;
}

uint8_t pxMshGetPolygonFlagGetIsDynamicallyLit(PxMesh const* msh, uint32_t i) {
return msh->polygons.flags[i].is_dynamically_lit;
}

int16_t pxMshGetPolygonFlagGetSector_Index(PxMesh const* msh, uint32_t i) {
return msh->polygons.flags[i].sector_index;
}

uint8_t pxMshGetPolygonFlagGetIsLod(PxMesh const* msh, uint32_t i) {
return msh->polygons.flags[i].is_lod;
}

uint8_t pxMshGetPolygonFlagGetNormalAxis(PxMesh const* msh, uint32_t i) {
return msh->polygons.flags[i].normal_axis;
}
Loading

0 comments on commit 369bf95

Please sign in to comment.