Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HW3DStream.h
1 //
2 // Copyright (c) 2005 by Tech Soft 3D, LLC.
3 // The information contained herein is confidential and proprietary to
4 // Tech Soft 3D, LLC., and considered a trade secret as defined under
5 // civil and criminal statutes. Tech Soft 3D shall pursue its civil
6 // and criminal remedies in the event of unauthorized use or misappropriation
7 // of its trade secrets. Use of this information by anyone other than
8 // authorized employees of Tech Soft 3D, LLC. is granted only under a
9 // written non-disclosure agreement, expressly prescribing the scope and
10 // manner of such use.
11 //
12 // $Id: 33a24f830d5bf65cdfa1a0a674d007ebc823292d $
13 //
14 
15 
16 #ifndef _HDWFSTREAM_H
17 #define _HDWFSTREAM_H
18 
19 #include "hc.h"
20 #include "HStream.h"
21 
22 
23 class HW3DPoint
24 {
25 public:
26  float x;
27  float y;
28  float z;
29 
31  HW3DPoint() : x(0), y(0), z(0) {}
33  HW3DPoint(float X, float Y, float Z=0.0f) : x(X), y(Y), z(Z) {}
35  HW3DPoint(HW3DPoint const *p) { x = p->x; y = p->y; z = p->z;};
37  HW3DPoint(const HW3DPoint & p) { x = p.x; y = p.y; z = p.z; };
38 
40  void Set(float X,float Y,float Z = 0.0f) { x = X; y = Y; z = Z; };
42  void Set(HW3DPoint * p) { x = p->x; y = p->y; z = p->z; };
44  void Set(HW3DPoint const * p) { x = p->x; y = p->y; z = p->z; };
46  void Set(HW3DPoint & p) { x = p.x; y = p.y; z = p.z; };
48  void Set(const HW3DPoint & p) { x = p.x; y = p.y; z = p.z; };
49 };
50 
51 class HW3DCamera {
52 public:
53  bool is_valid;
57  float field_width;
58  float field_height;
59  char projection[128];
60 };
61 
62 class HW3DStream_Initial_View : public HTK_Camera
63 {
64 public:
65  HW3DStream_Initial_View(HW3DCamera * initial_view) : HTK_Camera(TKE_View), m_pInitialCamera(initial_view) {;}
66 
67  TK_Status Interpret(BStreamFileToolkit & /*tk*/, ID_Key /*key*/, int /*variant*/)
68  {
69  if(!m_pInitialCamera)
70  return TK_Normal;
71 
72  m_settings[0] = m_pInitialCamera->position.x;
73  m_settings[1] = m_pInitialCamera->position.y;
74  m_settings[2] = m_pInitialCamera->position.z;
75 
76  m_settings[3] = m_pInitialCamera->target.x;
77  m_settings[4] = m_pInitialCamera->target.y;
78  m_settings[5] = m_pInitialCamera->target.z;
79 
80  m_settings[6] = m_pInitialCamera->up_vector.x;
81  m_settings[7] = m_pInitialCamera->up_vector.y;
82  m_settings[8] = m_pInitialCamera->up_vector.z;
83 
84  m_settings[9] = m_pInitialCamera->field_width;
85  m_settings[10] = m_pInitialCamera->field_height;
86 
87  if(m_pInitialCamera->projection[0] == 'p')
88  m_projection = TKO_Camera_Perspective;
89  else
90  m_projection = TKO_Camera_Orthographic;
91 
92  SetView("default");
93 
94  return TK_Normal;
95  }
96 
97 
98  TK_Status Execute(BStreamFileToolkit & /*tk*/) alter
99  {
100  TK_Status status=TK_Normal;
101 
102  if (!strcmp(GetView(),"default"))
103  {
104  m_pInitialCamera->is_valid = true;
105 
106  m_pInitialCamera->position.Set(m_settings[0],m_settings[1],m_settings[2]);
107  m_pInitialCamera->target.Set(m_settings[3],m_settings[4],m_settings[5]);
108  m_pInitialCamera->up_vector.Set(m_settings[6],m_settings[7],m_settings[8]);
109  m_pInitialCamera->field_width = m_settings[9];
110  m_pInitialCamera->field_height = m_settings[10];
111 
112  switch ((int) m_projection) {
113 
114  case TKO_Camera_Orthographic:
115  strcpy_s (m_pInitialCamera->projection, "orthographic");
116  break;
117 
118  case TKO_Camera_Perspective:
119  strcpy_s (m_pInitialCamera->projection, "perspective");
120  break;
121 
122  default:
123  strcpy_s (m_pInitialCamera->projection, "stretched");
124  break;
125  }
126 
127  }
128 
129  return (status);
130  };
131 
132 private:
133  HW3DCamera * m_pInitialCamera;
134 
135 };
136 #if 0
137 // Translate all the TKE_Image's to W3DE_Image
138 class HW3DStream_Image_Converter : public HTK_Image
139 {
140 private:
141  HW3DStream_Image_Converter(const HW3DStream_Image_Converter&);
142  HW3DStream_Image_Converter& operator=(const HW3DStream_Image_Converter&);
143 
144 public:
145 
146  HW3DStream_Image_Converter ()
147  {
148  m_opcode = W3DE_Image;
149  m_size[0] = m_size[1] = 0;
150  }
151 
152  ~HW3DStream_Image_Converter()
153  {
154  delete [] m_name;
155  }
156 
157  TK_Status Write (BStreamFileToolkit & tk) alter
158  {
159  TK_Status status = TK_Normal;
160 
161  switch (m_stage) {
162  case 0: {
163  if ((status = PutOpcode (tk)) != TK_Normal)
164  return status;
165  m_stage++;
166  }
167 
168  case 1: {
169 
170  if (m_name_length > 0) {
171  unsigned char byte = (unsigned char)m_name_length;
172  // need handling for string > 255 ?
173  if ((status = PutData (tk, byte)) != TK_Normal)
174  return status;
175  }
176  m_stage++;
177  }
178 
179  case 2: {
180  if (m_name_length > 0) {
181  if ((status = PutData (tk, m_name, m_name_length)) != TK_Normal)
182  return status;
183  }
184  m_stage++;
185  }
186  case 3:
187  {
188  if ((status = PutData(tk, m_size[0])) != TK_Normal)
189  return status;
190  if ((status = PutData(tk, m_size[1])) != TK_Normal)
191  return status;
192  if ((status = PutData(tk, 24)) != TK_Normal)
193  return status;
194  m_stage++;
195 
196  }
197 
198  case 4: {
199  if (Tagging (tk))
200  status = Tag (tk);
201 
202  m_stage = -1;
203  } break;
204 
205  default:
206  return tk.Error();
207  }
208 
209  return status;
210  }
211 };
212 #endif
213 
214 bool HW3D_Read_W3D_File(DWFInputStream * input_stream,
215  void * pModelSection,
216  HW3DCamera * ret_initial_camera,
217  bool importMetaData);
218 
219 
220 bool generate_object_definitions(std::map<HC_KEY, int> const & tk_map,
221  HC_KEY key,
222  void * arg1,
223  void * arg2
224  );
225 #define W3D_READ_BUFFER_SIZE 16*1024
226 
227 #endif // _HDWFSTREAM_H
228 
229 
HW3DPoint(HW3DPoint const *p)
Definition: HW3DStream.h:35
char projection[128]
projection type
Definition: HW3DStream.h:59
HW3DPoint(float X, float Y, float Z=0.0f)
Definition: HW3DStream.h:33
void Set(float X, float Y, float Z=0.0f)
Definition: HW3DStream.h:40
HW3DPoint position
position
Definition: HW3DStream.h:54
HW3DPoint()
Definition: HW3DStream.h:31
float field_height
field height
Definition: HW3DStream.h:58
Definition: HW3DStream.h:51
float y
The y-coordinate of a 3-dimensional point.
Definition: HW3DStream.h:27
void Set(const HW3DPoint &p)
Definition: HW3DStream.h:48
Definition: HW3DStream.h:62
Definition: HW3DStream.h:23
void Set(HW3DPoint &p)
Definition: HW3DStream.h:46
float x
The x-coordinate of a 3-dimensional point.
Definition: HW3DStream.h:26
bool is_valid
is data valid
Definition: HW3DStream.h:53
float z
The z-coordinate of a 3-dimensional point.
Definition: HW3DStream.h:28
float field_width
field width
Definition: HW3DStream.h:57
HW3DPoint up_vector
up_vector
Definition: HW3DStream.h:56
void Set(HW3DPoint const *p)
Definition: HW3DStream.h:44
HW3DPoint target
target
Definition: HW3DStream.h:55
void Set(HW3DPoint *p)
Definition: HW3DStream.h:42
HW3DPoint(const HW3DPoint &p)
Definition: HW3DStream.h:37