Start debug draw
This commit is contained in:
parent
56904cabab
commit
1c6666b377
3 changed files with 119 additions and 22 deletions
53
renderer.h
53
renderer.h
|
@ -36,6 +36,8 @@ struct
|
|||
S3L_Scene scene;
|
||||
S3L_Model3D mapModel; ///< whole map model
|
||||
S3L_Model3D *carModel;
|
||||
|
||||
// TODO: ghostModel
|
||||
|
||||
/**
|
||||
The scene model array.
|
||||
|
@ -67,7 +69,7 @@ struct
|
|||
uint8_t gridOfLODs[LCR_RENDERER_LOD_BLOCKS];
|
||||
|
||||
// pixel function precomputed values:
|
||||
int previousTriID;
|
||||
uint32_t previousTriID;
|
||||
int triUVs[6];
|
||||
uint8_t texSubsampleCount;
|
||||
|
||||
|
@ -793,8 +795,29 @@ LCR_renderer.carModel->transform.scale.z =
|
|||
return 1;
|
||||
}
|
||||
|
||||
void LCR_rendererMoveCamera(LCR_SpaceUnit forwRightUpOffset[3],
|
||||
LCR_SpaceUnit yawPitchOffset[2])
|
||||
void LCR_rendererGetCameraTransform(LCR_GameUnit position[3],
|
||||
LCR_GameUnit rotation[3], LCR_GameUnit *fov)
|
||||
{
|
||||
position[0] = (LCR_renderer.scene.camera.transform.translation.x *
|
||||
LCR_GAME_UNIT) / LCR_RENDERER_UNIT;
|
||||
position[1] = (LCR_renderer.scene.camera.transform.translation.y *
|
||||
LCR_GAME_UNIT) / LCR_RENDERER_UNIT;
|
||||
position[2] = (LCR_renderer.scene.camera.transform.translation.z *
|
||||
LCR_GAME_UNIT) / LCR_RENDERER_UNIT;
|
||||
|
||||
rotation[0] = (LCR_renderer.scene.camera.transform.rotation.x *
|
||||
LCR_GAME_UNIT) / S3L_FRACTIONS_PER_UNIT;
|
||||
rotation[1] = (LCR_renderer.scene.camera.transform.rotation.y *
|
||||
LCR_GAME_UNIT) / S3L_FRACTIONS_PER_UNIT;
|
||||
rotation[2] = (LCR_renderer.scene.camera.transform.rotation.z *
|
||||
LCR_GAME_UNIT) / S3L_FRACTIONS_PER_UNIT;
|
||||
|
||||
*fov = (LCR_renderer.scene.camera.focalLength * LCR_GAME_UNIT)
|
||||
/ S3L_FRACTIONS_PER_UNIT;
|
||||
}
|
||||
|
||||
void LCR_rendererMoveCamera(LCR_GameUnit forwRightUpOffset[3],
|
||||
LCR_GameUnit yawPitchOffset[2])
|
||||
{
|
||||
S3L_Vec4 f, r, u;
|
||||
|
||||
|
@ -803,27 +826,25 @@ void LCR_rendererMoveCamera(LCR_SpaceUnit forwRightUpOffset[3],
|
|||
|
||||
LCR_renderer.scene.camera.transform.translation.x +=
|
||||
((f.x * forwRightUpOffset[0] + r.x * forwRightUpOffset[1] +
|
||||
u.x * forwRightUpOffset[2]) * S3L_FRACTIONS_PER_UNIT) / LCR_SQUARE_SIDE_LEN;
|
||||
u.x * forwRightUpOffset[2]) * S3L_FRACTIONS_PER_UNIT) / LCR_GAME_UNIT;
|
||||
|
||||
LCR_renderer.scene.camera.transform.translation.y +=
|
||||
((f.y * forwRightUpOffset[0] + r.y * forwRightUpOffset[1] +
|
||||
u.y * forwRightUpOffset[2]) * S3L_FRACTIONS_PER_UNIT) / LCR_SQUARE_SIDE_LEN;
|
||||
u.y * forwRightUpOffset[2]) * S3L_FRACTIONS_PER_UNIT) / LCR_GAME_UNIT;
|
||||
|
||||
LCR_renderer.scene.camera.transform.translation.z +=
|
||||
((f.z * forwRightUpOffset[0] + r.z * forwRightUpOffset[1] +
|
||||
u.z * forwRightUpOffset[2]) * S3L_FRACTIONS_PER_UNIT) / LCR_SQUARE_SIDE_LEN;
|
||||
u.z * forwRightUpOffset[2]) * S3L_FRACTIONS_PER_UNIT) / LCR_GAME_UNIT;
|
||||
|
||||
LCR_renderer.scene.camera.transform.rotation.y +=
|
||||
(yawPitchOffset[0] * S3L_FRACTIONS_PER_UNIT) / LCR_SQUARE_SIDE_LEN;
|
||||
|
||||
LCR_renderer.scene.camera.transform.rotation.x +=
|
||||
(yawPitchOffset[1] * S3L_FRACTIONS_PER_UNIT) / LCR_SQUARE_SIDE_LEN;
|
||||
LCR_renderer.scene.camera.transform.rotation.y = S3L_wrap(
|
||||
LCR_renderer.scene.camera.transform.rotation.y +
|
||||
(yawPitchOffset[0] * S3L_FRACTIONS_PER_UNIT) / LCR_GAME_UNIT,
|
||||
S3L_FRACTIONS_PER_UNIT);
|
||||
|
||||
if (LCR_renderer.scene.camera.transform.rotation.x > S3L_FRACTIONS_PER_UNIT / 4)
|
||||
LCR_renderer.scene.camera.transform.rotation.x = S3L_FRACTIONS_PER_UNIT / 4;
|
||||
|
||||
if (LCR_renderer.scene.camera.transform.rotation.x < -1 * S3L_FRACTIONS_PER_UNIT / 4)
|
||||
LCR_renderer.scene.camera.transform.rotation.x = -1 * S3L_FRACTIONS_PER_UNIT / 4;
|
||||
LCR_renderer.scene.camera.transform.rotation.x = S3L_clamp(
|
||||
LCR_renderer.scene.camera.transform.rotation.x +
|
||||
(yawPitchOffset[1] * S3L_FRACTIONS_PER_UNIT) / LCR_GAME_UNIT,
|
||||
-1 * S3L_FRACTIONS_PER_UNIT / 4,S3L_FRACTIONS_PER_UNIT / 4);
|
||||
|
||||
#define chk(o,c,l) \
|
||||
if (LCR_renderer.scene.camera.transform.translation.c o l) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue