mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-11-21 20:39:57 +01:00
Update examples
This commit is contained in:
parent
e4f361f26e
commit
973a3ad02c
3 changed files with 8283 additions and 8303 deletions
|
@ -30,7 +30,10 @@
|
||||||
#define TEXTURE_W 256
|
#define TEXTURE_W 256
|
||||||
#define TEXTURE_H 256
|
#define TEXTURE_H 256
|
||||||
|
|
||||||
#define MAX_VELOCITY 800
|
#define MAX_VELOCITY 1000
|
||||||
|
#define ACCELERATION 700
|
||||||
|
#define TURN_SPEED 300
|
||||||
|
#define FRICTION 600
|
||||||
|
|
||||||
S3L_Model3D models[2];
|
S3L_Model3D models[2];
|
||||||
|
|
||||||
|
@ -273,9 +276,9 @@ int main()
|
||||||
uint8_t *state = SDL_GetKeyboardState(NULL);
|
uint8_t *state = SDL_GetKeyboardState(NULL);
|
||||||
|
|
||||||
int16_t step = velocity * frameDiff;
|
int16_t step = velocity * frameDiff;
|
||||||
int16_t stepFriction = 300 * frameDiff;
|
int16_t stepFriction = FRICTION * frameDiff;
|
||||||
int16_t stepRotation = 200 * frameDiff * S3L_max(0,velocity - 400) / ((float) MAX_VELOCITY);
|
int16_t stepRotation = TURN_SPEED * frameDiff * S3L_max(0,velocity - 200) / ((float) MAX_VELOCITY);
|
||||||
int16_t stepVelocity = S3L_nonZero(1000 * frameDiff);
|
int16_t stepVelocity = S3L_nonZero(ACCELERATION * frameDiff);
|
||||||
|
|
||||||
if (stepRotation == 0 && S3L_abs(velocity) >= 200)
|
if (stepRotation == 0 && S3L_abs(velocity) >= 200)
|
||||||
stepRotation = 1;
|
stepRotation = 1;
|
||||||
|
@ -320,7 +323,7 @@ int main()
|
||||||
if (coll == 1)
|
if (coll == 1)
|
||||||
{
|
{
|
||||||
handleCollision(&(models[1].transform.translation),previousCarPos);
|
handleCollision(&(models[1].transform.translation),previousCarPos);
|
||||||
friction = 8;
|
friction = 2;
|
||||||
}
|
}
|
||||||
else if (coll == 2)
|
else if (coll == 2)
|
||||||
{
|
{
|
||||||
|
@ -340,7 +343,7 @@ int main()
|
||||||
velocity = S3L_min(0,velocity + stepFriction * friction);
|
velocity = S3L_min(0,velocity + stepFriction * friction);
|
||||||
|
|
||||||
S3L_Unit cameraDistance =
|
S3L_Unit cameraDistance =
|
||||||
S3L_FRACTIONS_PER_UNIT / 2 + (S3L_abs(velocity) * (S3L_FRACTIONS_PER_UNIT / 2) / MAX_VELOCITY);
|
S3L_interpolate(S3L_FRACTIONS_PER_UNIT / 2,S3L_FRACTIONS_PER_UNIT,S3L_abs(velocity),MAX_VELOCITY);
|
||||||
|
|
||||||
scene.camera.transform.translation.x =
|
scene.camera.transform.translation.x =
|
||||||
scene.models[1].transform.translation.x - (carDirection.x * cameraDistance) / S3L_FRACTIONS_PER_UNIT;
|
scene.models[1].transform.translation.x - (carDirection.x * cameraDistance) / S3L_FRACTIONS_PER_UNIT;
|
||||||
|
|
16555
programs/cityTexture.h
16555
programs/cityTexture.h
File diff suppressed because it is too large
Load diff
|
@ -496,25 +496,23 @@ int main()
|
||||||
target0 = scene.models[0].transform.translation;
|
target0 = scene.models[0].transform.translation;
|
||||||
target1 = scene.models[2].transform.translation;
|
target1 = scene.models[2].transform.translation;
|
||||||
|
|
||||||
transform0.translation.x = 2 * S3L_FRACTIONS_PER_UNIT;
|
transform0.translation.x = -2 * S3L_FRACTIONS_PER_UNIT;
|
||||||
transform0.translation.y = 4 * S3L_FRACTIONS_PER_UNIT;
|
transform0.translation.y = 5 * S3L_FRACTIONS_PER_UNIT;
|
||||||
transform0.translation.z = -14 * S3L_FRACTIONS_PER_UNIT;
|
transform0.translation.z = -14 * S3L_FRACTIONS_PER_UNIT;
|
||||||
|
|
||||||
S3L_lookAt(target0,&transform0);
|
transform0.rotation.x = -S3L_FRACTIONS_PER_UNIT / 12;
|
||||||
|
transform1.rotation.y = S3L_FRACTIONS_PER_UNIT / 8;
|
||||||
|
|
||||||
transform1.translation.x = 5 * S3L_FRACTIONS_PER_UNIT;
|
transform1.translation.x = 5 * S3L_FRACTIONS_PER_UNIT;
|
||||||
transform1.translation.y = 6 * S3L_FRACTIONS_PER_UNIT;
|
transform1.translation.y = 6 * S3L_FRACTIONS_PER_UNIT;
|
||||||
transform1.translation.z = 3 * S3L_FRACTIONS_PER_UNIT;
|
transform1.translation.z = 3 * S3L_FRACTIONS_PER_UNIT;
|
||||||
|
|
||||||
transform1.rotation.x = S3L_FRACTIONS_PER_UNIT / 8;
|
transform1.rotation.x = transform0.rotation.x;
|
||||||
|
transform1.rotation.y = transform0.rotation.y;
|
||||||
S3L_lookAt(target1,&transform1);
|
|
||||||
|
|
||||||
//transform1.rotation.y = -S3L_FRACTIONS_PER_UNIT + transform1.rotation.y;
|
|
||||||
|
|
||||||
int frames = 100;
|
int frames = 100;
|
||||||
|
|
||||||
for (int i = 0; i < frames; ++i) // render the frames
|
for (int i = 0; i < frames; ++i) // render the frames
|
||||||
{
|
{
|
||||||
animateWater();
|
animateWater();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue