X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fmetaball.c;fp=src%2Fmetaball.c;h=0000000000000000000000000000000000000000;hp=94049125442905aec4a95014ca30d3e9b58a81a6;hb=ba648ddfc62fc6d3f47294aa8bfc10ea6ca3f479;hpb=3398fc6c4188104048f99b650a6cb90beda9b6ed diff --git a/src/metaball.c b/src/metaball.c deleted file mode 100644 index 9404912..0000000 --- a/src/metaball.c +++ /dev/null @@ -1,193 +0,0 @@ -#include -#include -#include -#include -#include -#include "screen.h" -#include "demo.h" -#include "3dgfx.h" -#include "gfxutil.h" -#include "util.h" -#include "metasurf.h" -#include "mesh.h" - -struct metaball { - float energy; - float pos[3]; -}; - -static int init(void); -static void destroy(void); -static void start(long trans_time); -static void draw(void); - -static void calc_voxel_field(void); - -static struct screen scr = { - "metaballs", - init, - destroy, - start, 0, - draw -}; - -static float cam_theta, cam_phi = 25; -static float cam_dist = 10; -static struct g3d_mesh mmesh; - -static struct metasurface *msurf; - -#define VOL_SZ 32 -#define VOL_SCALE 10.0f -#define VOX_DIST (VOL_SCALE / VOL_SZ) -#define VOL_HALF_SCALE (VOL_SCALE * 0.5f) - -#define NUM_MBALLS 3 -static struct metaball mball[NUM_MBALLS]; - -static int dbg; - -struct screen *metaballs_screen(void) -{ - return &scr; -} - -static int init(void) -{ - mball[0].energy = 1.2; - mball[1].energy = 0.8; - mball[2].energy = 1.0; - - if(!(msurf = msurf_create())) { - fprintf(stderr, "failed to initialize metasurf\n"); - return -1; - } - msurf_set_resolution(msurf, VOL_SZ, VOL_SZ, VOL_SZ); - msurf_set_bounds(msurf, -VOL_HALF_SCALE, -VOL_HALF_SCALE, -VOL_HALF_SCALE, - VOL_HALF_SCALE, VOL_HALF_SCALE, VOL_HALF_SCALE); - msurf_set_threshold(msurf, 1.7); - msurf_set_inside(msurf, MSURF_GREATER); - - mmesh.prim = G3D_TRIANGLES; - mmesh.varr = 0; - mmesh.iarr = 0; - mmesh.vcount = mmesh.icount = 0; - - return 0; -} - -static void destroy(void) -{ - msurf_free(msurf); -} - -static void start(long trans_time) -{ - g3d_matrix_mode(G3D_PROJECTION); - g3d_load_identity(); - g3d_perspective(50.0, 1.3333333, 0.5, 100.0); - - g3d_enable(G3D_CULL_FACE); - g3d_enable(G3D_LIGHTING); - g3d_enable(G3D_LIGHT0); - - g3d_polygon_mode(G3D_GOURAUD); -} - -static void update(void) -{ - int i, j; - float tsec = time_msec / 1000.0f; - static float phase[] = {0.0, M_PI / 3.0, M_PI * 0.8}; - static float speed[] = {0.8, 1.4, 1.0}; - static float scale[][3] = {{1, 2, 0.8}, {0.5, 1.6, 0.6}, {1.5, 0.7, 0.5}}; - static float offset[][3] = {{0, 0, 0}, {0.25, 0, 0}, {-0.2, 0.15, 0.2}}; - - mouse_orbit_update(&cam_theta, &cam_phi, &cam_dist); - - for(i=0; i