00001 /****************************************************************************************/ 00002 /* Fog.c */ 00003 /* */ 00004 /* Author: John Pollard */ 00005 /* Description: Fog module */ 00006 /* */ 00007 /* The contents of this file are subject to the Genesis3D Public License */ 00008 /* Version 1.01 (the "License"); you may not use this file except in */ 00009 /* compliance with the License. You may obtain a copy of the License at */ 00010 /* http://www.genesis3d.com */ 00011 /* */ 00012 /* Software distributed under the License is distributed on an "AS IS" */ 00013 /* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */ 00014 /* the License for the specific language governing rights and limitations */ 00015 /* under the License. */ 00016 /* */ 00017 /* The Original Code is Genesis3D, released March 25, 1999. */ 00018 /*Genesis3D Version 1.1 released November 15, 1999 */ 00019 /* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */ 00020 /* */ 00021 /****************************************************************************************/ 00022 #include <Windows.h> 00023 #include <Assert.h> 00024 00025 #include "Fog.h" 00026 00027 //================================================================================ 00028 // geFog_Create 00029 //================================================================================ 00030 GENESISAPI geFog *geFog_Create(SET_ATTR_CB *SetAttrCB) 00031 { 00032 geFog *Fog; 00033 00034 Fog = GE_RAM_ALLOCATE_STRUCT(geFog); 00035 00036 if (!Fog) 00037 { 00038 geErrorLog_Add(GE_ERR_OUT_OF_MEMORY, NULL); 00039 return NULL; 00040 } 00041 00042 memset(Fog, 0, sizeof(geFog)); 00043 00044 if (SetAttrCB) 00045 Fog->SetAttrCB = SetAttrCB; 00046 00047 return Fog; 00048 } 00049 00050 //================================================================================ 00051 // geFog_Destroy 00052 //================================================================================ 00053 GENESISAPI void geFog_Destroy(geFog *Fog) 00054 { 00055 assert(Fog); 00056 00057 geRam_Free(Fog); 00058 } 00059 00060 //================================================================================ 00061 // geFog_SetAttributes 00062 //================================================================================ 00063 GENESISAPI geBoolean geFog_SetAttributes( geFog *Fog, 00064 const geVec3d *Pos, 00065 GE_RGBA *Color, 00066 geFloat LightBrightness, 00067 geFloat VolumeBrightness, 00068 geFloat VolumeRadius) 00069 { 00070 Fog->Pos = *Pos; 00071 Fog->Color.r = Color->r*(1.0f/255.0f)*(1<<8); 00072 Fog->Color.g = Color->g*(1.0f/255.0f)*(1<<8); 00073 Fog->Color.b = Color->b*(1.0f/255.0f)*(1<<8); 00074 Fog->LightBrightness = LightBrightness; 00075 Fog->VolumeBrightness = VolumeBrightness; 00076 Fog->VolumeRadius = VolumeRadius; 00077 Fog->VolumeRadiusSquared = VolumeRadius*VolumeRadius; 00078 Fog->VolumeRadius2 = VolumeRadius*2; 00079 00080 // Now that all is set, call the CB if it exist... 00081 if (Fog->SetAttrCB) 00082 { 00083 if (!Fog->SetAttrCB(Fog)) 00084 return GE_FALSE; 00085 } 00086 00087 return GE_TRUE; 00088 } 00089 00090 //================================================================================ 00091 // geFog_SetUserData 00092 //================================================================================ 00093 GENESISAPI geBoolean geFog_SetUserData(geFog *Fog, void *UserData) 00094 { 00095 assert(Fog); 00096 00097 Fog->UserData = UserData; 00098 00099 return GE_TRUE; 00100 } 00101 00102 //================================================================================ 00103 // geFog_GetUserData 00104 //================================================================================ 00105 GENESISAPI void *geFog_GetUserData(geFog *Fog) 00106 { 00107 assert(Fog); 00108 00109 return Fog->UserData; 00110 } 00111
1.3.2