Example #1
0
CModelerDoc::CModelerDoc()
{
  // Default clipboard variables used for storing copy/paste data
  m_f3ClipboardCenter = FLOAT3D( 0.0f, 0.0f, 0.0f);
  m_fClipboardZoom = FLOAT( 0.0f);
  m_f3ClipboardHPB = FLOAT3D( 0.0f, 0.0f, 0.0f);
  m_iCurrentMip = 0;
}
CEmittedParticle::CEmittedParticle(void)
{
  ep_tmEmitted=-1;
  ep_tmLife=1.0f;
  ep_colColor=C_WHITE|CT_OPAQUE;
  ep_vSpeed=FLOAT3D(0,0,0);
  ep_vPos=FLOAT3D(0,0,0);
  ep_fStretch=1;
  ep_fRot=0;
  ep_fRotSpeed=0;
}
/* Test if an oriented box in view space is inside view frustum. */
INDEX CPerspectiveProjection3D::TestBoxToFrustum(const FLOATobbox3D &box) const
{
  ASSERT( pr_Prepared);
  INDEX iPass = 1;
  INDEX iTest;

  // check to near
  iTest = (INDEX) box.TestAgainstPlane( FLOATplane3D(FLOAT3D(0,0,-1), pr_NearClipDistance));
  if( iTest<0) {
    return -1;
  } else if( iTest==0) {
    iPass = 0;
  }
  // check to far
  if( pr_FarClipDistance>0) {
    iTest = (INDEX) box.TestAgainstPlane( FLOATplane3D(FLOAT3D(0,0,1), -pr_FarClipDistance));
    if( iTest<0) {
      return -1;
    } else if( iTest==0) {
      iPass = 0;
    }
  }
  // check to left
  iTest = (INDEX) box.TestAgainstPlane(pr_plClipL);
  if( iTest<0) {
    return -1;
  } else if( iTest==0) {
    iPass = 0;
  }
  // check to right
  iTest = (INDEX) box.TestAgainstPlane(pr_plClipR);
  if( iTest<0) {
    return -1;
  } else if( iTest==0) {
    iPass = 0;
  }
  // check to up
  iTest = (INDEX) box.TestAgainstPlane(pr_plClipU);
  if( iTest<0) {
    return -1;
  } else if( iTest==0) {
    iPass = 0;
  }
  // check to down
  iTest = (INDEX) box.TestAgainstPlane(pr_plClipD);
  if( iTest<0) {
    return -1;
  } else if( iTest==0) {
    iPass = 0;
  }
  // all done
  return iPass;
}
/*
 * 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;
}
// TEMP - Draw one AABBox
void gfxDrawWireBox(FLOATaabbox3D &bbox, COLOR col)
{
  FLOAT3D vMinVtx = bbox.Min();
  FLOAT3D vMaxVtx = bbox.Max();
  // fill vertex array so it represents bounding box
  FLOAT3D vBoxVtxs[8];
  vBoxVtxs[0] = FLOAT3D( vMinVtx(1), vMinVtx(2), vMinVtx(3));
  vBoxVtxs[1] = FLOAT3D( vMaxVtx(1), vMinVtx(2), vMinVtx(3));
  vBoxVtxs[2] = FLOAT3D( vMaxVtx(1), vMinVtx(2), vMaxVtx(3));
  vBoxVtxs[3] = FLOAT3D( vMinVtx(1), vMinVtx(2), vMaxVtx(3));
  vBoxVtxs[4] = FLOAT3D( vMinVtx(1), vMaxVtx(2), vMinVtx(3));
  vBoxVtxs[5] = FLOAT3D( vMaxVtx(1), vMaxVtx(2), vMinVtx(3));
  vBoxVtxs[6] = FLOAT3D( vMaxVtx(1), vMaxVtx(2), vMaxVtx(3));
  vBoxVtxs[7] = FLOAT3D( vMinVtx(1), vMaxVtx(2), vMaxVtx(3));

  // connect vertices into lines of bounding box
  INDEX iBoxLines[12][2];
  iBoxLines[ 0][0] = 0;  iBoxLines[ 0][1] = 1;  iBoxLines[ 1][0] = 1;  iBoxLines[ 1][1] = 2;
  iBoxLines[ 2][0] = 2;  iBoxLines[ 2][1] = 3;  iBoxLines[ 3][0] = 3;  iBoxLines[ 3][1] = 0;
  iBoxLines[ 4][0] = 0;  iBoxLines[ 4][1] = 4;  iBoxLines[ 5][0] = 1;  iBoxLines[ 5][1] = 5;
  iBoxLines[ 6][0] = 2;  iBoxLines[ 6][1] = 6;  iBoxLines[ 7][0] = 3;  iBoxLines[ 7][1] = 7;
  iBoxLines[ 8][0] = 4;  iBoxLines[ 8][1] = 5;  iBoxLines[ 9][0] = 5;  iBoxLines[ 9][1] = 6;
  iBoxLines[10][0] = 6;  iBoxLines[10][1] = 7;  iBoxLines[11][0] = 7;  iBoxLines[11][1] = 4;
  // for all vertices in bounding box
  for( INDEX i=0; i<12; i++) {
    // get starting and ending vertices of one line
    FLOAT3D &v0 = vBoxVtxs[iBoxLines[i][0]];
    FLOAT3D &v1 = vBoxVtxs[iBoxLines[i][1]];
    _pdp->DrawLine3D(v0,v1,col);
  } 
}
Example #6
0
void CDlgClient::OnBtResetColision() 
{
	CSeriousSkaStudioDoc *pDoc = theApp.GetDocument();
  NodeInfo &ni = theApp.m_dlgBarTreeView.GetSelectedNodeInfo();
  if(ni.ni_iType == NT_COLISIONBOX) {
    ColisionBox &cb = *(ColisionBox*)ni.ni_pPtr;
    cb.SetMax(FLOAT3D(0.5,2,0.5));
    cb.SetMin(FLOAT3D(-0.5,0,-0.5));
  } else {
    ASSERT(FALSE);
  }

  theApp.ReselectCurrentItem();
  pDoc->MarkAsChanged();
}
Example #7
0
// 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);
  }
}
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;
}
Example #9
0
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;
}
Example #10
0
/*
 * Create direction vector from angles in 3D (ignoring banking).
 */
void AnglesToDirectionVector(const ANGLE3D &a3dAngles, FLOAT3D &vDirection)
{
  // find the rotation matrix from the angles
  FLOATmatrix3D mDirection;
  MakeRotationMatrix(mDirection, a3dAngles);
  // rotate a front oriented vector by the matrix
  vDirection = FLOAT3D(0.0f, 0.0f, -1.0f)*mDirection;
}
FLOAT3D CEmiter::GetGravity(CEntity *pen)
{
  if(pen->GetPhysicsFlags()&EPF_MOVABLE)
  {
    return ((CMovableEntity *)pen)->en_vGravityDir*
           ((CMovableEntity *)pen)->en_fGravityA;
  }
  return FLOAT3D(0,-10.0f,0);
}
CDlgCPESphereProperty::CDlgCPESphereProperty(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgCPESphereProperty::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgCPESphereProperty)
	m_fDelayTime = 0.0f;
	//}}AFX_DATA_INIT
	m_force.SetZeroForce();
	m_sphere.SetRadius(FLOAT3D(0,0,0), 0, 0);
}
// check if all of the corners of entity's bounding box are influenced by current select-on-render selection
void SelectEntityOnRender(CProjection3D &prProjection, CEntity &en)
{
  FLOATaabbox3D bbox;

  FLOATmatrix3D mOne = FLOATmatrix3D(0.0f);
  mOne.Diagonal(1.0f);
  FLOATmatrix3D *pmR;
  FLOAT3D vOffset;

  // if this entity is model
  if (en.en_RenderType==CEntity::RT_MODEL || en.en_RenderType==CEntity::RT_EDITORMODEL)
  {
    // get bbox of current frame
    CModelObject *pmo = en.GetModelObject();
    pmo->GetCurrentFrameBBox( bbox);
    pmR = &en.en_mRotation;
    vOffset = en.GetPlacement().pl_PositionVector;
  }
  // if it is ska model
  else if(en.en_RenderType==CEntity::RT_SKAMODEL || en.en_RenderType==CEntity::RT_SKAEDITORMODEL)
  {
    en.GetModelInstance()->GetCurrentColisionBox( bbox);
    pmR = &en.en_mRotation;
    vOffset = en.GetPlacement().pl_PositionVector;
  }
  // if it is brush
  else
  {
    // get bbox of brush's first mip
    CBrush3D *pbr = en.GetBrush();
    CBrushMip *pbrmip = pbr->GetFirstMip();
    bbox = pbrmip->bm_boxBoundingBox;
    pmR = &mOne;
    vOffset = FLOAT3D( 0.0f, 0.0f, 0.0f);
  }

  if( IsBoundingBoxInLasso( prProjection, bbox, pmR, vOffset))
  {
    if( _bSelectAlternative)
    {
      // deselect
      if (en.IsSelected(ENF_SELECTED))
      {
        _pselenSelectOnRender->Deselect(en);
      }
    }
    else
    {
      // select
      if (!en.IsSelected(ENF_SELECTED))
      {
        _pselenSelectOnRender->Select(en);
      }
    }
  }
}
CModelInstance::CModelInstance()
{
  mi_psklSkeleton = NULL;
  mi_iParentBoneID = -1;
  mi_colModelColor = 0;
  mi_vStretch = FLOAT3D(1,1,1);
  mi_colModelColor = 0xFFFFFFFF;
  mi_aqAnims.aq_Lists.SetAllocationStep(1);
  mi_cmiChildren.SetAllocationStep(1);
  memset(&mi_qvOffset,0,sizeof(QVect));
  mi_qvOffset.qRot.q_w = 1;
  mi_iCurentBBox = -1;
  // set default all frames bbox
//  mi_cbAllFramesBBox.SetName("All Frames Bounding box");
  mi_cbAllFramesBBox.SetMin(FLOAT3D(-0.5,0,-0.5));
  mi_cbAllFramesBBox.SetMax(FLOAT3D(0.5,2,0.5));
  // Set default model instance name
//  SetName("Noname");
}
void CDlgCPESphereProperty::Clear()
{
	m_fDelayTime = 0;
	m_force = CForce();
	m_force.SetZeroForce();
	m_sphere = CSphereDoubleSpace();
	m_sphere.SetRadius(FLOAT3D(0,0,0), 0, 0);

	UpdateData(SAVETOFORM);
}
static FLOATaabbox3D CalculateAABBoxFromRect(CTerrain *ptrTerrain, Rect rcExtract)
{
  ASSERT(ptrTerrain!=NULL);
  ASSERT(ptrTerrain->tr_penEntity!=NULL);

  // Get entity that holds this terrain
  //CEntity *penEntity = ptrTerrain->tr_penEntity;

  FLOATaabbox3D bboxExtract;
  FLOATaabbox3D bboxAllTerrain;
  ptrTerrain->GetAllTerrainBBox(bboxAllTerrain);

  FLOAT fMinY = bboxAllTerrain.minvect(2);
  FLOAT fMaxY = bboxAllTerrain.maxvect(2);

  bboxExtract.minvect = FLOAT3D(rcExtract.rc_iLeft  * ptrTerrain->tr_vStretch(1),fMinY,rcExtract.rc_iTop    * ptrTerrain->tr_vStretch(3));
  bboxExtract.maxvect = FLOAT3D(rcExtract.rc_iRight * ptrTerrain->tr_vStretch(1),fMaxY,rcExtract.rc_iBottom * ptrTerrain->tr_vStretch(3));
  return bboxExtract;
}
Example #17
0
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;
}
CEmiter::CEmiter(void)
{
  em_etType=ET_AIR_ELEMENTAL;
  em_bInitialized=FALSE;
  em_tmStart=-1;
  em_tmLife=0;
  em_vG=FLOAT3D(0,1,0);
  em_colGlobal=C_WHITE|CT_OPAQUE;
  em_iGlobal=0;
  em_aepParticles.Clear();
}
Example #19
0
// calculate default texture mapping control points from a plane
void CMappingVectors::FromPlane(const FLOATplane3D &plPlane)
{
  // take origin at plane reference point
  mv_vO = plPlane.ReferencePoint();

  // if the plane is mostly horizontal
  if (Abs(plPlane(2))>0.5) {
    // use cross product of +x axis and plane normal as +s axis
    mv_vU = FLOAT3D(1.0f, 0.0f, 0.0f)*(FLOAT3D&)plPlane;
  // if the plane is mostly vertical
  } else {
    // use cross product of +y axis and plane normal as +s axis
    mv_vU = FLOAT3D(0.0f, 1.0f, 0.0f)*(FLOAT3D&)plPlane;
  }
  // make +s axis normalized
  mv_vU.Normalize();

  // use cross product of plane normal and +s axis as +t axis
  mv_vV = mv_vU*(FLOAT3D &)plPlane;
}
// 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);
}
// Stretch model instance without attachments
void CModelInstance::StretchSingleModel(FLOAT3D &vStretch)
{
  mi_vStretch = vStretch;
  // for each child of model instance
  INDEX ctch = mi_cmiChildren.Count();
  for(INDEX ich=0;ich<ctch;ich++) {
    // set new stretch of model instance
    CModelInstance &chmi = mi_cmiChildren[ich];
    chmi.StretchSingleModel(FLOAT3D(1/vStretch(1),1/vStretch(2),1/vStretch(3)));
  }
}
void DrawSelectedVertices(GFXVertex *pavVertices, GFXColor *pacolColors, INDEX ctVertices)
{
  gfxEnableDepthBias();
  // for each vertex
  for(INDEX ivx=0;ivx<ctVertices;ivx++) {
    GFXVertex &vtx = pavVertices[ivx];
    GFXColor  &col = pacolColors[ivx];
    // draw vertex
    _pdp->DrawPoint3D(FLOAT3D(vtx.x,vtx.y,vtx.z),ByteSwap(col.ul.abgr),3);
  }
  gfxDisableDepthBias();
}
Example #23
0
/* Create angles in 3D from up vector (ignoring objects relative heading).
   (up vector must be normalized!)*/
void UpVectorToAngles(const FLOAT3D &vY, ANGLE3D &a3dAngles)
{
  // create any front vector
  FLOAT3D vZ;
  if (Abs(vY(2))>0.5f) {
    vZ = FLOAT3D(1,0,0)*vY;
  } else {
    vZ = FLOAT3D(0,1,0)*vY;
  }
  vZ.Normalize();
  // side vector is cross product
  FLOAT3D vX = vY*vZ;
  vX.Normalize();
  // create the rotation matrix
  FLOATmatrix3D m;
  m(1,1) = vX(1); m(1,2) = vY(1); m(1,3) = vZ(1);
  m(2,1) = vX(2); m(2,2) = vY(2); m(2,3) = vZ(2);
  m(3,1) = vX(3); m(3,2) = vY(3); m(3,3) = vZ(3);

  // decompose the matrix without snapping
  DecomposeRotationMatrixNoSnap(a3dAngles, m);
}
Example #24
0
void CDlgCPEConeProperty::Clear()
{
    m_bUsePos = FALSE;
    m_bUseSpeed = TRUE;
    m_fSpeedLower = 0;
    m_fSpeedUpper = 0;
    m_cone = CConeDoubleSpace();
    m_cone.SetAngle(0,0);
    m_cone.SetCenter(FLOAT3D(0,0,0));
    m_cone.SetHeight(0,0);

    UpdateData(SAVETOFORM);
}
Example #25
0
// Calculate lightning for given model
void shaCalculateLightForSpecular(void)
{
  ASSERT(_paNormals!=NULL);
  _acolVtxColors.PopAll();
  _acolVtxColors.Push(_ctVertices);

  GFXColor colModel   = (GFXColor)_colModel;   // Model color
  GFXColor &colAmbient = (GFXColor)_colAmbient; // Ambient color
  GFXColor &colLight   = (GFXColor)_colLight;   // Light color
  GFXColor &colSurface = (GFXColor)_colConstant; // shader color

  // colModel = MulColors(colModel.r,colSurface.abgr);
  colModel.MultiplyRGBA(colModel,colSurface);

  UBYTE ubColShift = 8;
  SLONG slar = colAmbient.r;
  SLONG slag = colAmbient.g;
  SLONG slab = colAmbient.b;

  if(shaOverBrightningEnabled()) {
    slar = ClampUp(slar,127L);
    slag = ClampUp(slag,127L);
    slab = ClampUp(slab,127L);
    ubColShift = 8;
  } else {
    slar*=2;
    slag*=2;
    slab*=2;
    ubColShift = 7;
  }

  // for each vertex color
  for(INDEX ivx=0;ivx<_ctVertices;ivx++) {
    // calculate vertex light
    FLOAT3D &vNorm = FLOAT3D(_paNormals[ivx].nx,_paNormals[ivx].ny,_paNormals[ivx].nz);
    FLOAT fDot = vNorm % _vLightDir;
    fDot = Clamp(fDot,0.0f,1.0f);
    SLONG slDot = NormFloatToByte(fDot);

    _acolVtxColors[ivx].r = ClampUp(colModel.r * (slar + ((colLight.r * slDot)>>ubColShift))>>8,255L);
    _acolVtxColors[ivx].g = ClampUp(colModel.g * (slag + ((colLight.g * slDot)>>ubColShift))>>8,255L);
    _acolVtxColors[ivx].b = ClampUp(colModel.b * (slab + ((colLight.b * slDot)>>ubColShift))>>8,255L);
    _acolVtxColors[ivx].a = slDot;//colModel.a;//slDot;
  }
  // Set current wertex array 
  _pcolVtxColors = &_acolVtxColors[0];
}
Example #26
0
// render bounding box
static void RenderWireframeBox( FLOAT3D vMinVtx, FLOAT3D vMaxVtx, COLOR col)
{
  // only for OpenGL (for now)
  if( _pGfx->gl_eCurrentAPI!=GAT_OGL) return;

  // prepare wireframe OpenGL settings
  gfxDisableDepthTest();
  gfxDisableDepthWrite();
  gfxDisableBlend();
  gfxDisableAlphaTest();
  gfxDisableTexture();
  // fill vertex array so it represents bounding box
  FLOAT3D vBoxVtxs[8];
  vBoxVtxs[0] = FLOAT3D( vMinVtx(1), vMinVtx(2), vMinVtx(3));
  vBoxVtxs[1] = FLOAT3D( vMaxVtx(1), vMinVtx(2), vMinVtx(3));
  vBoxVtxs[2] = FLOAT3D( vMaxVtx(1), vMinVtx(2), vMaxVtx(3));
  vBoxVtxs[3] = FLOAT3D( vMinVtx(1), vMinVtx(2), vMaxVtx(3));
  vBoxVtxs[4] = FLOAT3D( vMinVtx(1), vMaxVtx(2), vMinVtx(3));
  vBoxVtxs[5] = FLOAT3D( vMaxVtx(1), vMaxVtx(2), vMinVtx(3));
  vBoxVtxs[6] = FLOAT3D( vMaxVtx(1), vMaxVtx(2), vMaxVtx(3));
  vBoxVtxs[7] = FLOAT3D( vMinVtx(1), vMaxVtx(2), vMaxVtx(3));
  // connect vertices into lines of bounding box
  INDEX iBoxLines[12][2];
  iBoxLines[ 0][0] = 0;  iBoxLines[ 0][1] = 1;  iBoxLines[ 1][0] = 1;  iBoxLines[ 1][1] = 2;
  iBoxLines[ 2][0] = 2;  iBoxLines[ 2][1] = 3;  iBoxLines[ 3][0] = 3;  iBoxLines[ 3][1] = 0;
  iBoxLines[ 4][0] = 0;  iBoxLines[ 4][1] = 4;  iBoxLines[ 5][0] = 1;  iBoxLines[ 5][1] = 5;
  iBoxLines[ 6][0] = 2;  iBoxLines[ 6][1] = 6;  iBoxLines[ 7][0] = 3;  iBoxLines[ 7][1] = 7;
  iBoxLines[ 8][0] = 4;  iBoxLines[ 8][1] = 5;  iBoxLines[ 9][0] = 5;  iBoxLines[ 9][1] = 6;
  iBoxLines[10][0] = 6;  iBoxLines[10][1] = 7;  iBoxLines[11][0] = 7;  iBoxLines[11][1] = 4;
  // for all vertices in bounding box
  glCOLOR(col);
  pglBegin( GL_LINES);
  for( INDEX i=0; i<12; i++) {
    // get starting and ending vertices of one line
    FLOAT3D &v0 = vBoxVtxs[iBoxLines[i][0]];
    FLOAT3D &v1 = vBoxVtxs[iBoxLines[i][1]];
    pglVertex3f( v0(1), v0(2), v0(3));
    pglVertex3f( v1(1), v1(2), v1(3));
  } 
  pglEnd();
  OGL_CHECKERROR;
}
// check if given bounding box is selected by lasso
BOOL IsBoundingBoxInLasso( CProjection3D &prProjection, const FLOATaabbox3D &box, FLOATmatrix3D *pmR, FLOAT3D &vOffset)
{
  FLOAT3D vMin = box.Min();
  FLOAT3D vMax = box.Max();

  // test lasso influence for all of bounding box's vertices
  if(
    IsVertexInLasso( prProjection, FLOAT3D( vMin(1), vMin(2), vMin(3)), pmR, vOffset) &&
    IsVertexInLasso( prProjection, FLOAT3D( vMax(1), vMin(2), vMin(3)), pmR, vOffset) &&
    IsVertexInLasso( prProjection, FLOAT3D( vMin(1), vMax(2), vMin(3)), pmR, vOffset) &&
    IsVertexInLasso( prProjection, FLOAT3D( vMax(1), vMax(2), vMin(3)), pmR, vOffset) &&
    IsVertexInLasso( prProjection, FLOAT3D( vMin(1), vMin(2), vMax(3)), pmR, vOffset) &&
    IsVertexInLasso( prProjection, FLOAT3D( vMax(1), vMin(2), vMax(3)), pmR, vOffset) &&
    IsVertexInLasso( prProjection, FLOAT3D( vMin(1), vMax(2), vMax(3)), pmR, vOffset) &&
    IsVertexInLasso( prProjection, FLOAT3D( vMax(1), vMax(2), vMax(3)), pmR, vOffset) )
  {
    return TRUE;
  }
  return FALSE;
}
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 CDlgCCameraEffectProperty::OnBtnListAddmod() 
{
	UpdateData(SAVETOOBJECT);

	CCameraEffect::CCameraValue cv;
	cv.m_fHorizonal = m_fWidth;
	cv.m_fVertical = m_fHeight;
	cv.m_fTwist = m_fTwist;
	cv.m_fZoom = m_fZoom;
	cv.m_vMoveByCharCoord = FLOAT3D(m_fMoveX, m_fMoveY, m_fMoveZ);
	int index = m_ssCameraShake.AddSample(m_fTime, cv);
	if(index == -1)	//modify
	{
		int i = 0;
		int count = m_ssCameraShake.GetSampleCount();
		for( i = 0; i < count; ++i)
		{
			if(m_ssCameraShake.GetKey(i) == m_fTime) break;
		}
		index = i;
		m_ssCameraShake.RemoveSample(index);
		m_lbCameraShake.DeleteString(index);
		m_ssCameraShake.AddSample(m_fTime, cv);
	}

	char buf[256];
	sprintf(buf, szFormat
				, m_fTime
				, m_fWidth
				, m_fHeight
				, m_fTwist
				, m_fZoom
				, m_fMoveX
				, m_fMoveY
				, m_fMoveZ
				);
	index = m_lbCameraShake.InsertString(index, buf);
	
	m_lbCameraShake.SetCurSel(index);
	OnSelchangeList();
}
Example #30
0
static FLOATaabbox3D AddAllVerticesToBBox(CModelInstance &mi)
{
  FLOATmatrix3D mat;
  FLOAT3D vPos = FLOAT3D(0,0,0);
  mat.Diagonal(1);
  CStaticStackArray<FLOAT3D> avVertices;
  mi.GetModelVertices(avVertices,mat,vPos,0,0);

  INDEX ctvtx = avVertices.Count();
  // if at least one vertex exists
  FLOATaabbox3D bbox;
  if(ctvtx>0) {
    bbox = FLOATaabbox3D(avVertices[0]);
    // for each vertex after first one
    for(INDEX ivx=1;ivx<ctvtx;ivx++) {
      // add this vertex position to all frames bbox
      bbox |= FLOATaabbox3D(avVertices[ivx]);
    }
  }
  return bbox;
}