fixed topo's soft tabs; added zoom to cam_point_dir
This commit is contained in:
parent
27114c2c16
commit
13b3640db7
4
.gitignore
vendored
4
.gitignore
vendored
@ -8,3 +8,7 @@ bts.exe
|
|||||||
# backups, just in case you can't configure your editor properly
|
# backups, just in case you can't configure your editor properly
|
||||||
*.bak
|
*.bak
|
||||||
*~
|
*~
|
||||||
|
|
||||||
|
# gprof
|
||||||
|
gmon.out
|
||||||
|
|
||||||
|
2
common.h
2
common.h
@ -117,4 +117,4 @@ int render_init(int width, int height);
|
|||||||
void render_deinit(void);
|
void render_deinit(void);
|
||||||
|
|
||||||
// vecmath.c
|
// vecmath.c
|
||||||
void cam_point_dir(camera_t *model, float dx, float dy, float dz);
|
void cam_point_dir(camera_t *model, float dx, float dy, float dz, float zoom, float roll);
|
||||||
|
13
main.c
13
main.c
@ -112,16 +112,17 @@ void run_game(void)
|
|||||||
|
|
||||||
while(!quitflag)
|
while(!quitflag)
|
||||||
{
|
{
|
||||||
|
float zoom = 1.0f;
|
||||||
|
|
||||||
// update angles
|
// update angles
|
||||||
if(key_left)
|
if(key_left)
|
||||||
angy += 0.02f;
|
angy += 0.02f/zoom;
|
||||||
if(key_right)
|
if(key_right)
|
||||||
angy -= 0.02f;
|
angy -= 0.02f/zoom;
|
||||||
if(key_up)
|
if(key_up)
|
||||||
angx -= 0.02f;
|
angx -= 0.02f/zoom;
|
||||||
if(key_down)
|
if(key_down)
|
||||||
angx += 0.02f;
|
angx += 0.02f/zoom;
|
||||||
|
|
||||||
// clamp angle, YOU MUST NOT LOOK DIRECTLY UP OR DOWN!
|
// clamp angle, YOU MUST NOT LOOK DIRECTLY UP OR DOWN!
|
||||||
if(angx > M_PI*0.499f)
|
if(angx > M_PI*0.499f)
|
||||||
@ -134,7 +135,7 @@ void run_game(void)
|
|||||||
float cya = cosf(angy);
|
float cya = cosf(angy);
|
||||||
float sxa = sinf(angx);
|
float sxa = sinf(angx);
|
||||||
float cxa = cosf(angx);
|
float cxa = cosf(angx);
|
||||||
cam_point_dir(&tcam, sya*cxa, sxa, cya*cxa);
|
cam_point_dir(&tcam, sya*cxa, sxa, cya*cxa, zoom, 0.0f);
|
||||||
|
|
||||||
// move along
|
// move along
|
||||||
float mvx = 0.0f;
|
float mvx = 0.0f;
|
||||||
@ -154,7 +155,7 @@ void run_game(void)
|
|||||||
if(key_space)
|
if(key_space)
|
||||||
mvy -= 1.0f;
|
mvy -= 1.0f;
|
||||||
|
|
||||||
float mvspd = 0.2f;
|
float mvspd = 0.2f/zoom;
|
||||||
mvx *= mvspd;
|
mvx *= mvspd;
|
||||||
mvy *= mvspd;
|
mvy *= mvspd;
|
||||||
mvz *= mvspd;
|
mvz *= mvspd;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
void cam_point_dir(camera_t *model, float dx, float dy, float dz)
|
void cam_point_dir(camera_t *model, float dx, float dy, float dz, float zoom, float roll)
|
||||||
{
|
{
|
||||||
// Another case where I'd copy-paste code from my aimbot.
|
// Another case where I'd copy-paste code from my aimbot.
|
||||||
// Except the last time I did it, I redid it from scratch,
|
// Except the last time I did it, I redid it from scratch,
|
||||||
@ -28,9 +28,9 @@ void cam_point_dir(camera_t *model, float dx, float dy, float dz)
|
|||||||
// Now build that matrix!
|
// Now build that matrix!
|
||||||
|
|
||||||
// Front vector (Z): Well, duh.
|
// Front vector (Z): Well, duh.
|
||||||
model->mzx = nx;
|
model->mzx = nx*zoom;
|
||||||
model->mzy = ny;
|
model->mzy = ny*zoom;
|
||||||
model->mzz = nz;
|
model->mzz = nz*zoom;
|
||||||
|
|
||||||
// Left (TODO: confirm) vector (X): Simple 2D 90deg rotation.
|
// Left (TODO: confirm) vector (X): Simple 2D 90deg rotation.
|
||||||
// Can be derived from a bit of trial and error.
|
// Can be derived from a bit of trial and error.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user