static ANGLE3D GetRotForDelta(CPoint ptDelta, BOOL bInvertY) { FLOAT fdH = ptDelta.x/15.0f; FLOAT fdP = ptDelta.y/15.0f; if( bInvertY) return ANGLE3D( fdH, -fdP, 0); else return ANGLE3D( fdH, fdP, 0); }
CDlgCreateSpecularTexture::CDlgCreateSpecularTexture(CWnd* pParent /*=NULL*/) : CDialog(CDlgCreateSpecularTexture::IDD, pParent) { //{{AFX_DATA_INIT(CDlgCreateSpecularTexture) m_strNumericalExponent = _T(""); m_bAutoRotate = FALSE; //}}AFX_DATA_INIT m_bAutoRotate = TRUE; m_colorSpecular.m_pwndParentDialog = this; m_colorLight.m_pwndParentDialog = this; m_colorAmbient.m_pwndParentDialog = this; m_pPreviewDrawPort = NULL; m_pPreviewViewPort = NULL; m_pGraphDrawPort = NULL; m_pGraphViewPort = NULL; m_colorAmbient.SetColor( 0x030303FF); m_bCustomWindowsCreated = FALSE; m_plPlacement.pl_OrientationAngle = ANGLE3D( 30, 0, 0); m_moModel.mo_Stretch = FLOAT3D( 1.0f, 1.0f, 1.0f); // mark that timer is not yet started m_iTimerID = -1; }
void CAM_Start(const CTFileName &fnmDemo) { _bCameraOn = FALSE; CTFileName fnmScript = fnmDemo.NoExt()+".ini"; if( cam_bRecord) { try { _strScript.Create_t(fnmScript); } catch(char *strError) { CPrintF("Camera: %s\n", strError); return; }; _cp.cp_vPos = FLOAT3D(0,0,0); _cp.cp_aRot = ANGLE3D(0,0,0); _cp.cp_aFOV = 90.0f; _cp.cp_fSpeed = 1; _cp.cp_tmTick = 0.0f; } else { try { _strScript.Open_t(fnmScript); } catch(char *strError) { (void)strError; return; }; } _bCameraOn = TRUE; _bInitialized = FALSE; }
// begin/end model rendering to screen void BeginModelRenderingView( CAnyProjection3D &prProjection, CDrawPort *pdp) { ASSERT( _iRenderingType==0 && _pdp==NULL); // set 3D projection _iRenderingType = 1; _pdp = pdp; prProjection->ObjectPlacementL() = CPlacement3D(FLOAT3D(0,0,0), ANGLE3D(0,0,0)); prProjection->Prepare(); // in case of mirror projection, move mirror clip plane a bit father from the mirrored models, // so we have less clipping (for instance, player feet) if( prProjection->pr_bMirror) prProjection->pr_plMirrorView.pl_distance -= 0.06f; // -0.06 is because entire projection is offseted by +0.05 _aprProjection = prProjection; _pdp->SetProjection( _aprProjection); // make FPU precision low _fpuOldPrecision = GetFPUPrecision(); SetFPUPrecision(FPT_24BIT); // prepare common arrays for simple shadows rendering _avtxCommon.PopAll(); _atexCommon.PopAll(); _acolCommon.PopAll(); // eventually setup truform extern INDEX gap_bForceTruform; extern INDEX ogl_bTruformLinearNormals; if( ogl_bTruformLinearNormals) ogl_bTruformLinearNormals = 1; if( gap_bForceTruform) { gap_bForceTruform = 1; gfxSetTruform( _pGfx->gl_iTessellationLevel, ogl_bTruformLinearNormals); } }
CChildFrame::CChildFrame() { m_bShowVisibilityTweaks=FALSE; m_bDisableVisibilityTweaks=FALSE; m_bTestGameOn = FALSE; m_bShowTargets = FALSE; m_bShowEntityNames = FALSE; m_fManualMipBrushingFactor = 1.0f; m_bLastAutoMipBrushingOn = FALSE; m_bAutoMipBrushingOn = FALSE; m_iSelectedConfiguration = 0; m_bSceneRenderingTime = FALSE; m_bRenderViewPictures = FALSE; // don't allow moving of anchored entities m_bAncoredMovingAllowed = FALSE; if( theApp.m_Preferences.ap_bHideShadowsOnOpen) { m_stShadowType = CWorldRenderPrefs::SHT_NONE; m_bShadowsVisible = FALSE; m_bShadowsCalculate = TRUE; } else { m_stShadowType = CWorldRenderPrefs::SHT_FULL; m_bShadowsVisible = TRUE; m_bShadowsCalculate = TRUE; } m_iAnchoredResetTimerID = -1; m_bInfoVisible = 0; m_bSelectionVisible = TRUE; m_bViewFromEntity = FALSE; wo_plStored01 = CPlacement3D( FLOAT3D(0.0f,0.0f,0.0f), ANGLE3D(0,0,0)); wo_plStored02 = CPlacement3D( FLOAT3D(0.0f,0.0f,0.0f), ANGLE3D(0,0,0)); wo_plStored03 = CPlacement3D( FLOAT3D(0.0f,0.0f,0.0f), ANGLE3D(0,0,0)); wo_plStored04 = CPlacement3D( FLOAT3D(0.0f,0.0f,0.0f), ANGLE3D(0,0,0)); wo_fStored01 = 10.0f; wo_fStored02 = 10.0f; wo_fStored03 = 10.0f; wo_fStored04 = 10.0f; }
// Prepare scene for terrain rendering void PrepareScene(CAnyProjection3D &apr, CDrawPort *pdp, CTerrain *ptrTerrain) { ASSERT(ptrTerrain!=NULL); ASSERT(ptrTerrain->tr_penEntity!=NULL); // Set current terrain _ptrTerrain = ptrTerrain; // Set drawport _pdp = pdp; // Prepare and set the projection apr->ObjectPlacementL() = CPlacement3D(FLOAT3D(0,0,0), ANGLE3D(0,0,0)); apr->Prepare(); _aprProjection = apr; _pdp->SetProjection( _aprProjection); CEntity *pen = ptrTerrain->tr_penEntity; // calculate projection of viewer in absolute space const FLOATmatrix3D &mViewer = _aprProjection->pr_ViewerRotationMatrix; _vViewer(1) = -mViewer(3,1); _vViewer(2) = -mViewer(3,2); _vViewer(3) = -mViewer(3,3); // calculate projection of viewer in object space _vViewerObj = _vViewer * !pen->en_mRotation; const CPlacement3D &plTerrain = pen->GetLerpedPlacement(); _mObjectToView = mViewer * pen->en_mRotation; _vObjectToView = (plTerrain.pl_PositionVector - _aprProjection->pr_vViewerPosition) * mViewer; // make transform matrix const FLOATmatrix3D &m = _mObjectToView; const FLOAT3D &v = _vObjectToView; FLOAT glm[16]; glm[0] = m(1,1); glm[4] = m(1,2); glm[ 8] = m(1,3); glm[12] = v(1); glm[1] = m(2,1); glm[5] = m(2,2); glm[ 9] = m(2,3); glm[13] = v(2); glm[2] = m(3,1); glm[6] = m(3,2); glm[10] = m(3,3); glm[14] = v(3); glm[3] = 0; glm[7] = 0; glm[11] = 0; glm[15] = 1; gfxSetViewMatrix(glm); // Get viewer in absolute space _vViewerAbs = (_aprProjection->ViewerPlacementR().pl_PositionVector - pen->en_plPlacement.pl_PositionVector) * !pen->en_mRotation; gfxDisableBlend(); gfxDisableTexture(); gfxDisableAlphaTest(); gfxEnableDepthTest(); gfxEnableDepthWrite(); gfxCullFace(GFX_BACK); }
void CDlgCPPDynamicStateProperty::OnBtnAdd() { // TODO: Add your control notification handler code here UpdateData(SAVETOOBJECT); UINT addedPos = 0; switch((TC_NAME)m_tcStateComponent.GetCurSel()) { case TC_COLOR: addedPos = m_ppdstate.AddColor( m_fAddTime, m_btnColor.GetColor() ); break; case TC_ALPHA: addedPos = m_ppdstate.AddAlpha( m_fAddTime, Clamp(UBYTE(m_fValue1), UBYTE(0), UBYTE(255)) ); break; case TC_SIZE: addedPos = m_ppdstate.AddSize( m_fAddTime, m_fValue2, m_fValue1 ); break; case TC_MASS: addedPos = m_ppdstate.AddMass( m_fAddTime, m_fValue1 ); break; case TC_TEXPOS: addedPos = m_ppdstate.AddTexPos( m_fAddTime, Clamp(UBYTE(m_fValue2), UBYTE(0), UBYTE(255)), Clamp(UBYTE(m_fValue1), UBYTE(0), UBYTE(255)) ); break; case TC_DELTAPOS: addedPos = m_ppdstate.AddDeltaPos( m_fAddTime, FLOAT3D(m_fValue3, m_fValue2, m_fValue1) ); break; case TC_ANGLE: addedPos = m_ppdstate.AddAngle( m_fAddTime, ANGLE3D(m_fValue3, m_fValue2, m_fValue1) ); break; } Refresh((TC_NAME)m_tcStateComponent.GetCurSel()); m_lbAddedState.SetCurSel( (int)addedPos ); }
void CDlgCreateSpecularTexture::OnAutoRotate() { a3dObjectAngles = ANGLE3D( 0, 0, 0); a3dLightAngles = ANGLE3D( 0, 0, 0); if( m_bAutoRotate) { a3dObjectRotation = ANGLE3D( 0, 0, 0); a3dLightRotation = ANGLE3D( 0, 0, 0); } else { a3dObjectRotation = ANGLE3D( -2.5f, 0, 0); a3dLightRotation = ANGLE3D( 0, 0, 0); } m_bAutoRotate = !m_bAutoRotate; }
/* * Copy selected sectors of a source brush to a 3D object. */ void CWorld::CopySourceBrushSectorsToObject( CEntity &enBrush, CBrushSectorSelectionForCSG &bscselSectors, const CPlacement3D &plSourcePlacement, CObject3D &obObject, const CPlacement3D &plTargetPlacement, DOUBLEaabbox3D &boxSourceAbsolute ) { ASSERT(GetFPUPrecision()==FPT_53BIT); // get the brush mip from the entity CBrushMip &bmBrushMip = *GetBrushMip(enBrush); // calculate placement of the brush in absolute space (taking relative // world placement and entity placement in account) CPlacement3D plBrush = enBrush.en_plPlacement; plBrush.RelativeToAbsolute(plSourcePlacement); // copy selected sectors of brush to object3d object bmBrushMip.ToObject3D(obObject, bscselSectors); // make a copy of the object and find its box in absolute space CObject3D obAbsolute; obAbsolute = obObject; CSimpleProjection3D_DOUBLE prToAbsolute; prToAbsolute.ObjectPlacementL() = plBrush; prToAbsolute.ViewerPlacementL() = CPlacement3D(FLOAT3D(0,0,0), ANGLE3D(0,0,0)); prToAbsolute.Prepare(); obAbsolute.Project(prToAbsolute); obAbsolute.GetBoundingBox(boxSourceAbsolute); // project the brush into target space CSimpleProjection3D_DOUBLE prSimple; prSimple.ObjectPlacementL() = plBrush; prSimple.ViewerPlacementL() = plTargetPlacement; prSimple.Prepare(); obObject.Project(prSimple); }
void CDlgCreateSpecularTexture::DrawPreview( CDrawPort *pdp, FLOAT fExp) { BOOL bErrorOcured = FALSE; if( (m_moModel.GetData() == NULL) || (m_moModel.mo_toTexture.GetData() == NULL) || (m_moModel.mo_toSpecular.GetData() == NULL) ) // obtain components for rendering try { DECLARE_CTFILENAME( fnBCGTexture, "Models\\Editor\\SpecularPreviewBCG.tex"); m_toBackground.SetData_t( fnBCGTexture); DECLARE_CTFILENAME( fnTeapotModel, "Models\\Editor\\Teapot.mdl"); DECLARE_CTFILENAME( fnTeapotTexture, "Models\\Editor\\Teapot.tex"); m_moModel.SetData_t( fnTeapotModel); m_moModel.mo_toTexture.SetData_t( fnTeapotTexture); m_moModel.mo_toSpecular.SetData_t( CTString("temp\\SpecularTemp.tex")); } catch( char *strError) { (void) strError; bErrorOcured = TRUE; } if( !bErrorOcured) { ((CModelData*)m_moModel.GetData())->md_colSpecular = m_colorSpecular.GetColor(); PIXaabbox2D screenBox = PIXaabbox2D( PIX2D(0,0), PIX2D(pdp->GetWidth(), pdp->GetHeight()) ); //pdp->PutTexture( &m_moModel.mo_toSpecular, screenBox); //return; pdp->PutTexture( &m_toBackground, screenBox); pdp->FillZBuffer( ZBUF_BACK); CRenderModel rmRenderModel; CPerspectiveProjection3D prPerspectiveProjection; a3dObjectAngles += a3dObjectRotation; a3dLightAngles += a3dLightRotation; m_plPlacement.pl_OrientationAngle = a3dObjectAngles; AnglesToDirectionVector( a3dLightAngles, rmRenderModel.rm_vLightDirection); prPerspectiveProjection.FOVL() = AngleDeg(50.0f); prPerspectiveProjection.ScreenBBoxL() = FLOATaabbox2D( FLOAT2D(0.0f,0.0f),FLOAT2D((float)pdp->GetWidth(), (float)pdp->GetHeight())); prPerspectiveProjection.AspectRatioL() = 1.0f; prPerspectiveProjection.FrontClipDistanceL() = 0.05f; prPerspectiveProjection.ViewerPlacementL().pl_PositionVector = FLOAT3D(0.0f,0.0f,0.0f); prPerspectiveProjection.ViewerPlacementL().pl_OrientationAngle = ANGLE3D( 0, -20, 0); prPerspectiveProjection.Prepare(); CAnyProjection3D apr; apr = prPerspectiveProjection; BeginModelRenderingView(apr, pdp); _mrpModelRenderPrefs.SetRenderType( RT_TEXTURE|RT_SHADING_PHONG); m_plPlacement.pl_PositionVector = FLOAT3D( 0.0f, -0.19f, -0.35f); rmRenderModel.SetObjectPlacement(m_plPlacement); rmRenderModel.rm_colLight = m_colorLight.GetColor(); rmRenderModel.rm_colAmbient = m_colorAmbient.GetColor(); m_moModel.SetupModelRendering(rmRenderModel); m_moModel.RenderModel(rmRenderModel); EndModelRenderingView(); } /* pdp->Fill(C_GREEN|CT_OPAQUE); PIX pixSizeI = pdp->GetWidth(); PIX pixSizeJ = pdp->GetHeight(); for (PIX pixI=0; pixI<pixSizeI; pixI++) { for (PIX pixJ=0; pixJ<pixSizeJ; pixJ++) { FLOAT fX = pixI*2.0f/pixSizeI-1; FLOAT fY = pixJ*2.0f/pixSizeJ-1; FLOAT fZ; FLOAT fZ2 = 1-fX*fX-fY*fY; if (fZ2<0) { fZ = 0; } else { fZ = Sqrt(fZ2); } FLOAT fZN = FLOAT(pow(fZ, fExp)); ASSERT(fZN>=0 && fZN<=1); UBYTE ub = UBYTE(fZN*255); pdp->Fill(pixI, pixJ, 1,1, RGBToColor(ub,ub,ub)|CT_OPAQUE); } } */ }
#include "stdafx.h" #ifdef _DEBUG #undef new #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CDlgCreateSpecularTexture dialog static TIME timeLastTick=TIME(0); static ANGLE3D a3dObjectRotation = ANGLE3D( 0, 0, 0); static ANGLE3D a3dLightRotation = ANGLE3D( 0, 0, 0); static ANGLE3D a3dObjectAngles = ANGLE3D( 0, 0, 0); static ANGLE3D a3dLightAngles = ANGLE3D( 0, 0, 0); static CPoint ptLMBDown; static CPoint ptRMBDown; static ANGLE3D GetRotForDelta(CPoint ptDelta, BOOL bInvertY) { FLOAT fdH = ptDelta.x/15.0f; FLOAT fdP = ptDelta.y/15.0f; if( bInvertY) return ANGLE3D( fdH, -fdP, 0); else return ANGLE3D( fdH, fdP, 0);
/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ #include "stdh.h" #include <Engine/Math/Projection.h> ///////////////////////////////////////////////////////////////////// // CProjection3D ///////////////////////////////////////////////////////////////////// // Construction / destruction /* * Default constructor. */ CProjection3D::CProjection3D(void) { pr_Prepared = FALSE; pr_ObjectStretch = FLOAT3D(1.0f, 1.0f, 1.0f); pr_bFaceForward = FALSE; pr_bHalfFaceForward = FALSE; pr_vObjectHandle = FLOAT3D(0.0f, 0.0f, 0.0f); pr_fDepthBufferNear = 0.0f; pr_fDepthBufferFar = 1.0f; pr_NearClipDistance = 0.25f; pr_FarClipDistance = -9999.0f; // never used by default pr_bMirror = FALSE; pr_bWarp = FALSE; pr_fViewStretch = 1.0f; } CPlacement3D _plOrigin(FLOAT3D(0,0,0), ANGLE3D(0,0,0));
/* * Prepare for projecting. */ void CPerspectiveProjection3D::Prepare(void) { FLOATmatrix3D t3dObjectStretch; // matrix for object stretch FLOATmatrix3D t3dObjectRotation; // matrix for object angles // calc. matrices for viewer and object angles and stretch MakeRotationMatrixFast( t3dObjectRotation, pr_ObjectPlacement.pl_OrientationAngle); MakeInverseRotationMatrixFast( pr_ViewerRotationMatrix, pr_ViewerPlacement.pl_OrientationAngle); t3dObjectStretch.Diagonal(pr_ObjectStretch); pr_vViewerPosition = pr_ViewerPlacement.pl_PositionVector; BOOL bXInverted = pr_ObjectStretch(1)<0; BOOL bYInverted = pr_ObjectStretch(2)<0; BOOL bZInverted = pr_ObjectStretch(3)<0; pr_bInverted = (bXInverted != bYInverted) != bZInverted; // if the projection is mirrored if (pr_bMirror) { // reflect viewer ReflectPositionVectorByPlane(pr_plMirror, pr_vViewerPosition); ReflectRotationMatrixByPlane_rows(pr_plMirror, pr_ViewerRotationMatrix); // get mirror plane in view space pr_plMirrorView = pr_plMirror; pr_plMirrorView -= pr_vViewerPosition; pr_plMirrorView *= pr_ViewerRotationMatrix; // invert inversion pr_bInverted = !pr_bInverted; } else if (pr_bWarp) { // get mirror plane in view space pr_plMirrorView = pr_plMirror; } // if the object is face-forward if (pr_bFaceForward) { // if it turns only heading if (pr_bHalfFaceForward) { // get the y-axis vector of object rotation FLOAT3D vY(t3dObjectRotation(1,2), t3dObjectRotation(2,2), t3dObjectRotation(3,2)); // find z axis of viewer FLOAT3D vViewerZ( pr_ViewerRotationMatrix(3,1), pr_ViewerRotationMatrix(3,2), pr_ViewerRotationMatrix(3,3)); // calculate x and z axis vectors to make object head towards viewer FLOAT3D vX = (-vViewerZ)*vY; vX.Normalize(); FLOAT3D vZ = vY*vX; // compose the rotation matrix back from those angles t3dObjectRotation(1,1) = vX(1); t3dObjectRotation(1,2) = vY(1); t3dObjectRotation(1,3) = vZ(1); t3dObjectRotation(2,1) = vX(2); t3dObjectRotation(2,2) = vY(2); t3dObjectRotation(2,3) = vZ(2); t3dObjectRotation(3,1) = vX(3); t3dObjectRotation(3,2) = vY(3); t3dObjectRotation(3,3) = vZ(3); // first apply object stretch then object rotation and then viewer rotation pr_mDirectionRotation = pr_ViewerRotationMatrix*t3dObjectRotation; pr_RotationMatrix = pr_mDirectionRotation*t3dObjectStretch; // if it is fully face forward } else { // apply object stretch and banking only FLOATmatrix3D mBanking; MakeRotationMatrixFast( mBanking, ANGLE3D(0,0, pr_ObjectPlacement.pl_OrientationAngle(3))); pr_mDirectionRotation = mBanking; pr_RotationMatrix = mBanking*t3dObjectStretch; } } else { // first apply object stretch then object rotation and then viewer rotation pr_mDirectionRotation = pr_ViewerRotationMatrix*t3dObjectRotation; pr_RotationMatrix = pr_mDirectionRotation*t3dObjectStretch; } // calc. offset of object from viewer pr_TranslationVector = pr_ObjectPlacement.pl_PositionVector - pr_vViewerPosition; // rotate offset only by viewer angles pr_TranslationVector = pr_TranslationVector*pr_ViewerRotationMatrix; // transform handle from object space to viewer space and add it to the offset pr_TranslationVector -= pr_vObjectHandle*pr_RotationMatrix; FLOAT2D vMin, vMax; // if using a shadow projection if (ppr_fMetersPerPixel>0) { // caclulate factors FLOAT fFactor = ppr_fViewerDistance/ppr_fMetersPerPixel; ppr_PerspectiveRatios(1) = -fFactor; ppr_PerspectiveRatios(2) = -fFactor; pr_ScreenCenter = -pr_ScreenBBox.Min(); vMin = pr_ScreenBBox.Min(); vMax = pr_ScreenBBox.Max(); // if using normal projection } else if (ppr_boxSubScreen.IsEmpty()) { // calculate perspective constants FLOAT2D v2dScreenSize = pr_ScreenBBox.Size(); pr_ScreenCenter = pr_ScreenBBox.Center(); /* calculate FOVHeight from FOVWidth by formula: halfanglej = atan( tan(halfanglei)*jsize*aspect/isize ) */ ANGLE aHalfI = ppr_FOVWidth/2; ANGLE aHalfJ = ATan(TanFast(aHalfI)*v2dScreenSize(2)*pr_AspectRatio/v2dScreenSize(1)); /* calc. perspective ratios by formulae: xratio = isize/(2*tan(anglei/2)) yratio = jsize/(2*tan(anglej/2)) sign is negative since viewer is looking down the -z axis */ ppr_PerspectiveRatios(1) = -v2dScreenSize(1)/(2.0f*TanFast(aHalfI))*pr_fViewStretch; ppr_PerspectiveRatios(2) = -v2dScreenSize(2)/(2.0f*TanFast(aHalfJ))*pr_fViewStretch; vMin = pr_ScreenBBox.Min()-pr_ScreenCenter; vMax = pr_ScreenBBox.Max()-pr_ScreenCenter; // if using sub-drawport projection } else { // calculate perspective constants FLOAT2D v2dScreenSize = pr_ScreenBBox.Size(); pr_ScreenCenter = pr_ScreenBBox.Center(); /* calculate FOVHeight from FOVWidth by formula: halfanglej = atan( tan(halfanglei)*jsize*aspect/isize ) */ ANGLE aHalfI = ppr_FOVWidth/2; ANGLE aHalfJ = ATan(TanFast(aHalfI)*v2dScreenSize(2)*pr_AspectRatio/v2dScreenSize(1)); /* calc. perspective ratios by formulae: xratio = isize/(2*tan(anglei/2)) yratio = jsize/(2*tan(anglej/2)) sign is negative since viewer is looking down the -z axis */ ppr_PerspectiveRatios(1) = -v2dScreenSize(1)/(2.0f*TanFast(aHalfI))*pr_fViewStretch; ppr_PerspectiveRatios(2) = -v2dScreenSize(2)/(2.0f*TanFast(aHalfJ))*pr_fViewStretch; vMin = ppr_boxSubScreen.Min()-pr_ScreenCenter; vMax = ppr_boxSubScreen.Max()-pr_ScreenCenter; pr_ScreenCenter -= ppr_boxSubScreen.Min(); } // find factors for left, right, up and down clipping FLOAT fMinI = vMin(1); FLOAT fMinJ = vMin(2); FLOAT fMaxI = vMax(1); FLOAT fMaxJ = vMax(2); FLOAT fRatioX = ppr_PerspectiveRatios(1); FLOAT fRatioY = ppr_PerspectiveRatios(2); #define MySgn(x) ((x)>=0?1:-1) FLOAT fDZ = -1.0f; FLOAT fDXL = fDZ*fMinI/fRatioX; FLOAT fDXR = fDZ*fMaxI/fRatioX; FLOAT fDYU = -fDZ*fMinJ/fRatioY; FLOAT fDYD = -fDZ*fMaxJ/fRatioY; FLOAT fNLX = -fDZ; FLOAT fNLZ = +fDXL; FLOAT fOoNL = 1.0f/(FLOAT)sqrt(fNLX*fNLX+fNLZ*fNLZ); fNLX*=fOoNL; fNLZ*=fOoNL; FLOAT fNRX = +fDZ; FLOAT fNRZ = -fDXR; FLOAT fOoNR = 1.0f/(FLOAT)sqrt(fNRX*fNRX+fNRZ*fNRZ); fNRX*=fOoNR; fNRZ*=fOoNR; FLOAT fNDY = -fDZ; FLOAT fNDZ = +fDYD; FLOAT fOoND = 1.0f/(FLOAT)sqrt(fNDY*fNDY+fNDZ*fNDZ); fNDY*=fOoND; fNDZ*=fOoND; FLOAT fNUY = +fDZ; FLOAT fNUZ = -fDYU; FLOAT fOoNU = 1.0f/(FLOAT)sqrt(fNUY*fNUY+fNUZ*fNUZ); fNUY*=fOoNU; fNUZ*=fOoNU; // make clip planes pr_plClipU = FLOATplane3D(FLOAT3D( 0,fNUY,fNUZ), 0.0f); pr_plClipD = FLOATplane3D(FLOAT3D( 0,fNDY,fNDZ), 0.0f); pr_plClipL = FLOATplane3D(FLOAT3D(fNLX, 0,fNLZ), 0.0f); pr_plClipR = FLOATplane3D(FLOAT3D(fNRX, 0,fNRZ), 0.0f); // mark as prepared pr_Prepared = TRUE; // calculate constant value used for calculating z-buffer k-value from vertex's z coordinate pr_fDepthBufferFactor = -pr_NearClipDistance; pr_fDepthBufferMul = pr_fDepthBufferFar-pr_fDepthBufferNear; pr_fDepthBufferAdd = pr_fDepthBufferNear; // calculate ratio for mip factor calculation ppr_fMipRatio = pr_ScreenBBox.Size()(1)/(ppr_PerspectiveRatios(1)*640.0f); }
void CPlayerProfileMenu::SelectPlayer(INDEX iPlayer) { CPlayerCharacter &pc = _pGame->gm_apcPlayers[iPlayer]; for (INDEX iPl = 0; iPl<8; iPl++) { gm_mgNumber[iPl].mg_bHighlighted = FALSE; } gm_mgNumber[iPlayer].mg_bHighlighted = TRUE; iPlayer = Clamp(iPlayer, INDEX(0), INDEX(7)); if (_iLocalPlayer >= 0 && _iLocalPlayer<4) { _pGame->gm_aiMenuLocalPlayers[_iLocalPlayer] = iPlayer; } else { _pGame->gm_iSinglePlayer = iPlayer; } gm_mgNameField.mg_pstrToChange = &pc.pc_strName; gm_mgNameField.SetText(*gm_mgNameField.mg_pstrToChange); gm_mgTeam.mg_pstrToChange = &pc.pc_strTeam; gm_mgTeam.SetText(*gm_mgTeam.mg_pstrToChange); CPlayerSettings *pps = (CPlayerSettings *)pc.pc_aubAppearance; gm_mgCrosshair.mg_iSelected = pps->ps_iCrossHairType + 1; gm_mgCrosshair.ApplyCurrentSelection(); gm_mgWeaponSelect.mg_iSelected = pps->ps_iWeaponAutoSelect; gm_mgWeaponSelect.ApplyCurrentSelection(); gm_mgWeaponHide.mg_iSelected = (pps->ps_ulFlags&PSF_HIDEWEAPON) ? 1 : 0; gm_mgWeaponHide.ApplyCurrentSelection(); gm_mg3rdPerson.mg_iSelected = (pps->ps_ulFlags&PSF_PREFER3RDPERSON) ? 1 : 0; gm_mg3rdPerson.ApplyCurrentSelection(); gm_mgQuotes.mg_iSelected = (pps->ps_ulFlags&PSF_NOQUOTES) ? 0 : 1; gm_mgQuotes.ApplyCurrentSelection(); gm_mgAutoSave.mg_iSelected = (pps->ps_ulFlags&PSF_AUTOSAVE) ? 1 : 0; gm_mgAutoSave.ApplyCurrentSelection(); gm_mgCompDoubleClick.mg_iSelected = (pps->ps_ulFlags&PSF_COMPSINGLECLICK) ? 0 : 1; gm_mgCompDoubleClick.ApplyCurrentSelection(); gm_mgViewBobbing.mg_iSelected = (pps->ps_ulFlags&PSF_NOBOBBING) ? 0 : 1; gm_mgViewBobbing.ApplyCurrentSelection(); gm_mgSharpTurning.mg_iSelected = (pps->ps_ulFlags&PSF_SHARPTURNING) ? 1 : 0; gm_mgSharpTurning.ApplyCurrentSelection(); // get function that will set player appearance CShellSymbol *pss = _pShell->GetSymbol("SetPlayerAppearance", /*bDeclaredOnly=*/ TRUE); // if none if (pss == NULL) { // no model gm_mgModel.mg_moModel.SetData(NULL); // if there is some } else { // set the model BOOL(*pFunc)(CModelObject *, CPlayerCharacter *, CTString &, BOOL) = (BOOL(*)(CModelObject *, CPlayerCharacter *, CTString &, BOOL))pss->ss_pvValue; CTString strName; BOOL bSet; if (_gmRunningGameMode != GM_SINGLE_PLAYER && !_bPlayerMenuFromSinglePlayer) { bSet = pFunc(&gm_mgModel.mg_moModel, &pc, strName, TRUE); gm_mgModel.mg_strTip = TRANS("change model for this player"); gm_mgModel.mg_bEnabled = TRUE; } else { // cannot change player appearance in single player mode bSet = pFunc(&gm_mgModel.mg_moModel, NULL, strName, TRUE); gm_mgModel.mg_strTip = TRANS("cannot change model for single-player game"); gm_mgModel.mg_bEnabled = FALSE; } // ignore gender flags, if any strName.RemovePrefix("#female#"); strName.RemovePrefix("#male#"); gm_mgModel.mg_plModel = CPlacement3D(FLOAT3D(0.1f, -1.0f, -3.5f), ANGLE3D(150, 0, 0)); gm_mgModel.mg_strText = strName; CPlayerSettings *pps = (CPlayerSettings *)pc.pc_aubAppearance; _strLastPlayerAppearance = pps->GetModelFilename(); try { gm_mgModel.mg_moFloor.SetData_t(CTFILENAME("Models\\Computer\\Floor.mdl")); gm_mgModel.mg_moFloor.mo_toTexture.SetData_t(CTFILENAME("Models\\Computer\\Floor.tex")); } catch (char *strError) { (void)strError; } } }