//================================================================================ // Frustum_TransformToWorldSpace //================================================================================ void Frustum_TransformToWorldSpace(const Frustum_Info *In, const geCamera *Camera, Frustum_Info *Out) { int32 i; GFX_Plane *pPlane1, *pPlane2; assert(In != Out); pPlane1 = (GFX_Plane*)In->Planes; pPlane2 = Out->Planes; // Rotate all the planes for (i=0; i<In->NumPlanes; i++, pPlane1++, pPlane2++) { pPlane2->Type = pPlane1->Type; SetWorldspaceClipPlane(pPlane1, Camera, pPlane2); pPlane2->Dist = geVec3d_DotProduct(geCamera_GetPov(Camera), &pPlane2->Normal) - CLIP_PLANE_EPSILON; if (pPlane1->Dist) // Add the original dist back in { geVec3d Vect; geVec3d_Clear(&Vect); geVec3d_AddScaled(&Vect, &pPlane1->Normal, pPlane1->Dist, &Vect); BackRotateVector(&Vect, &Vect, geCamera_GetCameraSpaceXForm(Camera)); pPlane2->Dist += geVec3d_DotProduct(&pPlane2->Normal, &Vect); } } Out->NumPlanes = In->NumPlanes; // Get BBox info for fast BBox rejection against frustum... SetUpFrustumBBox(Out); }
char weapon_molotov_init(){ int i; InfMolotov* m; for(i=0; i<NUMBER_OF_MOLOTOVS; i++) { m = &molotovs[i]; m->active=GE_FALSE; m->molotov=0; //m->position geVec3d_Clear(&(m->position)); geVec3d_Clear(&(m->velocity)); geXForm3d_SetIdentity(&(m->xform)); } molotovCurrentWorld = 0; molotovActor = LoadActorDef(".\\actors\\molotov.act"); if(! molotovActor ) { error("Failed to load molotov actor"); printLog("Failed to load molotov actor\n"); return 0; } molotovIndex = 0; return 1; }
void kill_all_molotovs(){ int i; InfMolotov* m; for(i=0; i<NUMBER_OF_MOLOTOVS; i++) { m = &molotovs[i]; m->active=GE_FALSE; if( m->molotov ){ if(! molotovCurrentWorld ){ error("No previous world present when clearing molotovs"); } KillActor(molotovCurrentWorld, &(m->molotov)); m->molotov = 0; } geVec3d_Clear(&(m->position)); geVec3d_Clear(&(m->velocity)); geXForm3d_SetIdentity(&(m->xform)); } molotovCurrentWorld = 0; molotovIndex = 0; }
char weapon_mini_rocket_init(){ int i; InfMiniRocket* g; for(i=0; i<NUMBER_OF_MINIROCKETS; i++) { g = &miniRockets[i]; g->active=GE_FALSE; g->mini_rocket=0; //g->position geVec3d_Clear(&(g->position)); geVec3d_Clear(&(g->velocity)); geXForm3d_SetIdentity(&(g->xform)); } mini_rocketCurrentWorld = 0; mini_rocketActor = LoadActorDef(".\\actors\\mini_rocket.act"); if(! mini_rocketActor ) { error("Failed to load mini_rocket actor"); printLog("Failed to load mini_rocket actor\n"); return 0; } mini_rocketIndex = 0; return 1; }
void kill_all_miniRockets(){ int i; InfMiniRocket* g; for(i=0; i<NUMBER_OF_MINIROCKETS; i++) { g = &miniRockets[i]; g->active=GE_FALSE; if( g->mini_rocket ){ if(! mini_rocketCurrentWorld ){ error("No previous world present when clearing miniRockets"); } KillActor(mini_rocketCurrentWorld, &(g->mini_rocket)); g->mini_rocket = 0; } geVec3d_Clear(&(g->position)); geVec3d_Clear(&(g->velocity)); geXForm3d_SetIdentity(&(g->xform)); } mini_rocketCurrentWorld = 0; mini_rocketIndex = 0; }
//===================================================================================== // LeafCenter //===================================================================================== void LeafCenter(GBSP_Node *Node, geVec3d *PortalMid) { int32 NumPortals, Side; geVec3d Mid; GBSP_Portal *Portal; NumPortals = 0; geVec3d_Clear(PortalMid); for (Portal = Node->Portals; Portal; Portal = Portal->Next[Side]) { Side = Portal->Nodes[1] == Node; PolyCenter(Portal->Poly, &Mid); geVec3d_Add(PortalMid, &Mid, PortalMid); NumPortals++; } geVec3d_Scale(PortalMid, 1.0f/(geFloat)NumPortals, PortalMid); }
//================================================================================ // Frustum_RotateToWorldSpace //================================================================================ void Frustum_RotateToWorldSpace(Frustum_Info *In, geCamera *Camera, Frustum_Info *Out) { int32 i; GFX_Plane *pPlane1, *pPlane2; assert(In != Out); pPlane1 = In->Planes; pPlane2 = Out->Planes; // Rotate all the planes for (i=0; i<In->NumPlanes; i++, pPlane1++, pPlane2++) { pPlane2->Type = pPlane1->Type; SetWorldspaceClipPlane(pPlane1, Camera, pPlane2); pPlane2->Dist = 0.0f; // We are just rotating, so set dist to 0 if (pPlane1->Dist) // Add the original dist back in { geVec3d Vect; geVec3d_Clear(&Vect); geVec3d_AddScaled(&Vect, &pPlane1->Normal, pPlane1->Dist, &Vect); BackRotateVector(&Vect, &Vect, geCamera_GetCameraSpaceXForm(Camera)); pPlane2->Dist += geVec3d_DotProduct(&pPlane2->Normal, &Vect); } } Out->NumPlanes = In->NumPlanes; // Get BBox info for fast BBox rejection against frustum... SetUpFrustumBBox(Out); }
//===================================================================================== // CreateAllOutsidePortals //===================================================================================== geBoolean CreateAllOutsidePortals(GBSP_Node *Node) { int32 k, i, Index; GBSP_Plane PPlanes[6]; GBSP_Portal *Portals[6]; memset(OutsideNode, 0, sizeof(GBSP_Node)); memset(PPlanes, 0, 6*sizeof(GBSP_Plane)); OutsideNode->PlaneNum = PLANENUM_LEAF; OutsideNode->Contents = BSP_CONTENTS_SOLID2; OutsideNode->Portals = NULL; OutsideNode->BrushList = NULL; // So there won't be NULL volume leafs when we create the outside portals for (k=0; k< 3; k++) { if (VectorToSUB(NodeMins, k)-128 <= -MIN_MAX_BOUNDS || VectorToSUB(NodeMaxs, k)+128 >= MIN_MAX_BOUNDS) { GHook.Error("CreateAllOutsidePortals: World BOX out of range...\n"); return GE_FALSE; } VectorToSUB(NodeMins, k) -= (geFloat)128; VectorToSUB(NodeMaxs, k) += (geFloat)128; } // Create 6 portals, and point to the outside and the RootNode for (i=0; i<3; i++) { for (k=0; k<2; k++) { Index = k*3 + i; geVec3d_Clear(&PPlanes[Index].Normal); if (k == 0) { VectorToSUB(PPlanes[Index].Normal, i) = (geFloat)1; PPlanes[Index].Dist = VectorToSUB(NodeMins, i); } else { VectorToSUB(PPlanes[Index].Normal, i) = (geFloat)-1; PPlanes[Index].Dist = -VectorToSUB(NodeMaxs, i); } Portals[Index] = CreateOutsidePortal(&PPlanes[Index], Node); if (!Portals[Index]) return GE_FALSE; } } for (i=0; i< 6; i++) { for (k=0; k< 6; k++) { if (k == i) continue; if (!ClipPoly(Portals[i]->Poly, &PPlanes[k], GE_FALSE, &Portals[i]->Poly)) { GHook.Error("CreateAllOutsidePortals: There was an error clipping the portal.\n"); return GE_FALSE; } if (!Portals[i]->Poly) { GHook.Error("CreateAllOutsidePortals: Portal was clipped away.\n"); return GE_FALSE; } } } return GE_TRUE; }
//==================================================================================== // FinishLeafSides //==================================================================================== geBoolean FinishLeafSides(GBSP_Node *Node) { geVec3d Mins, Maxs; GBSP_Plane Plane; int32 Axis, i, Dir; if (!GetLeafBBoxFromPortals(Node, &Mins, &Maxs)) { GHook.Error("FinishLeafSides: Could not get leaf portal BBox.\n"); return GE_FALSE; } if (CNumLeafSides < 4) GHook.Printf("*WARNING* FinishLeafSides: Incomplete leaf volume.\n"); // Add any bevel planes to the sides so we can expand them for axial box collisions else for (Axis=0 ; Axis <3 ; Axis++) { for (Dir=-1 ; Dir <= 1 ; Dir+=2) { // See if the plane is allready in the sides for (i=0; i< CNumLeafSides; i++) { Plane = Planes[LPlaneNumbers[i]]; if (LPlaneSides[i]) { geVec3d_Inverse(&Plane.Normal); Plane.Dist = -Plane.Dist; } if (VectorToSUB(Plane.Normal, Axis) == (geFloat)Dir) break; } if (i >= CNumLeafSides) { // Add a new axial aligned side geVec3d_Clear(&Plane.Normal); VectorToSUB(Plane.Normal, Axis) = (geFloat)Dir; // get the mins/maxs from the gbsp brush if (Dir == 1) Plane.Dist = VectorToSUB(Maxs, Axis); else Plane.Dist = -VectorToSUB(Mins, Axis); LPlaneNumbers[i] = FindPlane(&Plane, &LPlaneSides[i]); if (LPlaneNumbers[i] == -1) { GHook.Error("FinishLeafSides: Could not create the plane.\n"); return GE_FALSE; } CNumLeafSides++; NumLeafBevels++; } } } Node->FirstSide = NumLeafSides; Node->NumSides = CNumLeafSides; for (i=0; i< CNumLeafSides; i++) { if (NumLeafSides >= MAX_LEAF_SIDES) { GHook.Error("FinishLeafSides: Max Leaf Sides.\n"); return GE_FALSE; } LeafSides[NumLeafSides].PlaneNum = LPlaneNumbers[i]; LeafSides[NumLeafSides].PlaneSide = LPlaneSides[i]; NumLeafSides++; } return GE_TRUE; }
/* ------------------------------------------------------------------------------------ */ void CCameraManager::Defaults() { memset(&Translation, 0, sizeof(geVec3d)); memset(&Rotation, 0, sizeof(geVec3d)); bBindToActor = false; theActor = NULL; szActorBone[0] = 0; memset(&CameraOffsetTranslation, 0, sizeof(geVec3d)); memset(&CameraOffsetRotation, 0, sizeof(geVec3d)); bUseExtBox = false; theModel = NULL; bBindToModel = NULL; FarClipPlaneDistance = 0.0f; ClipEnable = false; TrackingFlags = kCameraTrackPosition; // eaa3 12/18/2000 head bob setup m_HeadBobOffset = 0.0f; // No offset m_HeadBob = false; // Default to no bobbing // eaa3 12/18/2000 end zooming = false; zoommode = false; shake = false; shakex = shakey = shakemin = 0.0f; // changed RF063 jerkamt = 0.0f; jerk = false; // end change RF063 // changed RF064 DesiredHeight = 0.0f; HeightSpeed = 40.0f; OverlayDist = 10.0f; geXForm3d_SetIdentity(&m_OldXForm); geVec3d_Clear(&m_vMoveDif); m_bViewChanged = m_bPositionMoved = false; // end change RF064 CIniFile AttrFile("camera.ini"); if(!AttrFile.ReadFile()) { CCD->ReportError("[ERROR] Failed to open camera.ini file", false); exit(-1); } std::string KeyName = AttrFile.FindFirstKey(); std::string Type; while(KeyName != "") { if(KeyName == "General") { FOV = (float)AttrFile.GetValueF(KeyName, "fieldofview"); if(FOV == 0.0f) FOV = DEFAULTFOV; m_LookUp = (float)AttrFile.GetValueF(KeyName, "lookupangle") * GE_PIOVER180; if(m_LookUp == 0.0f) m_LookUp = 1.0f; m_LookDwn = (float)AttrFile.GetValueF(KeyName, "lookdownangle") * GE_PIOVER180; if(m_LookDwn == 0.0f) m_LookDwn = 1.0f; switchallowed = false; Type = AttrFile.GetValue(KeyName, "viewswitchallowed"); if(Type == "true") switchallowed = true; switch1st = false; Type = AttrFile.GetValue(KeyName, "switchto1stpersonallowed"); if(Type == "true") switch1st = true; switch3rd = false; Type = AttrFile.GetValue(KeyName, "switchto3rdpersonallowed"); if(Type == "true") switch3rd = true; switchiso = false; Type = AttrFile.GetValue(KeyName, "switchtoisopersonallowed"); if(Type == "true") switchiso = true; // changed RF064 HeightSpeed = (float)AttrFile.GetValueF(KeyName, "heightspeed"); if(HeightSpeed == 0.0f) HeightSpeed = 40.0f; OverlayDist = (float)AttrFile.GetValueF(KeyName, "overlaydistance"); if(OverlayDist == 0.0f) OverlayDist = 10.0f; // end change RF064 } else if(KeyName == "FirstPerson") { Type = AttrFile.GetValue(KeyName, "height"); if(Type == "auto" || Type == "") { viewheight = -1.0f; } else { viewheight = (float)AttrFile.GetValueF(KeyName, "height"); } allowmouse1st = true; Type = AttrFile.GetValue(KeyName, "disablemouse"); if(Type == "true") allowmouse1st = false; } else if(KeyName == "ThirdPerson") { Type = AttrFile.GetValue(KeyName, "height"); if(Type == "auto" || Type == "") { playerheight = -1.0f; } else { playerheight = (float)AttrFile.GetValueF(KeyName, "height"); } playerangleup = (float)AttrFile.GetValueF(KeyName, "angleup") * GE_PIOVER180; playerdistance = (float)AttrFile.GetValueF(KeyName, "distance"); playerzoom = false; Type = AttrFile.GetValue(KeyName, "allowzoom"); if(Type == "true") { playerzoom = true; playermindistance = (float)AttrFile.GetValueF(KeyName, "minimumdistance"); playermaxdistance = (float)AttrFile.GetValueF(KeyName, "maximumdistance"); } playermouserotation = true; Type = AttrFile.GetValue(KeyName, "mouserotation"); if(Type == "false") { playermouserotation = false; playerallowlook = false; Type = AttrFile.GetValue(KeyName, "allowlook"); if(Type == "true") playerallowlook = true; } allowmouse3rd = true; Type = AttrFile.GetValue(KeyName, "disablemouse"); if(Type == "true") allowmouse3rd = false; allowtilt3rd = true; Type = AttrFile.GetValue(KeyName, "disabletilt"); if(Type == "true") allowtilt3rd = false; } else if(KeyName == "Isometric") { Type = AttrFile.GetValue(KeyName, "height"); if(Type == "auto" || Type == "") { isoheight = -1.0f; } else { isoheight = (float)AttrFile.GetValueF(KeyName, "height"); } isoangleup = (float)AttrFile.GetValueF(KeyName, "angleup") * GE_PIOVER180; isoanglearound = (float)AttrFile.GetValueF(KeyName, "anglearound") * GE_PIOVER180; isodistance = (float)AttrFile.GetValueF(KeyName, "distance"); IsoCollFlag = false; Type = AttrFile.GetValue(KeyName, "collisiondetection"); if(Type == "true") IsoCollFlag = true; allowmouseiso = true; Type = AttrFile.GetValue(KeyName, "disablemouse"); if(Type == "true") allowmouseiso = false; } else if(KeyName == "MultipleFixed") { } else if(KeyName == "Moving") { } KeyName = AttrFile.FindNextKey(); } }
void td_timedamageIterate(TimeDamage* td, geActor* act) { float time = TIME; switch(td->type){ case TIMEDAMAGE_NONE: if(! act ) { timefx_normal(); } return; case TIMEDAMAGE_INFECTED: if( !act ){ soundsys_updateSound(2.0); timefx_bite(3.0f); } td->timeLeft-=time; if( td->timeLeft <= 0.0f ){ if( td->damageLeft <= 0 ){ disableTimedamageType( td->type, act ); td_timedamageClear(td); } else { geVec3d zeroVector; geVec3d_Clear(&zeroVector); td->damageLeft -= 1; // cause damage enemy_damage(act, 1 + rand() % 5, DAMAGE_ARMORPIERCING, 0, zeroVector, zeroVector); td->timeLeft += getTimeOfTimedamage(td->type); } } break; case TIMEDAMAGE_DRUG: td->timeLeft-=time; if( !act ){ soundsys_updateSound(0.33f); timefx_drug(3.0f); } if( td->timeLeft <= 0.0f ){ if( td->damageLeft <= 0 ){ disableTimedamageType( td->type, act ); td_timedamageClear(td); } else { geVec3d zeroVector; geVec3d_Clear(&zeroVector); td->damageLeft -= 1; // cause damage enemy_damage(act, 1 + rand() % 5, DAMAGE_ARMORPIERCING, 0, zeroVector, zeroVector); td->timeLeft += getTimeOfTimedamage(td->type); } } break; case TIMEDAMAGE_FIRE: if( act == 0 && moved ) { td->timeLeft+=time; //system_message("adding fire time"); } else td->timeLeft-=time; if( td->timeLeft <= 0.0f ){ if( td->damageLeft <= 0 ){ disableTimedamageType( td->type, act ); td_timedamageClear(td); } else { geVec3d zeroVector; geVec3d_Clear(&zeroVector); td->damageLeft -= 1; // cause damage enemy_damage(act, 1 + rand() % 6, DAMAGE_FIRE, 0, zeroVector, zeroVector); td->timeLeft += getTimeOfTimedamage(td->type); fx_fire(&Pos , GE_FALSE, 0.50f); } } else if(td->timeLeft > 0.4f) { // effect geVec3d zeroVector; geVec3d_Clear(&zeroVector); td->timeLeft -= getTimeOfTimedamage(td->type); td->damageLeft -= 2; enemy_damage(act, 1 + rand() % 2, DAMAGE_FIRE, 0, zeroVector, zeroVector); if( !act ) { fx_fire(&Pos , GE_FALSE, 0.50f); } if( td->damageLeft <= 0 ){ td_timedamageClear(td); } } break; } }