\r
//#define OLD_FONT\r
\r
-#include "ErrorLog.h"\r
-#include "Genesis.h"\r
+#include "include/ErrorLog.h"\r
+#include "include/Genesis.h"\r
#include <windows.h>\r
-#include "dcommon.h"\r
-#include "Camera.h"\r
+#include "G3D/Engine/Drivers/DCommon.h"\r
+#include "G3D/Camera.h"\r
#include "PtrTypes.h"\r
\r
#define VectorToSUB(a, b) ( *(((geFloat*)&a) + b) )\r
//#include "Sound.h"\r
//#include "Sound3d.h"\r
\r
-#include "World.h"\r
+#include "World/World.h"\r
#include "Surface.h"\r
//#include "Camera.h"\r
#include "Light.h"\r
+++ /dev/null
-/****************************************************************************************/\r
-/* PtrTypes.c */\r
-/* */\r
-/* Description: File to resolve interdependency problems */\r
-/* */\r
-/* The contents of this file are subject to the Genesis3D Public License */\r
-/* Version 1.01 (the "License"); you may not use this file except in */\r
-/* compliance with the License. You may obtain a copy of the License at */\r
-/* http://www.genesis3d.com */\r
-/* */\r
-/* Software distributed under the License is distributed on an "AS IS" */\r
-/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */\r
-/* the License for the specific language governing rights and limitations */\r
-/* under the License. */\r
-/* */\r
-/* The Original Code is Genesis3D, released March 25, 1999. */\r
-/* Genesis3D Version 1.1 released November 15, 1999 */\r
-/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */\r
-/* */\r
-/****************************************************************************************/\r
-\r
-#ifndef GE_PTRTYPES_H\r
-#define GE_PTRTYPES_H\r
-\r
-#include "BaseType.h"\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-// System.h\r
-typedef struct geEngine geEngine;\r
-\r
-// Light.h\r
-typedef struct Light_LightInfo Light_LightInfo;\r
-\r
-// Surface.h\r
-typedef struct Surf_SurfInfo Surf_SurfInfo;\r
-typedef struct Surf_TexVert Surf_TexVert;\r
-\r
-// World.h\r
-typedef struct geWorld geWorld;\r
-\r
-// Frustum.h\r
-typedef struct Frustum_Info Frustum_Info;\r
-\r
-// World.h\r
-typedef struct World_BSP World_BSP;\r
-typedef struct geWorld_Leaf geWorld_Leaf;\r
-\r
- \r
-// Mesh.h\r
-typedef struct Mesh_MeshInfo Mesh_MeshInfo;\r
-typedef struct Mesh_MeshDef Mesh_MeshDef;\r
-typedef struct Mesh_RenderQ Mesh_RenderQ;\r
-\r
-// Entities.h\r
-typedef struct geEntity_EntitySet geEntity_EntitySet;\r
-\r
-// User.h\r
-typedef struct User_Info User_Info;\r
-typedef struct gePoly gePoly;\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif\r
#ifndef GE_GBSPFILE_H\r
#define GE_GBSPFILE_H\r
\r
-#include <Stdio.h>\r
+#include <stdio.h>\r
\r
-#include "BaseType.h"\r
-#include "Vec3d.h"\r
+#include "include/BaseType.h"\r
+#include "include/Vec3d.h"\r
#include <windows.h>\r
#include "DCommon.h"\r
-#include "VFile.h"\r
-#include "Motion.h"\r
+#include "include/VFile.h"\r
+#include "include/Motion.h"\r
\r
#ifdef __cplusplus\r
extern "C" {\r
}\r
#endif\r
\r
-#endif
\ No newline at end of file
+#endif\r
#ifndef GE_WORLD_H\r
#define GE_WORLD_H\r
\r
-#include "ErrorLog.h"\r
+#include "include/ErrorLog.h"\r
#include "PtrTypes.h"\r
-#include "Genesis.h"\r
+#include "include/Genesis.h"\r
#include "GBSPFile.h"\r
-#include "Motion.h"\r
+#include "include/Motion.h"\r
#include "Surface.h"\r
#include "Fog.h"\r
#include "WBitmap.h"\r
\r
#include "Bitmaplist.h"\r
\r
-#include "Actor.h" \r
+#include "include/Actor.h"\r
\r
//MRB BEGIN\r
//geSprite\r
-#include "Sprite.h"\r
+#include "include/Sprite.h"\r
//MRB END \r
\r
#ifdef __cplusplus\r
+++ /dev/null
-#ifndef BITMAP_H\r
-#define BITMAP_H\r
-\r
-/****************************************************************************************/\r
-/* Bitmap.h */\r
-/* */\r
-/* Author: Charles Bloom */\r
-/* Description: Abstract Bitmap system */\r
-/* */\r
-/* The contents of this file are subject to the Genesis3D Public License */\r
-/* Version 1.01 (the "License"); you may not use this file except in */\r
-/* compliance with the License. You may obtain a copy of the License at */\r
-/* http://www.genesis3d.com */\r
-/* */\r
-/* Software distributed under the License is distributed on an "AS IS" */\r
-/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */\r
-/* the License for the specific language governing rights and limitations */\r
-/* under the License. */\r
-/* */\r
-/* The Original Code is Genesis3D, released March 25, 1999. */\r
-/* Genesis3D Version 1.1 released November 15, 1999 */\r
-/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */\r
-/* */\r
-/****************************************************************************************/\r
-\r
-#include "basetype.h"\r
-#include "pixelformat.h"\r
-#include "vfile.h"\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-/***********************************************************************************/\r
-\r
-typedef struct geBitmap geBitmap;\r
-typedef struct geBitmap_Palette geBitmap_Palette;\r
-\r
-typedef struct geBitmap_Info\r
-{\r
- int Width;\r
- int Height;\r
- int Stride; // stride is in *pixels* ; it is the step to the next line : Stride >= Width\r
- gePixelFormat Format;\r
- int MinimumMip; //*including* minimumMip == 0 often\r
- int MaximumMip; //*including* maximumMip == nummips-1\r
- geBoolean HasColorKey;\r
- uint32 ColorKey; // meaningless unless HasColorKey ; the ColorKey is a Pixel in Format\r
- geBitmap_Palette * Palette;\r
-} geBitmap_Info;\r
-\r
-/***********************************************************************************/ \r
-// Bitmap methods\r
-\r
-// see a big comment at the end of this file\r
-\r
-/************************************************************************/\r
-\r
-GENESISAPI geBitmap * GENESISCC geBitmap_Create(int Width, int Height, int MipCount, gePixelFormat Format ); \r
-GENESISAPI void GENESISCC geBitmap_CreateRef(geBitmap *Bmp);\r
-\r
-GENESISAPI geBitmap * GENESISCC geBitmap_CreateFromInfo(const geBitmap_Info * pInfo);\r
-\r
-GENESISAPI geBitmap * GENESISCC geBitmap_CreateFromFile( geVFile *F );\r
-GENESISAPI geBitmap * GENESISCC geBitmap_CreateFromFileName(const geVFile *BaseFS,const char *Name);\r
-GENESISAPI geBoolean GENESISCC geBitmap_WriteToFile( const geBitmap *Bmp, geVFile *F );\r
-GENESISAPI geBoolean GENESISCC geBitmap_WriteToFileName(const geBitmap * Bmp,const geVFile *BaseFS,const char *Name);\r
- // BaseFS is not really const if it is a virtual file;\r
- // it *is* const if it is a dos directory\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_Destroy(geBitmap **Bmp);\r
- // returns whether Bmp was actually destroyed : not success/failure\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_GetInfo(const geBitmap *Bmp, geBitmap_Info *Info, geBitmap_Info *SecondaryInfo);\r
- //LockForWrite returns data in Info's format\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_Blit(const geBitmap *Src, int SrcPositionX, int SrcPositionY,\r
- geBitmap *Dst, int DstPositionX, int DstPositionY,\r
- int SizeX, int SizeY );\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_BlitMip(const geBitmap * Src, int SrcMip, geBitmap * Dst, int DstMip );\r
- // don't use this with Src == Dst, use UpdateMips instead !\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_BlitBitmap(const geBitmap * Src, geBitmap * Dst);\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_BlitBestMip(const geBitmap * Src, geBitmap * Dst);\r
- // blits the largest mip from Src that fits in Dst\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_LockForRead( // a non-exclusive lock\r
- const geBitmap * Bmp,\r
- geBitmap ** Target,\r
- int MinimumMip,\r
- int MaximumMip,\r
- gePixelFormat Format,\r
- geBoolean RespectColorKey,\r
- uint32 ColorKey);\r
- // not really const, stores lock-count, but *data* is const\r
- // will do a format conversion!\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_LockForReadNative(\r
- const geBitmap * Bmp,\r
- geBitmap ** Target,\r
- int MinimumMip,\r
- int MaximumMip);\r
- // lock for read in a format that gaurantee no conversions\r
- // then do GetInfo on the locks to see what you have!\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_LockForWrite( // an exclusive lock\r
- geBitmap * Bmp,\r
- geBitmap ** Target,\r
- int MinimumMip,\r
- int MaximumMip);\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_LockForWriteFormat(\r
- geBitmap * Bmp,\r
- geBitmap ** Target,\r
- int MinimumMip,\r
- int MaximumMip,\r
- gePixelFormat Format);\r
- // Format must be one of the two returned in GetInfo !!\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_UnLock(geBitmap *Bmp); // must be done on All locked mips\r
-GENESISAPI geBoolean GENESISCC geBitmap_UnLockArray(geBitmap **Locks,int Size);\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_SetFormat(geBitmap *Bmp, \r
- gePixelFormat NewFormat, \r
- geBoolean RespectColorKey, uint32 ColorKey,\r
- const geBitmap_Palette * Palette);\r
- // _SetFormat may cause you to lose color information!\r
- // SetFormat does a conversion!\r
- // if NewFormat is palettized and Palette is NULL, we create a palette for the bitmap!\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_SetFormatMin(geBitmap *Bmp,gePixelFormat NewFormat);\r
- // the Min version keeps colorkey & palette from the old format\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_SetColorKey(geBitmap *Bmp, geBoolean HasColorKey, uint32 ColorKey, geBoolean Smart);\r
- // SetColorKey discards old colorkey information!\r
- // does not do a conversion (changes the colorkey in the current data\r
- // if 'Smart' is on, we don't set HasColorKey to true unless it is actually used!\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_GetAverageColor(const geBitmap *Bmp,int *pR,int *pG,int *pB);\r
- // tells you the average color; computes it and caches it out\r
-\r
-GENESISAPI geBitmap_Palette * GENESISCC geBitmap_GetPalette(const geBitmap *Bmp);\r
-GENESISAPI geBoolean GENESISCC geBitmap_SetPalette(geBitmap *Bmp, const geBitmap_Palette *Palette);\r
- // _SetPal tries to _CreateRef your Palette, so no copy occurs & palettes may be shared\r
- // you may _Destroy() palette after using it to set (though its bits may not be freed)\r
- // (hence Palette is *not* const)\r
- // Warning : SetPalette on any mip changes the palette of ALL mips !\r
- // see Palette note at _UnLock\r
- // _SetPal destroys the bitmap's original palette and refs the new one, \r
- // so if you setpal with the bitmap's palette, there is no net change in ref counts (good!)\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_HasAlpha(const geBitmap * Bmp);\r
- // returns true if bitmap has *any* type of alpha\r
-\r
-GENESISAPI geBitmap * GENESISCC geBitmap_GetAlpha(const geBitmap *Bmp);\r
-GENESISAPI geBoolean GENESISCC geBitmap_SetAlpha(geBitmap *Bmp, const geBitmap *AlphaBmp);\r
- // we Ref the AlphaBmp, so you may destroy it after calling Set()\r
- // it may be NULL\r
- // there's only one Alpha per bitmap (for the top Mip) right now\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_SetGammaCorrection(geBitmap *Bmp,geFloat Gamma,geBoolean Apply);\r
- // this Gamma does not change the *original* (system/secondary) bits\r
- // it only affects the appearance when drawn\r
- // note : if you write to the gamma corrected bits, you must gamma correct manually if you\r
- // wish to fit in smoothly with the previous data\r
- // warning : if you use this function with many different gammas, performance will suffer!\r
- // use one global gamma for all bitmaps! try to let the engine manage gamma for you,\r
- // via geEngine_SetGamma !\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_SetPreferredFormat(geBitmap *Bmp,gePixelFormat Format);\r
-GENESISAPI gePixelFormat GENESISCC geBitmap_GetPreferredFormat(const geBitmap *Bmp);\r
-\r
-GENESISAPI void * GENESISCC geBitmap_GetBits(geBitmap *Bmp); // works only on a Lock()\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_RefreshMips(geBitmap *Bmp); // rebuilds mips; *tries* to be smart & not overwrite manually-fixed mips\r
- // RefreshMips does *not* build mips that don't exist\r
-GENESISAPI geBoolean GENESISCC geBitmap_UpdateMips(geBitmap *Bmp,int SourceMip,int TargetMip); \r
- // will create the target if it doesn't exist;\r
- // will overwrite manually-fixed mips!\r
-GENESISAPI geBoolean GENESISCC geBitmap_SetMipCount(geBitmap *Bmp,int Count);\r
- // creates or destroys to match the new count\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_ClearMips(geBitmap *Bmp); // Destroy all mips (except the first) !\r
- // use with care! this is not polite!\r
-\r
-// Shortcuts\r
-GENESISAPI int GENESISCC geBitmap_Width(const geBitmap *Bitmap);\r
-GENESISAPI int GENESISCC geBitmap_Height(const geBitmap *Bitmap);\r
-GENESISAPI uint32 GENESISCC geBitmap_MipBytes(const geBitmap * Bitmap,int mip);\r
-\r
-/**\r
-*\r
-* if Bitmap is a lock for read, functions that modify it return failure\r
-* if Bitmap is a lock for write, functions that modify it attempt to\r
-* modify the owner of the lock\r
-*\r
-* warning : if you lock multiple mips for write, and then modify one of the mips\r
-* (such as via SetPalette) it may affect the owner and all sibling mips!\r
-* doing different SetPalettes with different palettes on different locked mips \r
-* has undefined behavior!\r
-*\r
-**/\r
-\r
-#ifdef _DEBUG\r
-\r
-GENESISAPI uint32 GENESISCC geBitmap_Debug_GetCount(void);\r
-\r
-GENESISAPI uint32 GENESISCC geBitmap_Debug_GetRefs(void);\r
- // assert this is zero before you shutdown !\r
-\r
-#endif\r
-\r
-/***********************************************************************************/\r
-\r
-typedef enum\r
-{\r
- GE_BITMAP_STREAMING_ERROR=0,\r
- GE_BITMAP_STREAMING_NOT,\r
- GE_BITMAP_STREAMING_STARTED,\r
- GE_BITMAP_STREAMING_IDLE,\r
- GE_BITMAP_STREAMING_CHANGED,\r
- GE_BITMAP_STREAMING_DATADONE,\r
- GE_BITMAP_STREAMING_DONE,\r
-} geBitmap_StreamingStatus;\r
-\r
-GENESISAPI geBitmap_StreamingStatus GENESISCC geBitmap_GetStreamingStatus(const geBitmap *Bmp);\r
-\r
- /** on a file which is streaming, the sequence of returns looks like :\r
-\r
- GE_BITMAP_STREAMING_IDLE\r
- GE_BITMAP_STREAMING_CHANGED\r
- GE_BITMAP_STREAMING_IDLE\r
- GE_BITMAP_STREAMING_IDLE\r
- GE_BITMAP_STREAMING_CHANGED\r
- ...\r
- GE_BITMAP_STREAMING_DONE\r
- GE_BITMAP_STREAMING_NOT\r
- GE_BITMAP_STREAMING_NOT\r
- GE_BITMAP_STREAMING_NOT\r
- ...\r
-\r
- Status >= GE_BITMAP_STREAMING_STARTED means streaming has started & is in progress\r
-\r
- the user should never see _STARTED or _DATADONE\r
-\r
- ***/\r
-\r
-/***********************************************************************************/\r
-\r
-// palette methods :\r
-\r
-GENESISAPI geBitmap_Palette * GENESISCC geBitmap_Palette_Create(gePixelFormat Format,int Size);\r
-\r
-GENESISAPI geBitmap_Palette * GENESISCC geBitmap_Palette_CreateCopy(const geBitmap_Palette *Palette);\r
-\r
-GENESISAPI geBitmap_Palette * GENESISCC geBitmap_Palette_CreateFromFile(geVFile *F);\r
-\r
-GENESISAPI geBitmap_Palette * GENESISCC geBitmap_Palette_CreateFromBitmap(geBitmap * Bmp,geBoolean Slow);\r
- // does GetPalette, and if NULL, then\r
- // it create an optimal palette for a\r
- // non-palettized bitmap\r
- // (this is a create, you must destroy later!)\r
- // put Slow == TRUE for higher quality & slower\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_SortColors(geBitmap_Palette * P,geBoolean Slower);\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_CreateRef(geBitmap_Palette *Palette);\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_Destroy(geBitmap_Palette ** ppPalette);\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_WriteToFile(const geBitmap_Palette *Palette,geVFile *F);\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_SetFormat(geBitmap_Palette * Palette,gePixelFormat Format);\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_Copy(const geBitmap_Palette * Src,geBitmap_Palette * Target);\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_GetInfo(const geBitmap_Palette *P,geBitmap_Info *Into);\r
- // get the info as if it were a bitmap; Into->Height == 1\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_Lock(geBitmap_Palette *Palette, void **pBits, gePixelFormat *pFormat,int *pSize);\r
- // pFormat & pSize are optional\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_UnLock(geBitmap_Palette *Palette);\r
- // palette unlock does NOT notify the bitmap that the palette has changed.\r
- // call Bitmap_SetPalette() with the same palette pointer \r
- // to tell the bitmap that it must to some processing\r
- // (don't worry, it won't duplicate it or copy it onto itself)\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_GetData(const geBitmap_Palette *P, void *Into,gePixelFormat Format,int Colors);\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_SetData( geBitmap_Palette *P,const void *From,gePixelFormat Format,int Colors);\r
- // does Lock/UnLock for you\r
- // From and Into are arrays of Colors*gePixelFormat_BytesPerPel bytes\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_SetEntryColor( geBitmap_Palette *P,int Color,int R,int G,int B,int A);\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_GetEntryColor(const geBitmap_Palette *P,int Color,int *R,int *G,int *B,int *A);\r
- // Set/Get does Lock/Unlock for you ; these are slow! do not use these to work on all the colors!\r
-\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_SetEntry( geBitmap_Palette *P,int Color,uint32 Pixel);\r
-GENESISAPI geBoolean GENESISCC geBitmap_Palette_GetEntry(const geBitmap_Palette *P,int Color,uint32 *Pixel);\r
-\r
-/***********************************************************************************/\r
-\r
-/************************************************************************\r
-\r
-A brief tutorial on the Bitmap system, by Charles Bloom, cbloom@wildtangent.com\r
-\r
-The Bitmap is a smart wrapper for complex functionality. You give it hints to\r
-the opaque Bitmap object, and it tries its best to follow those hints, but it\r
-may not always do so. The Bitmap is the owner of its bits; you must Lock the\r
-bitmap to get permission to touch those bits, and UnLock to tell the bitmap\r
-you are done. The format may change between two Locks. Bitmaps can also be\r
-multiply owned, so you should account for the fact that others may touch your\r
-bitmap between your uses.\r
-\r
-The Bitmap contains one or two pixel-sets representing an image. The "primary" is\r
-a fast-blitting version of the image, and the "secondary" is a storage version\r
-(eventually wavelet compressed) which can be used to rebuild the primary if it is\r
-freed or damaged. Both cary a generalized format.\r
-\r
-Let's do an example. I want to load a bitmap, set it up for drawing with the\r
-genesis Engine, and then blit some interactive stuff into it.\r
-\r
-************************************************************************/\r
-\r
-#if 0\r
-// {\r
-//-----------------------------------------------------------------------------\r
-\r
-void Init(geEngine * Engine);\r
-void Shutdown(void);\r
-void Draw(void);\r
-void DrawPolite(void);\r
-\r
-static geBitmap * myBM = NULL;\r
-static geEngine * myEngine = NULL;\r
-\r
-void Init(geEngine * Engine)\r
-{\r
-geBoolean success;\r
-geBitmap_Info Info;\r
-\r
- myEngine = Engine; // this is not looked well upon; for ease of demonstration only!\r
- assert(Engine);\r
-\r
- myBM = geBitmap_CreateFromFileName(NULL,"mybitmap.bmp");\r
-\r
- // CreateFromFile can load windows BMP files, or custom GeBm files.\r
-\r
- assert(myBM);\r
-\r
- // get the main info; I don't care about the secondary, so leave it NULL\r
-\r
- success = geBitmap_GetInfo(myBM,&Info,NULL);\r
- assert(success);\r
-\r
- // make sure I loaded a bitmap in the format I understand !\r
-\r
- if ( Info.Format == GE_PIXELFORMAT_8BIT_PAL )\r
- {\r
- // I want palette index 255 to act as transparency, so I must use SetColorKey\r
-\r
- success = geBitmap_SetColorKey(myBM,GE_TRUE,255);\r
- assert(success);\r
-\r
- // just for fun, let's modify the palette:\r
- if (1)\r
- {\r
- geBitmap_Palette * Pal;\r
-\r
- // get the palette ; I don't care if its primary or secondary, so\r
- /// I don't use the Info.Palette field\r
-\r
- Pal = geBitmap_GetPalette(myBM);\r
- assert(Pal);\r
-\r
- // I'm only fiddling one entry, so don't bother with a full Lock() UnLock()\r
- // sequence on the palette\r
-\r
- // make palette index zero bright red; we use alpha = 255 for opaque\r
-\r
- success = geBitmap_Palette_SetEntryColor(Pal,0,255,0,0,255);\r
- assert(success);\r
-\r
- // tell the bitmap system you've changed the palette; this function\r
- // is smart enough to not do unecessary copies or whatever.\r
-\r
- success = geBitmap_SetPalette(myBM,Pal);\r
- assert(success);\r
- }\r
-\r
- }\r
- else\r
- {\r
- // otherwise, treat black as transparent, in whatever format I have\r
-\r
- success = geBitmap_SetColorKey(myBM,GE_TRUE,gePixelFormat_ComposePixel(Info.Format,0,0,0,0));\r
- assert(success);\r
- } \r
-\r
- // note that I did NOT use SetFormat. SetFormat may do a conversion, and since the original\r
- // bitmap was created without colorkey, it would have been converted to a new format but\r
- // kept its property of having no colorkey!\r
- // (SetFormat will fiddle the bits and whatever way necessary to keep bitmaps as visually similar\r
- // as possible)\r
-\r
- // I want to fiddle the fast format in 565 later, so cue the bitmap to try to give me that format.\r
-\r
- success = geBitmap_SetPreferredFormat(myBM,GE_PIXELFORMAT_16BIT_565_RGB);\r
- assert(success);\r
-\r
- // Add it to the engine so it can be used for drawing.\r
-\r
- success = geEngine_AddBitmap(myEngine,myBM);\r
- assert(success);\r
-}\r
-\r
-void Shutdown(void)\r
-{\r
-geBoolean WasDestroyed;\r
-\r
- assert(myBM);\r
- \r
- // clean up\r
-\r
- geEngine_RemoveBitmap(myEngine,myBM);\r
-\r
- WasDestroyed = geBitmap_Destroy(&myBM);\r
-\r
- // someone else might have done _CreateRef on our bitmap,\r
- // so we can't be sure it's actually destroyed.\r
- // this code is still ready to be run again with a new call to Init()\r
-\r
- //assert(WasDestroyed);\r
-\r
- myBM = NULL;\r
- myEngine = NULL;\r
-}\r
-\r
-void Draw(void)\r
-{\r
-geBitmap * Lock;\r
-geBoolean success;\r
-geBitmap_Info Info;\r
-uint16 *bits,*bptr;\r
-int x,y;\r
-\r
- // lets fiddle the bits.\r
- // we need to lock the bitmap for write.\r
- // LockForWrite is an exclusive lock, unlike LockForRead which is non-blocking\r
- // request our favorite format, and only lock Mip 0 (the full size bitmap)\r
-\r
- success = geBitmap_LockForWriteFormat(myBM,&Lock,0,0,GE_PIXELFORMAT_16BIT_565_RGB);\r
- if ( ! success )\r
- {\r
- // well, we tried to be nice; if we were very polite, we would do a LockForWrite\r
- // here, and try to fiddle the bits in whatever format we got; However, we aren't\r
- // that polite, so we just do a _SetFormat\r
- //\r
- // note that we are destroying the original bitmap by changing its format\r
- // we should only do this if we are going to draw into the bitmap\r
-\r
- success = geBitmap_SetFormat(myBM,GE_PIXELFORMAT_16BIT_565_RGB,GE_TRUE,0,NULL);\r
- assert(success);\r
-\r
- // now we should be able to get the bits we want, *but* they may not be the\r
- // primary (fast) format; oh well, it's the best we can do...\r
- // (if you must have the fastest bits, then use only _LockForWrite, never LockForWriteFormat,\r
- // which might have to do a conversion)\r
-\r
- success = geBitmap_LockForWriteFormat(myBM,&Lock,0,0,GE_PIXELFORMAT_16BIT_565_RGB);\r
- assert(success);\r
- }\r
-\r
- // now Lock is our bitmap in 565\r
- // we do a GetInfo because the Lock's info could be different than\r
- // the original bitmap's (particularly the Palette & the Stride)\r
-\r
- success = geBitmap_GetInfo(Lock,&Info,NULL);\r
- assert(success);\r
-\r
- // you can only call _GetBits on a locked bitmap\r
-\r
- bits = geBitmap_GetBits(Lock);\r
- assert( bits );\r
-\r
- bptr = bits;\r
- for(y=0; y < Info.Height; y++)\r
- {\r
- for(x=0; x < Info.Width; x++)\r
- {\r
- uint16 R,G,B;\r
- // make a silly 565 gradient\r
- R = x & 0x1F;\r
- G = x & 0x3F;\r
- B = y & 0x1F;\r
-\r
- *bptr++ = (R<<11) + (G<<5) + B;\r
- }\r
-\r
- // note that bptr is a word pointer, and Stride is in pixels :\r
-\r
- bptr += Info.Stride - Info.Width;\r
- }\r
- bits = bptr = NULL;\r
-\r
- // you call Unlock on all the mips you locked - not on the original bitmap!\r
-\r
- success = geBitmap_UnLock(Lock);\r
- assert(success);\r
-\r
- // now, we only fiddled the full-size Mip, and there might be more,\r
- // so lets percolate the changes into the smaller mips:\r
-\r
- success = geBitmap_RefreshMips(myBM);\r
- assert(success);\r
-\r
- // a null rect means use the whole bitmap;\r
- // Engine_DrawBitmap blits a 2d decal to the framebuffer (fast)\r
-\r
- success = geEngine_DrawBitmap(myEngine,myBM,NULL,0,0);\r
- assert(success);\r
-\r
-}\r
-\r
-void DrawPolite(void)\r
-{\r
-geBitmap * Lock;\r
-geBoolean success;\r
-geBitmap_Info Info;\r
-void *bits;\r
-int x,y;\r
-\r
- // this function does the same thing as Draw() , but is more polite\r
- // lock in the fastest format (whatever it is)\r
- // because we did SetPreferred, this should be 565_RGB, but might not be\r
-\r
- success = geBitmap_LockForWrite(myBM,&Lock,0,0);\r
- assert(success);\r
-\r
- success = geBitmap_GetInfo(Lock,&Info,NULL);\r
- assert(success);\r
-\r
- bits = geBitmap_GetBits(Lock);\r
- assert( bits );\r
-\r
- if ( Info.Format == GE_PIXELFORMAT_16BIT_565_RGB )\r
- {\r
- uint16 *wptr;\r
-\r
- // our favorite format\r
-\r
- wptr = bits;\r
- for(y=0; y < Info.Height; y++)\r
- {\r
- for(x=0; x < Info.Width; x++)\r
- {\r
- uint16 R,G,B;\r
- // make a silly 565 gradient\r
- R = x & 0x1F;\r
- G = x & 0x3F;\r
- B = y & 0x1F;\r
-\r
- *wptr++ = (R<<11) + (G<<5) + B;\r
- }\r
- wptr += Info.Stride - Info.Width;\r
- }\r
- }\r
- else\r
- {\r
- uint8 * bptr;\r
-\r
- // oh well, do our best\r
- // bitmaps must have had a good reason to not give us the format we preferred,\r
-\r
- bptr = bits;\r
- for(y=0; y < Info.Height; y++)\r
- {\r
- for(x=0; x < Info.Width; x++)\r
- {\r
- uint32 R,G,B;\r
-\r
- // put a color in any format\r
-\r
- R = (x & 0x1F)<<3;\r
- G = (x & 0x3F)<<2;\r
- B = (y & 0x1F)<<3;\r
-\r
- // we use alpha of 255 for opaque\r
-\r
- gePixelFormat_PutColor(Info.Format,&bptr,R,G,B,255);\r
- }\r
-\r
- bptr += (Info.Stride - Info.Width) * gePixelFormat_BytesPerPel(Info.Format);\r
- }\r
- }\r
- bits = NULL;\r
-\r
- // same as before:\r
-\r
- success = geBitmap_UnLock(Lock);\r
- assert(success);\r
-\r
- success = geBitmap_RefreshMips(myBM);\r
- assert(success);\r
-\r
- success = geEngine_DrawBitmap(myEngine,myBM,NULL,0,0);\r
- assert(success);\r
-\r
-}\r
-\r
-// end tutorial on the Bitmap system\r
-//-----------------------------------------------------------------------------\r
-// }\r
-\r
-/***********************************************************************************/\r
-\r
-#endif\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-\r
-#endif\r
-\r
-\r
+++ /dev/null
-/****************************************************************************************/\r
-/* BODY.H */\r
-/* */\r
-/* Author: Mike Sandige */\r
-/* Description: Actor body interface. */\r
-/* */\r
-/* The contents of this file are subject to the Genesis3D Public License */\r
-/* Version 1.01 (the "License"); you may not use this file except in */\r
-/* compliance with the License. You may obtain a copy of the License at */\r
-/* http://www.genesis3d.com */\r
-/* */\r
-/* Software distributed under the License is distributed on an "AS IS" */\r
-/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */\r
-/* the License for the specific language governing rights and limitations */\r
-/* under the License. */\r
-/* */\r
-/* The Original Code is Genesis3D, released March 25, 1999. */\r
-/* Genesis3D Version 1.1 released November 15, 1999 */\r
-/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */\r
-/* */\r
-/****************************************************************************************/\r
-#ifndef GE_BODY_H\r
-#define GE_BODY_H \r
-\r
-/* This object is for managing the data associated with a skeletal-based mesh, \r
- a 'body'.\r
- This object holds the geometry for the body and the list of materials needed.\r
-*/\r
-\r
-#include "basetype.h"\r
-#include "xform3d.h"\r
-#include "vfile.h"\r
-#include "bitmap.h"\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-#define GE_BODY_NUMBER_OF_LOD (4) // 0 is highest detail\r
-#define GE_BODY_NO_PARENT_BONE (-1) \r
-#define GE_BODY_HIGHEST_LOD (0)\r
-\r
-#define GE_BODY_ROOT (-1) // for specifying 'root' bounding box.\r
-\r
-typedef struct geBody geBody;\r
-\r
-\r
-\r
-geBody *GENESISCC geBody_Create(void);\r
-\r
-void GENESISCC geBody_Destroy(geBody **B);\r
-\r
-geBoolean GENESISCC geBody_IsValid(const geBody *B);\r
-\r
-\r
-geBoolean GENESISCC geBody_GetGeometryStats(const geBody *B, int lod, int *Vertices, int *Faces, int *Normals);\r
-\r
-geBoolean GENESISCC geBody_AddFace( geBody *B,\r
- const geVec3d *Vertex1, const geVec3d *Normal1, \r
- geFloat U1, geFloat V1, int BoneIndex1,\r
- const geVec3d *Vertex2, const geVec3d *Normal2, \r
- geFloat U2, geFloat V2, int BoneIndex2,\r
- const geVec3d *Vertex3, const geVec3d *Normal3, \r
- geFloat U3, geFloat V3, int BoneIndex3,\r
- int MaterialIndex);\r
-\r
- // Bitmap is added to body. It's reference count is increased. Caller still owns a pointer\r
- // to the bitmap, and is responsible for destroying it.\r
-geBoolean GENESISCC geBody_AddMaterial( geBody *B, \r
- const char *MaterialName, \r
- geBitmap *Bitmap,\r
- geFloat Red, \r
- geFloat Green, \r
- geFloat Blue,\r
- int *MaterialIndex);\r
-\r
- // returned bitmap is a pointer to the bitmap in the body's list. It may not be destroyed.\r
- // if caller would like to 'own' a copy of that bitmap pointer, it should call geBitmap_CreateRef()\r
-geBoolean GENESISCC geBody_GetMaterial(const geBody *Body, int MaterialIndex,\r
- const char **MaterialName,\r
- geBitmap **Bitmap, geFloat *Red, geFloat *Green, geFloat *Blue);\r
-\r
- // Bitmap is set into the body. It's reference count is increased. Caller still owns a pointer\r
- // to the bitmap, and is responsible for destroying it.\r
-geBoolean GENESISCC geBody_SetMaterial(geBody *Body, int MaterialIndex,\r
- geBitmap *Bitmap, geFloat Red, geFloat Green, geFloat Blue);\r
-\r
-int GENESISCC geBody_GetMaterialCount(const geBody *B);\r
-\r
-geBoolean GENESISCC geBody_AddBone( geBody *B, \r
- int ParentBoneIndex,\r
- const char *BoneName, \r
- const geXForm3d *AttachmentMatrix,\r
- int *BoneIndex);\r
-\r
-geBoolean GENESISCC geBody_ComputeLevelsOfDetail( geBody *B ,int Levels);\r
-\r
-int GENESISCC geBody_GetBoneCount(const geBody *B);\r
-\r
-void GENESISCC geBody_GetBone( const geBody *B, \r
- int BoneIndex, \r
- const char **BoneName,\r
- geXForm3d *Attachment, \r
- int *ParentBoneIndex);\r
-\r
-int32 GENESISCC geBody_GetBoneNameChecksum(const geBody *B);\r
-\r
-void GENESISCC geBody_SetBoundingBox( geBody *B,\r
- int BoneIndex, // GE_BODY_ROOT for specifing 'root' bounding box.\r
- const geVec3d *MinimumBoxCorner,\r
- const geVec3d *MaximumBoxCorner);\r
- \r
-\r
-geBoolean GENESISCC geBody_GetBoundingBox( const geBody *B, \r
- int BoneIndex, // GE_BODY_ROOT for specifing 'root' bounding box.\r
- geVec3d *MinimumBoxCorner,\r
- geVec3d *MaximumBoxCorner);\r
-\r
-geBoolean GENESISCC geBody_GetBoneByName(const geBody* B,\r
- const char* BoneName,\r
- int* pBoneIndex,\r
- geXForm3d* Attachment,\r
- int* pParentBoneIndex);\r
-\r
-geBoolean GENESISCC geBody_WriteToFile(const geBody *B, geVFile *pFile);\r
-geBody *GENESISCC geBody_CreateFromFile(geVFile *pFile);\r
-\r
-\r
-\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif\r
-
\ No newline at end of file
+++ /dev/null
-/****************************************************************************************/\r
-/* MOTION.H */\r
-/* */\r
-/* Author: Mike Sandige */\r
-/* Description: Motion interface. */\r
-/* */\r
-/* The contents of this file are subject to the Genesis3D Public License */\r
-/* Version 1.01 (the "License"); you may not use this file except in */\r
-/* compliance with the License. You may obtain a copy of the License at */\r
-/* http://www.genesis3d.com */\r
-/* */\r
-/* Software distributed under the License is distributed on an "AS IS" */\r
-/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */\r
-/* the License for the specific language governing rights and limitations */\r
-/* under the License. */\r
-/* */\r
-/* The Original Code is Genesis3D, released March 25, 1999. */\r
-/* Genesis3D Version 1.1 released November 15, 1999 */\r
-/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */\r
-/* */\r
-/****************************************************************************************/\r
-#ifndef GE_MOTION_H\r
-#define GE_MOTION_H\r
-\r
-/* motion\r
-\r
- This object is a list of named Path objects\r
-\r
-*/\r
-\r
-#include <stdio.h>\r
-#include "basetype.h"\r
-#include "path.h"\r
-#include "vfile.h"\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-// GENESIS_PUBLIC_APIS\r
-typedef struct geMotion geMotion;\r
-\r
-GENESISAPI geMotion *GENESISCC geMotion_Create(geBoolean ManageNames);\r
-\r
-GENESISAPI void GENESISCC geMotion_Destroy(geMotion **PM);\r
-\r
-// GENESIS_PRIVATE_APIS\r
-\r
-GENESISAPI geBoolean GENESISCC geMotion_IsValid(const geMotion *M);\r
-\r
- // AddPath adds a reference of P to the motion M. Ownership is shared - The caller must destroy P.\r
-GENESISAPI geBoolean GENESISCC geMotion_AddPath(geMotion *M, gePath *P,const char *Name,int *Index);\r
-\r
-GENESISAPI geBoolean GENESISCC geMotion_HasNames(const geMotion *M);\r
-GENESISAPI int32 GENESISCC geMotion_GetNameChecksum(const geMotion *M);\r
-\r
-GENESISAPI geBoolean GENESISCC geMotion_RemoveNames(geMotion *M);\r
-\r
-GENESISAPI void GENESISCC geMotion_SampleChannels(const geMotion *M, int PathIndex, geFloat Time, geQuaternion *Rotation, geVec3d *Translation);\r
-GENESISAPI geBoolean GENESISCC geMotion_SampleChannelsNamed(const geMotion *M, const char *PathName, geFloat Time, geQuaternion *Rotation, geVec3d *Translation);\r
-\r
-GENESISAPI void GENESISCC geMotion_Sample(const geMotion *M, int PathIndex, geFloat Time, geXForm3d *Transform);\r
-GENESISAPI geBoolean GENESISCC geMotion_SampleNamed(const geMotion *M, const char *PathName, geFloat Time, geXForm3d *Transform);\r
-\r
- // the returned Paths from _Get functions should not be destroyed. \r
- // if ownership is desired, call gePath_CreateRef() to create another owner. \r
- // an 'owner' has access to the object regardless of the number of other owners, and \r
- // an owner must call the object's destroy method to relinquish ownership\r
-GENESISAPI gePath *GENESISCC geMotion_GetPathNamed(const geMotion *M,const char *Name);\r
-GENESISAPI const char *GENESISCC geMotion_GetNameOfPath(const geMotion *M, int Index);\r
-\r
-// GENESIS_PUBLIC_APIS\r
-GENESISAPI gePath *GENESISCC geMotion_GetPath(const geMotion *M,int Index);\r
-GENESISAPI int GENESISCC geMotion_GetPathCount(const geMotion *M);\r
-\r
-\r
-GENESISAPI geBoolean GENESISCC geMotion_SetName(geMotion *M, const char * Name);\r
-GENESISAPI const char *GENESISCC geMotion_GetName(const geMotion *M);\r
-\r
-// GENESIS_PRIVATE_APIS\r
-\r
- // support for compound motions. A motion can either have sub-motions, or be single motion.\r
- // these functions support motions that have sub-motions.\r
-GENESISAPI int GENESISCC geMotion_GetSubMotionCount(const geMotion*M);\r
-\r
- // the returned motions from these _Get functions should not be destroyed. \r
- // if ownership is desired, call geMotion_CreateRef() to create another owner. \r
- // an 'owner' has access to the object regardless of the number of other owners, and \r
- // an owner must call the object's destroy method to relinquish ownership\r
-GENESISAPI geMotion *GENESISCC geMotion_GetSubMotion(const geMotion *M,int Index);\r
-GENESISAPI geMotion *GENESISCC geMotion_GetSubMotionNamed(const geMotion *M,const char *Name);\r
-GENESISAPI geBoolean GENESISCC geMotion_AddSubMotion(\r
- geMotion *ParentMotion,\r
- geFloat TimeScale, // Scale factor for this submotion\r
- geFloat TimeOffset, // Time in parent motion when submotion should start\r
- geMotion *SubMotion,\r
- geFloat StartTime, // Blend start time (relative to submotion)\r
- geFloat StartMagnitude, // Blend start magnitude (0..1)\r
- geFloat EndTime, // Blend ending time (relative to submotion)\r
- geFloat EndMagnitude, // Blend ending magnitude (0..1)\r
- const geXForm3d *Transform, // Base transform to apply to this submotion\r
- int *Index); // returned motion index\r
-\r
-GENESISAPI geMotion *GENESISCC geMotion_RemoveSubMotion(geMotion *ParentMotion, int SubMotionIndex);\r
-\r
-// Get/Set submotion time offset. The time offset is the offset into the \r
-// compound (parent) motion at which the submotion should start.\r
-GENESISAPI geFloat GENESISCC geMotion_GetTimeOffset( const geMotion *M,int SubMotionIndex );\r
-GENESISAPI geBoolean GENESISCC geMotion_SetTimeOffset( geMotion *M,int SubMotionIndex,geFloat TimeOffset );\r
-\r
-// Get/Set submotion time scale. Time scaling is applied to the submotion after the TimeOffset\r
-// is applied. The formula is: (CurrentTime - TimeOffset) * TimeScale\r
-GENESISAPI geFloat GENESISCC geMotion_GetTimeScale( const geMotion *M,int SubMotionIndex );\r
-GENESISAPI geBoolean GENESISCC geMotion_SetTimeScale( geMotion *M,int SubMotionIndex,geFloat TimeScale );\r
-\r
-// Get blending amount for a particular submotion. The Time parameter is parent-relative.\r
-GENESISAPI geFloat GENESISCC geMotion_GetBlendAmount( const geMotion *M, int SubMotionIndex, geFloat Time);\r
-\r
-// Get/Set blending path. The keyframe times in the blend path are relative to the submotion.\r
-GENESISAPI gePath *GENESISCC geMotion_GetBlendPath( const geMotion *M,int SubMotionIndex );\r
-GENESISAPI geBoolean GENESISCC geMotion_SetBlendPath( geMotion *M,int SubMotionIndex, gePath *Blend );\r
-\r
-GENESISAPI const geXForm3d *GENESISCC geMotion_GetBaseTransform( const geMotion *M,int SubMotionIndex );\r
-GENESISAPI geBoolean GENESISCC geMotion_SetBaseTransform( geMotion *M,int SubMotionIndex, geXForm3d *BaseTransform );\r
-GENESISAPI geBoolean GENESISCC geMotion_GetTransform(const geMotion *M, geFloat Time, geXForm3d *Transform);\r
-// GENESIS_PUBLIC_APIS\r
-\r
- // gets time of first key and time of last key (as if motion did not loop)\r
- // if there are no paths in the motion: returns GE_FALSE and times are not set\r
- // otherwise returns GE_TRUE\r
- //\r
- // For a compound motion, GetTimeExtents will return the extents of the scaled submotions.\r
- // For a single motion, no scaling is applied.\r
-GENESISAPI geBoolean GENESISCC geMotion_GetTimeExtents(const geMotion *M,geFloat *StartTime,geFloat *EndTime);\r
-\r
-// Only one event is allowed per time key.\r
-\r
-GENESISAPI geBoolean GENESISCC geMotion_InsertEvent(geMotion *M, geFloat tKey, const char* String);\r
- // Inserts the new event and corresponding string.\r
-\r
-GENESISAPI geBoolean GENESISCC geMotion_DeleteEvent(geMotion *M, geFloat tKey);\r
- // Deletes the event\r
-\r
-GENESISAPI void GENESISCC geMotion_SetupEventIterator(\r
- geMotion *M,\r
- geFloat StartTime, // Inclusive search start\r
- geFloat EndTime); // Non-inclusive search stop\r
- // For searching or querying the array for events between two times\r
- // times are compaired [StartTime,EndTime), '[' is inclusive, ')' is \r
- // non-inclusive. This prepares the geMotion_GetNextEvent() function.\r
-\r
-GENESISAPI geBoolean GENESISCC geMotion_GetNextEvent(\r
- geMotion *M, // Event list to iterate\r
- geFloat *pTime, // Return time, if found\r
- const char **ppEventString); // Return data, if found\r
- // Iterates from StartTime to EndTime as setup in geMotion_SetupEventIterator()\r
- // and for each event between these times [StartTime,EndTime)\r
- // this function will return Time and EventString returned for that event\r
- // and the iterator will be positioned for the next search. When there \r
- // are no more events in the range, this function will return GE_FALSE (Time\r
- // will be 0 and ppEventString will be empty).\r
-\r
-GENESISAPI geBoolean GENESISCC geMotion_GetEventExtents(const geMotion *M,\r
- geFloat *FirstEventTime,\r
- geFloat *LastEventTime);\r
- // returns the time associated with the first and last events \r
- // returns GE_FALSE if there are no events (and Times are not set)\r
-\r
-\r
-// GENESIS_PRIVATE_APIS\r
-GENESISAPI geMotion *GENESISCC geMotion_CreateFromFile(geVFile *f);\r
-GENESISAPI geBoolean GENESISCC geMotion_WriteToFile(const geMotion *M, geVFile *f);\r
-GENESISAPI geBoolean GENESISCC geMotion_WriteToBinaryFile(const geMotion *M,geVFile *pFile);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-\r
-#endif\r
+++ /dev/null
-/****************************************************************************************/\r
-/* PATH.H */\r
-/* */\r
-/* Author: Mike Sandige */\r
-/* Description: Time-indexed keyframe creation, maintenance, and sampling. */\r
-/* */\r
-/* The contents of this file are subject to the Genesis3D Public License */\r
-/* Version 1.01 (the "License"); you may not use this file except in */\r
-/* compliance with the License. You may obtain a copy of the License at */\r
-/* http://www.genesis3d.com */\r
-/* */\r
-/* Software distributed under the License is distributed on an "AS IS" */\r
-/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */\r
-/* the License for the specific language governing rights and limitations */\r
-/* under the License. */\r
-/* */\r
-/* The Original Code is Genesis3D, released March 25, 1999. */\r
-/* Genesis3D Version 1.1 released November 15, 1999 */\r
-/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */\r
-/* */\r
-/****************************************************************************************/\r
-#ifndef GE_PATH_H\r
-#define GE_PATH_H\r
-\r
-#include "basetype.h"\r
-#include "xform3d.h"\r
-#include "quatern.h"\r
-#include "vfile.h"\r
-\r
-#ifdef __cplusplus\r
- extern "C" {\r
-#endif\r
-\r
-\r
-// GENESIS_PUBLIC_APIS\r
-typedef struct _gePath gePath;\r
-\r
-#define GE_PATH_ROTATION_CHANNEL 1\r
-#define GE_PATH_TRANSLATION_CHANNEL 2\r
-\r
-#define GE_PATH_ALL_CHANNELS (GE_PATH_ROTATION_CHANNEL | GE_PATH_TRANSLATION_CHANNEL)\r
-\r
-#ifndef GE_PATH_ENUMS\r
- #define GE_PATH_ENUMS\r
- typedef enum \r
- {\r
- GE_PATH_INTERPOLATE_LINEAR = 0, // linear blend for translation or rotation channel\r
- GE_PATH_INTERPOLATE_HERMITE, // hermite cubic spline for translation channel\r
- GE_PATH_INTERPOLATE_SLERP, // spherical-linear blend for rotation channel\r
- GE_PATH_INTERPOLATE_SQUAD, // higher order blend for rotation channel 'G1' continuity\r
- //GE_PATH_INTEROPLATE_TRIPOD, // not supported yet.\r
- GE_PATH_INTERPOLATE_HERMITE_ZERO_DERIV = 7 // hermite cubic with zero derivative at keyframes ('easing' curve)\r
- }gePath_Interpolator;\r
-#endif\r
-\r
-GENESISAPI void GENESISCC gePath_CreateRef( gePath *P );\r
-\r
-GENESISAPI gePath *GENESISCC gePath_Create(\r
- gePath_Interpolator TranslationInterpolation, // type of interpolation for translation channel\r
- gePath_Interpolator RotationInterpolation, // type of interpolation for rotation channel\r
- geBoolean Looped); // True if end of path is connected to head\r
- // creates new gePath\r
- // A looping path should have the same first & last point. The path\r
- // generator will choose arbitrarily between these points for a \r
- // sample exactly at the end of the loop.\r
-\r
-GENESISAPI gePath *GENESISCC gePath_CreateCopy( const gePath *P );\r
- \r
-GENESISAPI void GENESISCC gePath_Destroy(gePath **PP); \r
- // destroys path *PP\r
-\r
-//------------------ time based keyframe operations\r
-GENESISAPI geBoolean GENESISCC gePath_InsertKeyframe(\r
- gePath *P, \r
- int ChannelMask, \r
- geFloat Time, \r
- const geXForm3d *Matrix); \r
- // inserts a keyframe at a specific time.\r
- \r
-GENESISAPI geBoolean GENESISCC gePath_DeleteKeyframe(\r
- gePath *P,\r
- int Index,\r
- int ChannelMask); \r
- // deletes the nth keyframe\r
-\r
-GENESISAPI geBoolean GENESISCC gePath_GetTimeExtents(\r
- const gePath *P,\r
- geFloat *StartTime, \r
- geFloat *EndTime);\r
- // gets the time for the first and last keys in the path (ignoring looping)\r
- // if there are no keys, return GE_FALSE and times are not set.\r
- // returns GE_TRUE if there are keys.\r
-\r
-//----------------- index based keyframe operations\r
-GENESISAPI void GENESISCC gePath_GetKeyframe(\r
- const gePath *P, \r
- int Index, // gets keyframe[index]\r
- int Channel, // for this channel\r
- geFloat *Time, // returns the time of the keyframe\r
- geXForm3d *Matrix); // returns the matrix of the keyframe\r
- // retrieves keyframe[index], and it's time\r
-\r
-GENESISAPI int GENESISCC gePath_GetKeyframeCount(const gePath *P,int Channel);\r
- // retrieves count of keyframes for a specific channel\r
-\r
-GENESISAPI int GENESISCC gePath_GetKeyframeIndex(const gePath *P, int Channel, geFloat Time);\r
- // retrieves the index of the keyframe at a specific time for a specific channel\r
-\r
-//----------------- sampling a path (time based)\r
-GENESISAPI void GENESISCC gePath_Sample(const gePath *P, geFloat Time,geXForm3d *Matrix);\r
- // returns a transform matrix sampled at 'Time'.\r
- // p is not const because information is cached in p for next sample\r
-\r
-// GENESIS_PRIVATE_APIS\r
-void GENESISCC gePath_SampleChannels(\r
- const gePath *P, \r
- geFloat Time, \r
- geQuaternion *Rotation, \r
- geVec3d *Translation);\r
- // returns a rotation and a translation for the path at 'Time'\r
- // p is not const because information is cached in p for next sample\r
-\r
-GENESISAPI geBoolean GENESISCC gePath_OffsetTimes(gePath *P, \r
- int StartingIndex, int ChannelMask, geFloat TimeOffset );\r
- // slides all samples in path starting with StartingIndex down by TimeOffset\r
-\r
-GENESISAPI geBoolean GENESISCC gePath_ModifyKeyframe(\r
- gePath *P,\r
- int Index,\r
- int ChannelMask,\r
- const geXForm3d *Matrix);\r
- \r
-\r
-// GENESIS_PUBLIC_APIS\r
-\r
-//------------------ saving/loading a path\r
-GENESISAPI gePath* GENESISCC gePath_CreateFromFile(geVFile *F);\r
- // loads a file (binary or ascii)\r
-\r
-GENESISAPI geBoolean GENESISCC gePath_WriteToFile(const gePath *P, geVFile *F);\r
- // dumps formatted ascii to the file. \r
-\r
-GENESISAPI geBoolean GENESISCC gePath_WriteToBinaryFile(const gePath *P, geVFile *F);\r
- // dumps a minimal binary image for fastest reading\r
-\r
-\r
-\r
-#ifdef __cplusplus\r
- }\r
-#endif\r
-\r
-\r
-#endif\r
+++ /dev/null
-/****************************************************************************************/\r
-/* QUATERN.H */\r
-/* */\r
-/* Author: Mike Sandige */\r
-/* Description: Quaternion mathematical system interface */\r
-/* */\r
-/* The contents of this file are subject to the Genesis3D Public License */\r
-/* Version 1.01 (the "License"); you may not use this file except in */\r
-/* compliance with the License. You may obtain a copy of the License at */\r
-/* http://www.genesis3d.com */\r
-/* */\r
-/* Software distributed under the License is distributed on an "AS IS" */\r
-/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */\r
-/* the License for the specific language governing rights and limitations */\r
-/* under the License. */\r
-/* */\r
-/* The Original Code is Genesis3D, released March 25, 1999. */\r
-/* Genesis3D Version 1.1 released November 15, 1999 */\r
-/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */\r
-/* */\r
-/****************************************************************************************/\r
-#ifndef GE_QUATERNION_H\r
-#define GE_QUATERNION_H\r
-\r
-/***************************************************************************\r
-\r
- The quatern module contains basic support for a quaternion object.\r
-\r
- quaternions are an extension of complex numbers that allows an\r
- expression for rotation that can be easily interpolated. geQuaternion_s are also \r
- more numericaly stable for repeated rotations than matrices.\r
-\r
- \r
- A quaternion is a 4 element 'vector' [w,x,y,z] where:\r
-\r
- q = w + xi + yj + zk\r
- i*i = -1\r
- j*j = -1\r
- k*k = -1\r
- i*j = -j*i = k\r
- j*k = -k*j = i\r
- k*i = -i*k = j\r
- q' (conjugate) = w - xi - yj - zk\r
- ||q|| (magnitude) = sqrt(q*q') = sqrt(w*w + x*x + y*y + z*z)\r
- unit quaternion ||q|| == 1; this implies q' == qinverse \r
- quaternions are associative (q1*q2)*q3 == q1*(q2*q3)\r
- quaternions are not commutative q1*q2 != q2*q1\r
- qinverse (inverse (1/q) ) = q'/(q*q')\r
- \r
- q can be expressed by w + xi + yj + zk or [w,x,y,z] \r
- or as in this implementation (s,v) where s=w, and v=[x,y,z]\r
-\r
- quaternions can represent a rotation. The rotation is an angle t, around a \r
- unit vector u. q=(s,v); s= cos(t/2); v= u*sin(t/2).\r
-\r
- quaternions can apply the rotation to a point. let the point be p [px,py,pz],\r
- and let P be a quaternion(0,p). Protated = q*P*qinverse \r
- ( Protated = q*P*q' if q is a unit quaternion)\r
-\r
- concatenation rotations is similar to matrix concatenation. given two rotations\r
- q1 and q2, to rotate by q1, then q2: let qc = (q2*q1), then the combined \r
- rotation is given by qc*P*qcinverse (= qc*P*qc' if q is a unit quaternion)\r
-\r
- multiplication: \r
- q1 = w1 + x1i + y1j + z1k\r
- q2 = w2 + x2i + y2j + z2k\r
- q1*q2 = q3 =\r
- (w1*w2 - x1*x2 - y1*y2 - z1*z2) {w3}\r
- (w1*x2 + x1*w2 + y1*z2 - z1*y2)i {x3}\r
- (w1*y2 - x1*z2 + y1*w2 + z1*x2)j {y3}\r
- (w1*z2 + x1*y2 + y1*x2 + z1*w2)k {z3}\r
-\r
- also, \r
- q1 = (s1,v1) = [s1,(x1,y1,z1)]\r
- q2 = (s2,v2) = [s2,(x2,y2,z2)]\r
- q1*q2 = q3 = (s1*s2 - dot_product(v1,v2), {s3}\r
- (s1*v2 + s2*v1 + cross_product(v1,v2)) {v3}\r
-\r
-\r
- interpolation - it is possible (and sometimes reasonable) to interpolate between\r
- two quaternions by interpolating each component. This does not quarantee a \r
- resulting unit quaternion, and will result in an animation with non-linear \r
- rotational velocity.\r
-\r
- spherical interpolation: (slerp) treat the quaternions as vectors \r
- find the angle between them (w = arccos(q1 dot q2) ).\r
- given 0<=t<=1, q(t) = q1*(sin((1-t)*w)/sin(w) + q2 * sin(t*w)/sin(w).\r
- since q == -q, care must be taken to rotate the proper way. \r
-\r
- this implementation uses the notation quaternion q = (quatS,quatV) \r
- where quatS is a scalar, and quatV is a 3 element vector.\r
-\r
-********************************************/\r
-\r
-#include "basetype.h"\r
-#include "xform3d.h"\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-typedef struct \r
-{\r
- geFloat W;\r
- geFloat X,Y,Z;\r
- //geVec3d QuatV;\r
-} geQuaternion;\r
-\r
-\r
-#define QUATERNION_PI (GE_PI)\r
-\r
-geBoolean GENESISCC geQuaternion_IsValid( const geQuaternion *Q );\r
- // return GE_TRUE if Q is non null and for has no NAN's in its components\r
-\r
-void GENESISCC geQuaternion_Set( geQuaternion *Q, geFloat W, geFloat X, geFloat Y, geFloat Z);\r
- // set quaternion components. Doesn't normalize\r
-void GENESISCC geQuaternion_SetVec3d( geQuaternion *Q, geFloat W, const geVec3d *V);\r
- // set quaternion components. Doesn't normalize\r
-GENESISAPI void GENESISCC geQuaternion_SetFromAxisAngle(geQuaternion *Q, const geVec3d *Axis, geFloat Theta);\r
- // set a quaternion from an axis and a rotation around the axis\r
-geBoolean GENESISCC geQuaternion_GetAxisAngle(const geQuaternion *Q, geVec3d *Axis, geFloat *Theta);\r
- // gets an axis and angle of rotation around the axis from a quaternion\r
- // returns GE_TRUE if there is an axis. \r
- // returns GE_FALSE if there is no axis (and Axis is set to 0,0,0, and Theta is 0)\r
-\r
-void GENESISCC geQuaternion_Get( const geQuaternion *Q, \r
- geFloat *W, geFloat *X, geFloat *Y, geFloat *Z);\r
- // get quaternion components into W,X,Y,Z\r
-void GENESISCC geQuaternion_GetVec3d( const geQuaternion *Q, geFloat *W, geVec3d *V);\r
- // get quaternion components into W and V\r
-\r
-void GENESISCC geQuaternion_FromMatrix(\r
- const geXForm3d *RotationMatrix,\r
- geQuaternion *QDest);\r
- // takes upper 3 by 3 portion of matrix (rotation sub matrix) \r
- // and generates a quaternion\r
-\r
-GENESISAPI void GENESISCC geQuaternion_ToMatrix(\r
- const geQuaternion *Q, \r
- geXForm3d *RotationMatrixDest);\r
- // takes a unit quaternion and makes RotationMatrixDest an equivelant rotation xform.\r
- // (any translation in RotationMatrixDest will be list)\r
-\r
-void GENESISCC geQuaternion_Slerp(\r
- const geQuaternion *Q0, \r
- const geQuaternion *Q1, \r
- geFloat T, \r
- geQuaternion *QT);\r
- // spherical interpolation between q0 and q1. 0<=t<=1 \r
- // resulting quaternion is 'between' q0 and q1\r
- // with t==0 being all q0, and t==1 being all q1.\r
- // returns a quaternion with a positive W - always takes shortest route\r
- // through the positive W domain.\r
-\r
-void GENESISCC geQuaternion_SlerpNotShortest(\r
- const geQuaternion *Q0, \r
- const geQuaternion *Q1, \r
- geFloat T, \r
- geQuaternion *QT);\r
- // spherical interpolation between q0 and q1. 0<=t<=1 \r
- // resulting quaternion is 'between' q0 and q1\r
- // with t==0 being all q0, and t==1 being all q1.\r
-\r
-\r
-void GENESISCC geQuaternion_Multiply(\r
- const geQuaternion *Q1, \r
- const geQuaternion *Q2, \r
- geQuaternion *QProduct);\r
- // multiplies q1 * q2, and places the result in q.\r
- // no failure. renormalization not automatic\r
-\r
-void GENESISCC geQuaternion_Rotate(\r
- const geQuaternion *Q, \r
- const geVec3d *V, \r
- geVec3d *VRotated);\r
- // Rotates V by the quaternion Q, places the result in VRotated.\r
-\r
-geBoolean GENESISCC geQuaternion_IsUnit(const geQuaternion *Q);\r
- // returns GE_TRUE if q is a unit quaternion. GE_FALSE otherwise.\r
-\r
-GENESISAPI geFloat GENESISCC geQuaternion_Normalize(geQuaternion *Q);\r
- // normalizes q to be a unit quaternion. returns original magnitude of q\r
-\r
-GENESISAPI void GENESISCC geQuaternion_Copy(const geQuaternion *QSrc, geQuaternion *QDst);\r
- // copies quaternion QSrc into QDst\r
-\r
-void GENESISCC geQuaternion_SetNoRotation(geQuaternion *Q);\r
- // sets Q to be a quaternion with no rotation (like an identity matrix)\r
-\r
-void GENESISCC geQuaternion_Ln(\r
- const geQuaternion *Q, \r
- geQuaternion *LnQ);\r
- // ln(Q) for unit quaternion only!\r
-\r
-void GENESISCC geQuaternion_Exp(\r
- const geQuaternion *Q,\r
- geQuaternion *ExpQ);\r
- // exp(Q) for pure quaternion only! (zero scalar part (W))\r
-\r
-void GENESISCC geQuaternion_Scale(\r
- const geQuaternion *Q,\r
- geFloat Scale,\r
- geQuaternion *QScaled);\r
- // Q = Q * Scale (result is not generally a unit quaternion!)\r
-\r
-void GENESISCC geQuaternion_Add(\r
- const geQuaternion *Q1,\r
- const geQuaternion *Q2,\r
- geQuaternion *QSum);\r
- // QSum = Q1 + Q2 (result is not generally a unit quaternion!)\r
-\r
-void GENESISCC geQuaternion_Subtract(\r
- const geQuaternion *Q1, \r
- const geQuaternion *Q2, \r
- geQuaternion *QSum);\r
- // QSum = Q1 - Q2 (result is not generally a unit quaternion!)\r
-\r
-void GENESISCC geQuaternion_Inverse(const geQuaternion *Q, geQuaternion *QInv);\r
- // sets QInv to the inverse of Q. \r
-\r
-geFloat GENESISCC geQuaternion_Magnitude(const geQuaternion *Q);\r
- // returns Magnitude of Q. \r
-\r
-geBoolean GENESISCC geQuaternion_Compare( geQuaternion *Q1, geQuaternion *Q2, geFloat Tolerance );\r
- // return GE_TRUE if quaternions differ elementwise by less than Tolerance.\r
-\r
-\r
-#ifndef NDEBUG\r
-void GENESISCC geQuaternion_SetMaximalAssertionMode( geBoolean Enable );\r
-#endif\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-\r
-#endif // GE_QUATERNION_H\r