Add t-posing chell

This commit is contained in:
James Lambert 2022-11-25 19:45:15 -07:00
parent 1c703b2e70
commit 6e5c516084
6 changed files with 64 additions and 5 deletions

View file

@ -206,6 +206,8 @@ build/src/scene/render_plan.o: $(MODEL_HEADERS)
build/src/scene/portal_render.o: $(MODEL_HEADERS)
build/src/player/player.o: build/assets/models/player/chell.h build/assets/materials/static.h
build/anims.ld: $(ANIM_LIST) tools/generate_animation_ld.js
@mkdir -p $(@D)
node tools/generate_animation_ld.js $@ $(ANIM_LIST)

View file

@ -14,6 +14,9 @@
#include "../util/time.h"
#include "../physics/contact_insertion.h"
#include "../build/assets/models/player/chell.h"
#include "../build/assets/materials/static.h"
#define GRAB_RAYCAST_DISTANCE 2.5f
#define PLAYER_COLLISION_LAYERS (COLLISION_LAYERS_TANGIBLE | COLLISION_LAYERS_FIZZLER)
@ -46,6 +49,48 @@ struct ColliderTypeData gPlayerColliderData = {
&gCollisionCylinderCallbacks,
};
void playerRender(void* data, struct DynamicRenderDataList* renderList, struct RenderState* renderState) {
struct Player* player = (struct Player*)data;
Mtx* matrix = renderStateRequestMatrices(renderState, 1);
if (!matrix) {
return;
}
struct Transform finalPlayerTransform;
struct Vector3 forwardVector;
struct Vector3 unusedRight;
playerGetMoveBasis(&player->lookTransform, &forwardVector, &unusedRight);
finalPlayerTransform.position = player->body.transform.position;
quatLook(&forwardVector, &gUp, &finalPlayerTransform.rotation);
finalPlayerTransform.scale = gOneVec;
finalPlayerTransform.position.y -= PLAYER_HEAD_HEIGHT;
transformToMatrixL(&finalPlayerTransform, matrix, SCENE_SCALE);
// Mtx* armature = renderStateRequestMatrices(renderState, PROPS_BOX_DROPPER_DEFAULT_BONES_COUNT);
// if (!armature) {
// return;
// }
// skCalculateTransforms(&player->armature, armature);
dynamicRenderListAddData(
renderList,
player_chell_model_gfx,
matrix,
DEFAULT_INDEX,
&player->body.transform.position,
NULL
);
}
void playerInit(struct Player* player, struct Location* startLocation, struct Vector3* velocity) {
collisionObjectInit(&player->collisionObject, &gPlayerColliderData, &player->body, 1.0f, PLAYER_COLLISION_LAYERS);
// rigidBodyMarkKinematic(&player->body);
@ -59,6 +104,9 @@ void playerInit(struct Player* player, struct Location* startLocation, struct Ve
player->yawVelocity = 0.0f;
player->flags = 0;
player->dynamicId = dynamicSceneAdd(player, playerRender, &player->body.transform, 1.5f);
dynamicSceneSetFlags(player->dynamicId, DYNAMIC_SCENE_OBJECT_SKIP_ROOT);
if (startLocation) {
player->lookTransform = startLocation->transform;
player->body.currentRoom = startLocation->roomIndex;
@ -69,6 +117,8 @@ void playerInit(struct Player* player, struct Location* startLocation, struct Ve
player->body.transform = player->lookTransform;
collisionObjectUpdateBB(&player->collisionObject);
dynamicSceneSetRoomFlags(player->dynamicId, ROOM_FLAG_FROM_INDEX(player->body.currentRoom));
}
#define PLAYER_SPEED (150.0f / 64.0f)
@ -389,4 +439,6 @@ void playerUpdate(struct Player* player, struct Transform* cameraTransform) {
collisionObjectUpdateBB(&player->collisionObject);
player->body.currentRoom = worldCheckDoorwayCrossings(&gCurrentLevel->world, &player->lookTransform.position, player->body.currentRoom, doorwayMask);
dynamicSceneSetRoomFlags(player->dynamicId, ROOM_FLAG_FROM_INDEX(player->body.currentRoom));
}

View file

@ -6,6 +6,7 @@
#include "../physics/rigid_body.h"
#include "../physics/collision_object.h"
#include "../levels/level_definition.h"
#include "../scene/dynamic_scene.h"
#define PLAYER_GRABBING_THROUGH_NOTHING -1
@ -20,6 +21,7 @@ struct Player {
struct RigidBody body;
struct Transform lookTransform;
short grabbingThroughPortal;
short dynamicId;
struct CollisionObject* grabbing;
float pitchVelocity;
float yawVelocity;
@ -29,8 +31,6 @@ struct Player {
void playerInit(struct Player* player, struct Location* startLocation, struct Vector3* velocity);
void playerUpdate(struct Player* player, struct Transform* cameraTransform);
void playerRender(struct Player* player, struct RenderState* renderState);
void playerGetMoveBasis(struct Transform* transform, struct Vector3* forward, struct Vector3* right);
#endif

View file

@ -61,6 +61,10 @@ void dynamicRenderListPopulate(struct DynamicRenderDataList* list, struct Render
continue;
}
if (stages[stageIndex].currentDepth == STARTING_RENDER_DEPTH && (object->flags & DYNAMIC_SCENE_OBJECT_SKIP_ROOT)) {
continue;
}
if (isSphereOutsideFrustrum(&stages[stageIndex].cameraMatrixInfo.cullingInformation, &scaledPos, object->scaledRadius)) {
continue;
}

View file

@ -14,6 +14,7 @@ typedef void (*DynamicRender)(void* data, struct DynamicRenderDataList* renderLi
#define DYNAMIC_SCENE_OBJECT_FLAGS_USED (1 << 0)
#define DYNAMIC_SCENE_OBJECT_FLAGS_ACTIVE (1 << 1)
#define DYNAMIC_SCENE_OBJECT_SKIP_ROOT (1 << 2)
#define INVALID_DYNAMIC_OBJECT -1

View file

@ -431,8 +431,8 @@ void renderPlanExecute(struct RenderPlan* renderPlan, struct Scene* scene, struc
dynamicRenderListPopulate(dynamicList, renderPlan->stageProps, renderPlan->stageCount, renderState);
for (int i = renderPlan->stageCount - 1; i >= 0; --i) {
struct RenderProps* current = &renderPlan->stageProps[i];
for (int stageIndex = renderPlan->stageCount - 1; stageIndex >= 0; --stageIndex) {
struct RenderProps* current = &renderPlan->stageProps[stageIndex];
if (!cameraApplyMatrices(renderState, &current->cameraMatrixInfo)) {
return;
@ -492,7 +492,7 @@ void renderPlanExecute(struct RenderPlan* renderPlan, struct Scene* scene, struc
portalIndex = 1 - portalIndex;
}
staticRender(&current->camera.transform, &current->cameraMatrixInfo.cullingInformation, current->visiblerooms, dynamicList, i, renderState);
staticRender(&current->camera.transform, &current->cameraMatrixInfo.cullingInformation, current->visiblerooms, dynamicList, stageIndex, renderState);
}
dynamicRenderListFree(dynamicList);