rendered paste body#include "boolean.h"
/* Physics grid constants. */
#define GRID_WIDTH 25
#define GRID_HEIGHT 9
#define POSITION_RANGE 100.0f
#define NUM_SPRINGS (2 * GRID_WIDTH * GRID_HEIGHT - GRID_WIDTH - GRID_HEIGHT)
/* Physics misc constants. */
#define SPRING_K 18.0f
#define FRICTION 0.25f
/* Graphics grid constants */
#define PAINT_GRID_WIDTH 50
#define PAINT_GRID_HEIGHT 50
#define PAINT_POSITION_RANGE_X 4.5f
#define PAINT_POSITION_RANGE_Y 4.5f
#define PAINT_POSITION_RANGE_Z 4.5f
/* Structs */
typedef struct _point_3d {
float x, y, z;
} Point3D, Vector3D;
typedef struct _Object {
Point3D position;
Point3D prevPosition;
Vector3D force;
Bool anchor;
} Object;
typedef struct _Spring {
Object* a;
Object* b;
Vector3D offset;
} Spring;
typedef struct _Model {
Object object[GRID_WIDTH][GRID_HEIGHT];
Spring spring[NUM_SPRINGS];
} Model;
/* Functions. */
Model* initModel();
void stepModel(Model* model);
void drawModel(Model* model);
void initAnimation(Model* model);
void stepAnimation(Model* model);