source: golgotha/src/golg/objs/explode_model.hh

Last change on this file was 80, checked in by Sam Hocevar, 12 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.5 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#ifndef EXPLODE_MODEL_HH
10#define EXPLODE_MODEL_HH
11
12#include "arch.hh"
13#include "math/num_type.hh"
14#include "objs/map_piece.hh"
15
16class g1_object_class;
17class g1_draw_context_class;
18
19class g1_explode_vertex_class
20{
21public:
22  i4_3d_vector v;
23  i4_float s,t;
24};
25
26class g1_explode_face_class
27{
28public:
29  w8    tint_handle; //0 for no tint
30
31  enum { MAX_VERTS=g1_quad_class::MAX_VERTS };
32  w32 num_verts() const { return (indices[MAX_VERTS-1]==0xffff)? MAX_VERTS-1 : MAX_VERTS; }
33 
34  g1_quad_class::vertex_ref_type indices[MAX_VERTS];
35
36  i4_3d_vector angles, l_angles, angular_vel;
37  i4_3d_vector pos, l_pos, vel;
38};
39
40enum g1_stage_type { G1_APPLY_WHOLE, G1_APPLY_SING };  // same force for each piece?
41
42
43
44struct g1_explode_params
45{
46  float gravity;
47  struct stage
48  {
49    g1_stage_type type;
50    int ticks;
51    float force;     // f= force/(dist*dist)negative force sucks, postive expels, 0 does nothing
52    float air_friction;
53   
54    void setup(int _ticks, float _force, g1_stage_type t=G1_APPLY_SING, float _air_friction=0.99)
55    { ticks=_ticks; force=_force; type=t; air_friction=_air_friction; }
56   
57  };
58
59  i4_3d_vector initial_vel;
60  int t_stages, current_stage;
61  stage stages[4];
62 
63  g1_explode_params();
64};
65
66class g1_explode_model_class : public g1_object_class
67{
68  void grab_model(g1_object_class *o, i4_3d_vector &obj_center);
69public:
70  g1_explode_params params;
71 
72  enum { DATA_VERSION=1 };
73  i4_3d_vector center;
74 
75  g1_explode_model_class(g1_object_type id, g1_loader_class *fp);
76  ~g1_explode_model_class();
77 
78  i4_float occupancy_radius() const {return 0.f;}
79
80  g1_explode_vertex_class *vertices;
81  sw16 num_vertices;
82
83  g1_explode_face_class   *faces;
84  sw16 num_faces;
85
86  virtual void setup(g1_object_class *source_obj,
87                     const i4_3d_vector &center,
88                     g1_explode_params &params);
89                       
90  virtual void save(g1_saver_class *fp);
91  virtual void draw(g1_draw_context_class *context);
92  virtual void think();
93};
94
95#endif
96
97
Note: See TracBrowser for help on using the repository browser.