mirror of
https://github.com/nishiowo/nishbox
synced 2025-04-21 20:24:39 +00:00
make vector array
This commit is contained in:
parent
69342355eb
commit
5e1276d68a
@ -3,7 +3,6 @@
|
||||
#include "nb_pre.h"
|
||||
|
||||
/* External library */
|
||||
#include <ode/ode.h>
|
||||
#ifdef _WIN32
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
|
@ -36,18 +36,15 @@ nb_draw_t* nb_draw_create(void) {
|
||||
nb_draw_reshape(draw);
|
||||
draw->running = 1;
|
||||
|
||||
draw->light = malloc(sizeof(*draw->light) * 4);
|
||||
draw->light[0] = 10.0;
|
||||
draw->light[1] = 10.0;
|
||||
draw->light[2] = 0.0;
|
||||
draw->light[3] = 1.0;
|
||||
|
||||
draw->camera = malloc(sizeof(*draw->camera) * 3);
|
||||
draw->camera[0] = 0;
|
||||
draw->camera[1] = 10;
|
||||
draw->camera[2] = 0;
|
||||
|
||||
draw->lookat = malloc(sizeof(*draw->lookat) * 3);
|
||||
draw->lookat[0] = 0;
|
||||
draw->lookat[1] = 0;
|
||||
draw->lookat[2] = 0;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#define NB_LOG_EXPOSE
|
||||
|
||||
#include "nb_pre.h"
|
||||
|
||||
/* External library */
|
||||
|
@ -9,15 +9,16 @@
|
||||
/* NishBox */
|
||||
|
||||
/* Standard */
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
float nb_log2(float x) { return log(x) / log(2); }
|
||||
|
||||
nb_vector_t nb_calculate_normal(nb_vector_t v0, nb_vector_t v1, nb_vector_t v2) {
|
||||
void nb_calculate_normal(nb_vector_t* r, nb_vector_t v0, nb_vector_t v1, nb_vector_t v2) {
|
||||
int i;
|
||||
dReal length;
|
||||
nb_vector_t vec = malloc(sizeof(*vec) * 3);
|
||||
nb_vector_t vec;
|
||||
dReal res[3];
|
||||
dReal tmp0[3];
|
||||
dReal tmp1[3];
|
||||
@ -41,5 +42,5 @@ nb_vector_t nb_calculate_normal(nb_vector_t v0, nb_vector_t v1, nb_vector_t v2)
|
||||
vec[1] /= length;
|
||||
vec[2] /= length;
|
||||
|
||||
return vec;
|
||||
memcpy(*r, vec, sizeof(vec));
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
to[1] = from[1]; \
|
||||
to[2] = from[2]
|
||||
|
||||
float nb_log2(float x);
|
||||
nb_vector_t nb_calculate_normal(nb_vector_t v0, nb_vector_t v1, nb_vector_t v2);
|
||||
float nb_log2(float x);
|
||||
void nb_calculate_normal(nb_vector_t* r, nb_vector_t v0, nb_vector_t v1, nb_vector_t v2);
|
||||
|
||||
#endif
|
||||
|
@ -11,9 +11,9 @@
|
||||
|
||||
/* Standard */
|
||||
|
||||
typedef double* nb_vector_t;
|
||||
typedef double nb_vector_t[4];
|
||||
#else
|
||||
typedef void* nb_vector_t;
|
||||
#error "should not happen!"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -19,7 +19,7 @@ NB_DECLARE_TYPE(version, {
|
||||
char opengl[32];
|
||||
});
|
||||
#else
|
||||
typedef void nb_version_t;
|
||||
#error "should not happen!"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user