|
@@ -4,21 +4,53 @@
|
|
|
#define S3L_PERSPECTIVE_CORRECTION 2
|
|
#define S3L_PERSPECTIVE_CORRECTION 2
|
|
|
|
|
|
|
|
#include "helper.h"
|
|
#include "helper.h"
|
|
|
|
|
+#include "levelModel.h"
|
|
|
|
|
|
|
|
#define ROOM_SIZE 10000
|
|
#define ROOM_SIZE 10000
|
|
|
#define CUBE_SIZE 800
|
|
#define CUBE_SIZE 800
|
|
|
|
|
|
|
|
TPE_Unit elevatorHeight;
|
|
TPE_Unit elevatorHeight;
|
|
|
|
|
|
|
|
|
|
+TPE_Unit ramp[6] = { 1600,0, -500,1400, -700,0 };
|
|
|
|
|
+TPE_Unit ramp2[6] = { 2000,-5000, 1500,1700, -5000,-500 };
|
|
|
|
|
+
|
|
|
TPE_Vec3 environmentDistance(TPE_Vec3 p, TPE_Unit maxD)
|
|
TPE_Vec3 environmentDistance(TPE_Vec3 p, TPE_Unit maxD)
|
|
|
{
|
|
{
|
|
|
- TPE_ENV_START( TPE_envAABoxInside(p,TPE_vec3(0,ROOM_SIZE / 4,0),TPE_vec3(ROOM_SIZE,ROOM_SIZE / 2,ROOM_SIZE)),p )
|
|
|
|
|
- TPE_ENV_NEXT( TPE_envAABox(p,TPE_vec3(4000,160,4000),TPE_vec3(1000,160,1000)),p )
|
|
|
|
|
- TPE_ENV_NEXT( TPE_envAABox(p,TPE_vec3(4000,80,2500),TPE_vec3(1000,80,500)),p )
|
|
|
|
|
- TPE_ENV_NEXT( TPE_envAABox(p,TPE_vec3(-1000,270,4500),TPE_vec3(4000,270,250)),p )
|
|
|
|
|
- TPE_ENV_NEXT( TPE_envAABox(p,TPE_vec3(-4000,elevatorHeight,0),TPE_vec3(1000,elevatorHeight,1000)),p )
|
|
|
|
|
- TPE_ENV_NEXT( TPE_envHalfPlane(p,TPE_vec3(0,0,-2000),TPE_vec3(0,255,255)),p )
|
|
|
|
|
- TPE_ENV_NEXT( TPE_envInfiniteCylinder(p,TPE_vec3(2000,0,-1100),TPE_vec3(0,255,0),400),p )
|
|
|
|
|
|
|
+ TPE_ENV_START( TPE_envAABoxInside(p,TPE_vec3(0,2450,-2100),TPE_vec3(12600,5000,10800)),p )
|
|
|
|
|
+// TPE_ENV_NEXT( TPE_envAABox(p,TPE_vec3(-10000,-10000,-10000),TPE_vec3(-1386,10000,-3160)),p )
|
|
|
|
|
+ TPE_ENV_NEXT( TPE_envAABox(p,TPE_vec3(-5693,0,-6580),TPE_vec3(4307,20000,3420)),p )
|
|
|
|
|
+ TPE_ENV_NEXT( TPE_envAABox(p,TPE_vec3(-10000,-1000,-10000),TPE_vec3(11085,2500,9295)),p )
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ TPE_ENV_NEXT ( TPE_envAATriPrism(p,TPE_vec3(-5400,0,0),ramp,3000,2), p)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+TPE_ENV_NEXT (
|
|
|
|
|
+TPE_envAATriPrism(p,
|
|
|
|
|
+TPE_vec3(2076,651,-6780),ramp2,3000,0), p)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+TPE_ENV_NEXT( TPE_envAABox(p,
|
|
|
|
|
+TPE_vec3(7000,0,-8500),
|
|
|
|
|
+TPE_vec3(3405,2400,3183)),p )
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+TPE_ENV_NEXT( TPE_envSphere(p,TPE_vec3(2521,-100,-3799),
|
|
|
|
|
+1200),p )
|
|
|
|
|
+
|
|
|
|
|
+// 2521 650 -3799
|
|
|
|
|
+
|
|
|
|
|
+// TPE_ENV_NEXT( TPE_envAABox(p,TPE_vec3(4000,80,2500),TPE_vec3(1000,80,500)),p )
|
|
|
|
|
+// TPE_ENV_NEXT( TPE_envAABox(p,TPE_vec3(-1000,270,4500),TPE_vec3(4000,270,250)),p )
|
|
|
|
|
+// 5298 651 -4432
|
|
|
|
|
+
|
|
|
|
|
+TPE_ENV_NEXT(
|
|
|
|
|
+TPE_envAABox(p,TPE_vec3(5300,elevatorHeight,-4400),
|
|
|
|
|
+TPE_vec3(1000,elevatorHeight,1000)),p )
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ TPE_ENV_NEXT( TPE_envHalfPlane(p,TPE_vec3(5051,0,1802),TPE_vec3(-255,0,-255)),p )
|
|
|
|
|
+ TPE_ENV_NEXT( TPE_envInfiniteCylinder(p,TPE_vec3(320,0,170),TPE_vec3(0,255,0),530),p )
|
|
|
TPE_ENV_END
|
|
TPE_ENV_END
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -37,6 +69,7 @@ void updateDirection(void) // updates player direction vector
|
|
|
int main(void)
|
|
int main(void)
|
|
|
{
|
|
{
|
|
|
helper_init();
|
|
helper_init();
|
|
|
|
|
+ levelModelInit();
|
|
|
|
|
|
|
|
updateDirection();
|
|
updateDirection();
|
|
|
|
|
|
|
@@ -48,7 +81,7 @@ int main(void)
|
|
|
|
|
|
|
|
playerBody = &(tpe_world.bodies[0]);
|
|
playerBody = &(tpe_world.bodies[0]);
|
|
|
|
|
|
|
|
- TPE_bodyMoveBy(&tpe_world.bodies[0],TPE_vec3(0,1000,0));
|
|
|
|
|
|
|
+ TPE_bodyMoveBy(&tpe_world.bodies[0],TPE_vec3(1000,1000,1500));
|
|
|
TPE_bodyRotateByAxis(&tpe_world.bodies[0],TPE_vec3(0,0,TPE_FRACTIONS_PER_UNIT / 4));
|
|
TPE_bodyRotateByAxis(&tpe_world.bodies[0],TPE_vec3(0,0,TPE_FRACTIONS_PER_UNIT / 4));
|
|
|
playerBody->elasticity = 0;
|
|
playerBody->elasticity = 0;
|
|
|
playerBody->friction = 0;
|
|
playerBody->friction = 0;
|
|
@@ -76,16 +109,31 @@ int main(void)
|
|
|
if (jumpCountdown > 0)
|
|
if (jumpCountdown > 0)
|
|
|
jumpCountdown--;
|
|
jumpCountdown--;
|
|
|
|
|
|
|
|
- /* Check whether on ground. This can be done in several ways, e.g. by
|
|
|
|
|
- checking recent collisions. We'll do it by casting a downwards ray: */
|
|
|
|
|
|
|
|
|
|
- onGround = (playerBody->flags & TPE_BODY_FLAG_DEACTIVATED) ||
|
|
|
|
|
- TPE_DISTANCE( playerBody->joints[0].position,
|
|
|
|
|
|
|
+
|
|
|
|
|
+TPE_Vec3 groundPoint = environmentDistance(playerBody->joints[0].position,groundDist);
|
|
|
|
|
+
|
|
|
|
|
+onGround = (playerBody->flags & TPE_BODY_FLAG_DEACTIVATED) ||
|
|
|
|
|
+ (TPE_DISTANCE(playerBody->joints[0].position,groundPoint)
|
|
|
|
|
+ <= groundDist && groundPoint.y < playerBody->joints[0].position.y - groundDist / 2
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+if (!onGround)
|
|
|
|
|
+{
|
|
|
|
|
+ /* it's possible that the closest point is e.g. was a perpend wall so also
|
|
|
|
|
+ additionally check directly below */
|
|
|
|
|
+
|
|
|
|
|
+ onGround = TPE_DISTANCE( playerBody->joints[0].position,
|
|
|
TPE_castEnvironmentRay(playerBody->joints[0].position,
|
|
TPE_castEnvironmentRay(playerBody->joints[0].position,
|
|
|
TPE_vec3(0,-1 * TPE_FRACTIONS_PER_UNIT,0),tpe_world.environmentFunction,
|
|
TPE_vec3(0,-1 * TPE_FRACTIONS_PER_UNIT,0),tpe_world.environmentFunction,
|
|
|
128,512,512)) <= groundDist;
|
|
128,512,512)) <= groundDist;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
- elevatorHeight = TPE_sin(helper_frame * 4) + TPE_FRACTIONS_PER_UNIT;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ elevatorHeight =
|
|
|
|
|
+(1250 * (TPE_sin(helper_frame * 4) + TPE_FRACTIONS_PER_UNIT)) /
|
|
|
|
|
+(2 * TPE_FRACTIONS_PER_UNIT);
|
|
|
|
|
|
|
|
s3l_scene.camera.transform.translation.x = playerBody->joints[0].position.x;
|
|
s3l_scene.camera.transform.translation.x = playerBody->joints[0].position.x;
|
|
|
s3l_scene.camera.transform.translation.z = playerBody->joints[0].position.z;
|
|
s3l_scene.camera.transform.translation.z = playerBody->joints[0].position.z;
|
|
@@ -151,21 +199,22 @@ int main(void)
|
|
|
playerRotation += 8;
|
|
playerRotation += 8;
|
|
|
|
|
|
|
|
if (helper_frame % 64 == 0)
|
|
if (helper_frame % 64 == 0)
|
|
|
|
|
+ {
|
|
|
helper_printCPU();
|
|
helper_printCPU();
|
|
|
|
|
+ helper_printCamera();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// draw the 3D environment
|
|
// draw the 3D environment
|
|
|
|
|
|
|
|
- helper_set3DColor(180,180,180);
|
|
|
|
|
- helper_draw3DBoxInside(TPE_vec3(0,ROOM_SIZE / 4,0),TPE_vec3(ROOM_SIZE,ROOM_SIZE / 2,ROOM_SIZE),TPE_vec3(0,0,0));
|
|
|
|
|
- helper_set3DColor(100,200,180);
|
|
|
|
|
- helper_draw3DBox(TPE_vec3(4000,160,4000),TPE_vec3(2000,320,2000),TPE_vec3(0,0,0));
|
|
|
|
|
- helper_draw3DBox(TPE_vec3(4000,80,2500),TPE_vec3(2000,160,1000),TPE_vec3(0,0,0));
|
|
|
|
|
- helper_draw3DBox(TPE_vec3(-1000,270,4500),TPE_vec3(8000,540,500),TPE_vec3(0,0,0));
|
|
|
|
|
- helper_draw3DBox(TPE_vec3(-4000,elevatorHeight,0),TPE_vec3(2000,2 * elevatorHeight,2000),TPE_vec3(0,0,0));
|
|
|
|
|
- helper_draw3DCylinder(TPE_vec3(2000,5000,-1100),TPE_vec3(400,10000,400),TPE_vec3(0,0,0));
|
|
|
|
|
|
|
+ helper_set3DColor(200,200,200);
|
|
|
|
|
+
|
|
|
|
|
+ helper_drawModel(&levelModel,TPE_vec3(0,0,0),TPE_vec3(600,600,600),
|
|
|
|
|
+ TPE_vec3(0,0,0));
|
|
|
|
|
+
|
|
|
|
|
+helper_draw3DBox(
|
|
|
|
|
+TPE_vec3(5300,elevatorHeight,-4400),
|
|
|
|
|
+TPE_vec3(2000,2 * elevatorHeight,2000),TPE_vec3(0,0,0));
|
|
|
|
|
|
|
|
- helper_draw3DPlane(TPE_vec3(0,1500,-3500),TPE_vec3(10000,512,4000),TPE_vec3(-64,0,0));
|
|
|
|
|
-
|
|
|
|
|
helper_set3DColor(200,50,0);
|
|
helper_set3DColor(200,50,0);
|
|
|
|
|
|
|
|
helper_draw3DBox(TPE_bodyGetCenterOfMass(&tpe_world.bodies[2]),
|
|
helper_draw3DBox(TPE_bodyGetCenterOfMass(&tpe_world.bodies[2]),
|