-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGe.c
392 lines (336 loc) · 14.9 KB
/
Ge.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
/****************************************************************************************/
/* GE.c */
/* */
/* Author: John Pollard */
/* Description: Old interface to engine (REMOVE???) */
/* */
/* The contents of this file are subject to the Genesis3D Public License */
/* Version 1.01 (the "License"); you may not use this file except in */
/* compliance with the License. You may obtain a copy of the License at */
/* http://www.genesis3d.com */
/* */
/* Software distributed under the License is distributed on an "AS IS" */
/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */
/* the License for the specific language governing rights and limitations */
/* under the License. */
/* */
/* The Original Code is Genesis3D, released March 25, 1999. */
/*Genesis3D Version 1.1 released November 15, 1999 */
/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */
/* */
/****************************************************************************************/
#include <Windows.h>
#include <Math.h>
#include <Assert.h>
#include "Genesis.H"
#include "System.h"
#include "Ram.h"
//#include "Sound.h"
//#include "Sound3d.h"
#include "World.h"
#include "Surface.h"
//#include "Camera.h"
#include "Light.h"
#include "Plane.h"
#include "Entities.h"
#include "Trace.h"
#include "User.h"
//#include "Host.h"
#include "Motion.h"
#include "Vis.h"
//=====================================================================================
// local static globals
//=====================================================================================
static geEngine *CEngine; // The current engine object
static char *geTag="Eclipse!";
//=====================================================================================
// local static function prototypes
//=====================================================================================
geBoolean geEngine_SetWorld(geEngine *Engine, geWorld *World);
//=====================================================================================
// Engine
//=====================================================================================
//=====================================================================================
// geEngine_CreateWithVersion
//=====================================================================================
GENESISAPI geEngine *geEngine_CreateWithVersion(HWND hWnd, const char *AppName, const char *DriverDirectory, uint32 Version)
{
assert(AppName != NULL);
//
// Initialize the engine level resources
//
return Sys_EngineCreate(hWnd, AppName, DriverDirectory, Version);
}
//=====================================================================================
// geEngine_Free
//=====================================================================================
GENESISAPI void geEngine_Free(geEngine *Engine)
{
Sys_EngineFree(Engine);
}
//=====================================================================================
// geEngine_FillRect
//=====================================================================================
GENESISAPI void geEngine_FillRect(geEngine *Engine, const GE_Rect *Rect, const GE_RGBA *Color)
{
User_EngineFillRect(Engine, Rect, Color);
}
//=====================================================================================
// GE_ScreenShot
//=====================================================================================
GENESISAPI geBoolean geEngine_ScreenShot(geEngine *Engine, const char *FileName)
{
assert(Engine);
return Engine->DriverInfo.RDriver->ScreenShot(FileName);
}
//=====================================================================================
// geEngine_EnabledFrameRateCounter
//=====================================================================================
GENESISAPI void geEngine_EnableFrameRateCounter(geEngine *Engine, geBoolean Enabled)
{
assert(Engine);
Engine->DisplayFrameRateCounter = Enabled;
}
//=====================================================================================
// Sound
//=====================================================================================
//========================================================================================
// Camera
//========================================================================================
#ifdef MESHES
//========================================================================================
// geWorld_CreateMesh
// Create a mesh definition object
//========================================================================================
GENESISAPI geMesh_Def *geWorld_CreateMesh(geWorld *World, const char *BitmapPath, const char *FileName)
{
assert(World != NULL);
assert(FileName != NULL);
return (geMesh_Def*)Sys_WorldCreateMesh(World, BitmapPath, FileName);
}
//========================================================================================
// geWorld_FreeMesh
//========================================================================================
GENESISAPI void geWorld_FreeMesh(geWorld *World, geMesh_Def *MeshDef)
{
assert(World != NULL);
assert(MeshDef != NULL);
Sys_WorldFreeMesh(World,(Mesh_MeshDef*)MeshDef);
}
//========================================================================================
// geWorld_AddMesh
//========================================================================================
GENESISAPI geMesh *geWorld_AddMesh(geWorld *World, geMesh_Def *MeshDef, uint32 Flags, uint32 UserFlags)
{
return (geMesh*)Mesh_WorldAddMesh(World,(Mesh_MeshDef*)MeshDef, Flags, UserFlags);
}
//========================================================================================
// geWorld_RemoveMesh
//========================================================================================
GENESISAPI void geWorld_RemoveMesh(geWorld *World, geMesh *Mesh)
{
assert(World != NULL);
assert(Mesh!= NULL);
Mesh_WorldRemoveMesh(World, (Mesh_RenderQ*)Mesh);
}
//========================================================================================
// geWorld_SetMeshXForm
//========================================================================================
GENESISAPI geBoolean geWorld_SetMeshXForm(geWorld *World, geMesh *Mesh, const geXForm3d *XForm)
{
assert(World != NULL);
assert(Mesh!= NULL);
assert(XForm != NULL);
return Mesh_SetMeshXForm((Mesh_RenderQ*)Mesh, XForm);
}
//========================================================================================
// geWorld_SetMeshFrame
//========================================================================================
GENESISAPI geBoolean geWorld_SetMeshFrame(geWorld *World, geMesh *Mesh, int32 Frame)
{
assert(World != NULL);
assert(Mesh!= NULL);
return Mesh_SetMeshFrame((Mesh_RenderQ*)Mesh, Frame);
}
//========================================================================================
// geWorld_GetMeshBox
//========================================================================================
GENESISAPI geBoolean geWorld_GetMeshBox(geWorld *World, geMesh_Def *MeshDef, geVec3d *Mins, geVec3d *Maxs)
{
assert (World != NULL);
assert (MeshDef != NULL);
assert (Mins != NULL);
assert (Maxs != NULL);
return Mesh_MeshGetBox(World,(Mesh_MeshDef*)MeshDef, Mins, Maxs);
}
//========================================================================================
// geWorld_GetMeshFrameCount
//========================================================================================
GENESISAPI int geWorld_GetMeshFrameCount(const geWorld *World, const geMesh *Mesh)
{
Mesh_RenderQ * mesh;
mesh = (Mesh_RenderQ *)Mesh;
assert(mesh);
assert(mesh->MeshDef);
return (int)mesh->MeshDef->NumFrames;
}
#endif
#if 0
//========================================================================================
// geWorld_SetModelXForm
//========================================================================================
GENESISAPI geBoolean geWorld_SetModelXForm(geWorld *World, geWorld_Model *Model, const geXForm3d *XForm)
{
return World_SetModelXForm(World, Model, XForm);
}
GENESISAPI geBoolean geWorld_ModelMotionGetTimeExtents(
const GE_ModelMotion * M,
GE_TimeType * StartTime,
GE_TimeType * EndTime)
{
return geMotion_GetTimeExtents((const geMotion *)M, StartTime, EndTime);
}
GENESISAPI GE_ModelMotion *geWorld_ModelGetMotion(geWorld_Model *Model)
{
return (GE_ModelMotion *)World_ModelGetMotion(Model);
}
GENESISAPI void geWorld_ModelMotionSample(
GE_ModelMotion * M,
GE_TimeType Time,
geXForm3d * XForm)
{
gePath * P;
P = geMotion_GetPath((const geMotion *)M, 0);
assert(P);
gePath_Sample(P, Time, XForm);
}
GENESISAPI void * geWorld_ModelGetUserData(const geWorld_Model *Model)
{
return World_ModelGetUserData(Model);
}
GENESISAPI void geWorld_ModelSetUserData(geWorld_Model *Model, void *UserData)
{
World_ModelSetUserData(Model, UserData);
}
#endif
//========================================================================================
// geWorld_AddLight
//========================================================================================
GENESISAPI geLight *geWorld_AddLight(geWorld *World)
{
assert(World != NULL);
return (geLight*)Light_WorldAddLight(World);
}
//========================================================================================
// geWorld_RemoveLight
//========================================================================================
GENESISAPI void geWorld_RemoveLight(geWorld *World, geLight *Light)
{
assert(World != NULL);
assert(Light != NULL);
Light_WorldRemoveLight(World, (Light_DLight*)Light);
}
//========================================================================================
// geWorld_SetLightAttributes
//========================================================================================
GENESISAPI geBoolean geWorld_SetLightAttributes( geWorld *World,
geLight *Light,
const geVec3d *Pos,
const GE_RGBA *RGBA,
geFloat Radius,
geBoolean CastShadow)
{
assert(World != NULL);
assert(Light != NULL);
assert(Pos != NULL);
assert(RGBA != NULL);
return Light_SetAttributes((Light_DLight*)Light, Pos, RGBA, Radius, CastShadow);
}
//========================================================================================
// geWorld_SetLTypeTable
//========================================================================================
GENESISAPI geBoolean geWorld_SetLTypeTable(geWorld *World, int32 LType, const char *Table)
{
assert(World != NULL);
assert(Table != NULL);
return Light_WorldSetLTypeTable(World, LType, Table);
}
// added QuestOfDreams DSpotLight
//========================================================================================
// geWorld_SetSpotLightAttributes
//========================================================================================
GENESISAPI geBoolean geWorld_SetSpotLightAttributes( geWorld *World,
geLight *Light,
const geVec3d *Pos,
const GE_RGBA *RGBA,
geFloat Radius,
geFloat Arc,
const geVec3d *Angles,
int Style,
geBoolean CastShadow)
{
assert(World != NULL);
assert(Light != NULL);
assert(Pos != NULL);
assert(RGBA != NULL);
assert(Angles != NULL);
return Light_SetSpotAttributes((Light_DLight*)Light, Pos, RGBA, Radius, Arc, Angles, Style, CastShadow);
}
// end change QuestOfDreams
//========================================================================================
// geWorld_TestModelMove
//========================================================================================
GENESISAPI geBoolean geWorld_TestModelMove( geWorld *World,
geWorld_Model *Model,
const geXForm3d *DXForm,
const geVec3d *Mins, const geVec3d *Maxs,
const geVec3d *In, geVec3d *Out)
{
return Trace_TestModelMove( World, Model, DXForm,
Mins, Maxs,
In, Out);
}
//========================================================================================
// geWorld_ModelCollision
//========================================================================================
GENESISAPI geBoolean geWorld_ModelCollision(geWorld *World,
geWorld_Model *Model,
const geXForm3d *DXForm,
GE_Collision *Collision)
{
Collision->Mesh = NULL;
Collision->Actor = NULL;
Collision->Model = NULL;
return Trace_ModelCollision(World,
Model,
DXForm,
Collision,
//&(Mesh_RenderQ *)Collision->Mesh,
&Collision->Impact);
}
//========================================================================================
// geWorld_Collision
//========================================================================================
GENESISAPI geBoolean geWorld_Collision(geWorld *World, const geVec3d *Mins, const geVec3d *Maxs, const geVec3d *Front, const geVec3d *Back, uint32 Contents, uint32 CollideFlags, uint32 UserFlags, GE_CollisionCB *CollisionCB, void *Context, GE_Collision *Col)
{
return Trace_GEWorldCollision(World, Mins, Maxs, Front, Back, Contents, CollideFlags, UserFlags, CollisionCB, Context, Col);
}
//========================================================================================
// geWorld_GetContents
//========================================================================================
GENESISAPI geBoolean geWorld_GetContents(geWorld *World, const geVec3d *Pos, const geVec3d *Mins, const geVec3d *Maxs, uint32 Flags, uint32 UserFlags, GE_CollisionCB *CollisionCB, void *Context, GE_Contents *Contents)
{
return Trace_GetContents(World, Pos, Mins, Maxs, Flags, UserFlags, CollisionCB, Context, Contents);
}
// changed texture name
//========================================================================================
// geWorld_GetContents
//========================================================================================
GENESISAPI geBoolean geWorld_GetTextureName(geWorld *World, const geVec3d *Pos, const geVec3d *Mins, const geVec3d *Maxs, char *TexName)
{
return Trace_GetTexureName(World, Pos, Mins, Maxs, TexName);
}
// end change texture name
//========================================================================================
// NetPlay
//========================================================================================