collision.c in Collision.rar


VC prepared with the explosion scenes, very realistic. Can let you see the real...Original Link
    Sponsored links

			

#include <stdlib.h>
#include <GL/glut.h>
#include <stdio.h>
#include <math.h>
#include <sys/types.h>
#include <time.h>

// 光源定义
GLfloat light_diffuse[] = {1.0, 1.0, 1.0, 1.0};  
GLfloat light_position[] = {10.0, 10.0, 30.0, 1.0};  
int win_id;
static GLuint texName;

// SETUP DATASTRUCTURE FOR OBJECTS
#define MAXGUYS 300
#define MAXOBJS 80
int NUMOBJS;
int TEXENABLE;
int DEBUGENABLE;
int frame;
//  点的数据结构
struct point 
{
	float x; 
	float y; 
	float z;
};
//  有关弹性碰撞的数据结构
struct spring 
{
	struct point* p1; 
	struct point* p2;
	struct point* v1; 
	struct point* v2;
	float* m1; 
	float* m2;
	float length; 
	float stiff; 
	float damp; 
	float breaklen;
};
//  有关碰撞线的数据结构
struct cdline 
{
	struct point* p1; 
	struct point* p2; 
	struct point* v1; 
	struct point* v2;
	struct point* vi1; 
	struct point* vi2;
	struct point min; 
	struct point max;
	float* mass;
	float fric;
};
//  对象的面的数据结构
struct face 
{
	struct point* p1; 
	struct point* p2;
	struct point* p3;
	struct point* v1; 
	struct point* v2; 
	struct point* v3;
	struct point* vi1; 
	struct point* vi2; 
	struct point* vi3; 
    float* m1; 
	float* m2; 
	float* m3;
    struct point min; 
	struct point max;
    float fric; 
	struct point nor;
};
//  有关对象的数据结构
struct object 
{
	int NUMPTS;
	int NUMSPRINGS;
	int NUMFACES;
	int NUMCDLINES;
	float mass[MAXGUYS];
	float r,g,b,a;
	struct point points[MAXGUYS];
	struct point vel[MAXGUYS];
	struct point velinc[MAXGUYS];
	struct spring springs[MAXGUYS];
	struct cdline cdlines[MAXGUYS];
	struct face faces[MAXGUYS];
	struct point max;                             // 对象的边界盒
	struct point min;
	int texture;
	int NUMTEXPTS;
	int texmap[64][64];
	struct point texpoints[MAXGUYS]; 
	struct face texfaces[MAXGUYS];
};
struct object objects[MAXOBJS];

// 定义一些底层函数
#define sqa(A) (A*fabs(A))
#define length(A) sq			

			...
			...
			... to be continued.

  This is a preview. To get the complete source file, 
  please click here to download the whole source code package.

			
			


Project Files

    Sponsored links
NameSizeDate
 collision.0013.37 kB03-10-99 18:32
 collision.c27.47 kB08-12-02 16:59
 collision.dsp3.41 kB07-12-02 20:13
 collision.dsw543.00 B07-12-02 20:13
 collision.exe248.12 kB08-12-02 16:59
 collision.ncb49.00 kB08-12-02 17:02
 collision.opt47.50 kB08-12-02 17:02
 collision.plg1.21 kB08-12-02 16:59
 CONFIG.TXT577.00 B03-10-99 14:33
 config.chain653.00 B03-10-99 14:33
 config.damp36.00 B03-10-99 14:33
 config.fric147.00 B03-10-99 14:33
 config.jello60.00 B03-10-99 14:33
 config.mass104.00 B03-10-99 14:33
 config.plate577.00 B03-10-99 14:33
 config.speed253.00 B03-10-99 14:33
 MAKE369.00 B01-10-99 19:54
 BLOCK.MOD5.52 kB03-10-99 07:16
 BLOCK.TGA27.06 kB03-10-99 06:55
 CAN.MOD5.75 kB03-10-99 06:41
 CAN.TGA12.06 kB03-10-99 06:41
 CHAIN.MOD732.00 B03-10-99 06:41
 chain_vstaple.mod341.00 B03-10-99 06:41
 FLOOR.TGA12.06 kB03-10-99 06:41
 JELLO.MOD5.80 kB03-10-99 07:56
 LILBLOCK.MOD5.49 kB03-10-99 07:27
 LILBLOCK.TGA27.06 kB03-10-99 07:26
 LILSTONE.MOD5.49 kB03-10-99 07:24
 LILSTONE.TGA12.06 kB03-10-99 07:21
 LONGRAMP.MOD3.34 kB03-10-99 07:25
 LONGRAMP.TGA27.06 kB03-10-99 07:25
 MARSH.MOD5.80 kB03-10-99 07:50
 MARSH.TGA12.06 kB03-10-99 06:54
 plate_base.mod1.45 kB03-10-99 06:41
 plate_larm0.mod1.29 kB03-10-99 06:41
 plate_larm1.mod1.29 kB03-10-99 06:41
 plate_larm2.mod1.30 kB03-10-99 06:41
 plate_larm3.mod1.30 kB03-10-99 06:41
 plate_larm4.mod1.31 kB03-10-99 06:41
 plate_larm5.mod1.31 kB03-10-99 06:41
 plate_larm6.mod1.31 kB03-10-99 06:41
 plate_larm7.mod1.30 kB03-10-99 06:41
 plate_sarm0.mod750.00 B03-10-99 06:41
 plate_sarm1.mod750.00 B03-10-99 06:41
 plate_sarm2.mod753.00 B03-10-99 06:41
 plate_sarm3.mod755.00 B03-10-99 06:41
 plate_sarm4.mod758.00 B03-10-99 06:41
 plate_sarm5.mod758.00 B03-10-99 06:41
 plate_sarm6.mod755.00 B03-10-99 06:41
 plate_sarm7.mod753.00 B03-10-99 06:41
 plate_vstaple.mod1.57 kB03-10-99 06:41
 RAMP.MOD3.34 kB03-10-99 06:41
 RAMP.TGA27.06 kB03-10-99 07:06
 README.models118.00 B03-10-99 06:41
 STONE.MOD5.51 kB03-10-99 07:14
 STONE.TGA12.06 kB03-10-99 06:54
 README.algorithms1.88 kB03-10-99 10:23
 README.config549.00 B01-10-99 19:54
 setup.3dfx89.00 B01-10-99 19:54
 test3Dfx39.79 kB01-10-99 19:54
 <CONFIGS>0.00 B21-10-08 08:16
 <Debug>0.00 B21-10-08 08:16
 <MODELS>0.00 B21-10-08 08:16
 <Collision>0.00 B21-10-08 08:16
...

Related Items

    Sponsored links