这篇教程C++ CVector函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CVector函数的典型用法代码示例。如果您正苦于以下问题:C++ CVector函数的具体用法?C++ CVector怎么用?C++ CVector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CVector函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CVectorBOOL CRVTrackerNodeMove::OnStart(){ // Only start if we're in brush or objectmode if ((m_pView->GetEditMode() != BRUSH_EDITMODE) && (m_pView->GetEditMode() != OBJECT_EDITMODE)) return FALSE; // Make sure something is selected if (!m_pView->GetRegion()->m_Selections.GetSize()) return FALSE; // If in handle mode, make sure we're clicking on a move handle if (m_bHandle) { // Any handle at all? int iCurHandle = m_pView->GetCurrentMouseOverHandle(); if (iCurHandle == -1) return FALSE; // A movement handle? CVector vDummy; if (m_pView->GetHandleInfo(iCurHandle, NULL, vDummy, vDummy)) return FALSE; } // Make a clone if needed if (m_bClone) { m_pView->GetRegionDoc()->Clone(); } // Default to successful start... BOOL bStart = TRUE; CVector vClosest; if(m_bSnap && m_pView->GetClosestPoint(m_cCurPt, vClosest, TRUE )) { // Make the closest point our starting position... m_vStartVec = vClosest; // Snap to grid... CEditGrid *pGrid = &m_pView->EditGrid(); m_vStartVec -= pGrid->Forward() * (pGrid->Forward().Dot(m_vStartVec - pGrid->Pos())); } else { if (!m_bSnap) { // Reset the move offset m_vTotalMoveOffset = CVector(0.0f, 0.0f, 0.0f); m_vMoveSnapAxis = CVector(1.0f, 1.0f, 1.0f); } // Find another point... bStart = m_pView->GetVertexFromPoint(m_cCurPt, m_vStartVec); } if( bStart ) m_pView->GetRegionDoc()->SetupUndoForSelections(); return bStart;}
开发者ID:Joincheng,项目名称:lithtech,代码行数:63,
示例2: memcpy///////////////////////////////////////////////////////////////// CVertexStreamBoundingBoxManager::ComputeVertexStreamBoundingBox//// Measure used vertices///////////////////////////////////////////////////////////////bool CVertexStreamBoundingBoxManager::ComputeVertexStreamBoundingBox ( SCurrentStateInfo2& state, uint ReadOffsetStart, uint ReadSize, CBox& outBoundingBox ){ IDirect3DVertexBuffer9* pStreamDataPT = state.stream.pStreamData; const uint StridePT = state.stream.Stride; uint NumVerts = ReadSize / StridePT; // Adjust for the offset in the stream ReadOffsetStart += state.stream.elementOffset; ReadSize -= state.stream.elementOffset; if ( ReadSize < 1 ) return false; // Get the source vertex bytes std::vector < uchar > sourceArray; sourceArray.resize ( ReadSize ); uchar* pSourceArrayBytes = &sourceArray[0]; { void* pVertexBytesPT = NULL; if ( FAILED( pStreamDataPT->Lock ( ReadOffsetStart, ReadSize, &pVertexBytesPT, D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY ) ) ) return false; memcpy ( pSourceArrayBytes, pVertexBytesPT, ReadSize ); pStreamDataPT->Unlock (); } // Compute bounds { // Get index data if ( FAILED( m_pDevice->GetIndices( &state.pIndexData ) ) ) return false; // Get index buffer desc D3DINDEXBUFFER_DESC IndexBufferDesc; state.pIndexData->GetDesc ( &IndexBufferDesc ); uint numIndices = state.args.primCount + 2; uint step = 1; if ( state.args.PrimitiveType == D3DPT_TRIANGLELIST ) { numIndices = state.args.primCount * 3; step = 3; } assert ( IndexBufferDesc.Size >= ( numIndices + state.args.startIndex ) * 2 ); // Get index buffer data std::vector < uchar > indexArray; indexArray.resize ( numIndices*2 ); uchar* pIndexArrayBytes = &indexArray[0]; { void* pIndexBytes = NULL; if ( FAILED( state.pIndexData->Lock ( state.args.startIndex*2, numIndices*2, &pIndexBytes, D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY ) ) ) return false; memcpy ( pIndexArrayBytes, pIndexBytes, numIndices*2 ); state.pIndexData->Unlock (); } CVector& vecMin = outBoundingBox.vecMin; CVector& vecMax = outBoundingBox.vecMax; vecMin = CVector ( 9999, 9999, 9999 ); vecMax = CVector ( -9999, -9999, -9999 ); // For each triangle for ( uint i = 0 ; i < numIndices - 2 ; i += step ) { // Get triangle vertex indici WORD v0 = ((WORD*)pIndexArrayBytes)[ i ]; WORD v1 = ((WORD*)pIndexArrayBytes)[ i + 1 ]; WORD v2 = ((WORD*)pIndexArrayBytes)[ i + 2 ]; if ( v0 >= NumVerts || v1 >= NumVerts || v2 >= NumVerts ) continue; // vert index out of range if ( v0 == v1 || v0 == v2 || v1 == v2 ) continue; // degenerate tri // Get vertex positions from original stream CVector* pPos0 = (CVector*)( pSourceArrayBytes + v0 * StridePT ); CVector* pPos1 = (CVector*)( pSourceArrayBytes + v1 * StridePT ); CVector* pPos2 = (CVector*)( pSourceArrayBytes + v2 * StridePT ); // Update min/max vecMin.fX = Min ( vecMin.fX, pPos0->fX ); vecMin.fY = Min ( vecMin.fY, pPos0->fY ); vecMin.fZ = Min ( vecMin.fZ, pPos0->fZ ); vecMax.fX = Max ( vecMax.fX, pPos0->fX ); vecMax.fY = Max ( vecMax.fY, pPos0->fY ); vecMax.fZ = Max ( vecMax.fZ, pPos0->fZ ); vecMin.fX = Min ( vecMin.fX, pPos1->fX ); vecMin.fY = Min ( vecMin.fY, pPos1->fY ); vecMin.fZ = Min ( vecMin.fZ, pPos1->fZ ); vecMax.fX = Max ( vecMax.fX, pPos1->fX );//.........这里部分代码省略.........
开发者ID:F420,项目名称:mtasa-blue,代码行数:101,
示例3: whilevoid CTestScenarioOffsetPursue::Initialize(CIATestMainWindow *pWindow){ CIAEntityBase *pTarget=new CIAEntityBase; pTarget->SetPosition(CVector(dBaseSize*0.3,dBaseSize*0.6,0)); pTarget->SetColor(CVector(0.5,0.5,0.5)); pTarget->SetSize(30); pWindow->AddEntity("Target",pTarget,true); CIAEntityBase *pLeader=new CIAEntityBase; pLeader->SetPosition(CVector(dBaseSize*0.3,dBaseSize*0.6,0)); pLeader->SetColor(CVector(0,0,0.5)); pLeader->SetSize(30); //pLeader->Wander(true,200,100,5000); pLeader->ArriveTarget(pTarget,eSBArriveSpeed_Normal); pWindow->AddEntity("Leader",pLeader,true); CVector pVectors[]={CVector(-30,-50,0),CVector(-30,50,0),CVector(-60,0,0),CVector(0,0,0)}; int nFollowers=0; while(pVectors[nFollowers]!=CVector(0,0,0)) { char sName[1024]; CIAEntityBase *pFollower=new CIAEntityBase; pFollower->SetPosition(CVector(dBaseSize*(0.2+((double)nFollowers)*0.1),dBaseSize*(0.2+((double)nFollowers)*0.1),0)); pFollower->SetColor(CVector(0.5,0,0)); pFollower->SetSize(20); pFollower->SetMaxVelocity(pLeader->GetMaxVelocity()*0.7); pFollower->SetMaxForce(pLeader->GetMaxForce()); pFollower->OffsetPursue(pLeader,pVectors[nFollowers]); pFollower->SetRenderFlags(RENDER_FLAGS_NONE); sprintf(sName,"Follower-%d",nFollowers+1); pWindow->AddEntity(sName,pFollower,true); nFollowers++; }}
开发者ID:theclai,项目名称:friking-shark,代码行数:34,
示例4: UNREFERENCED_PARAMETERvoid CCoronas::RegisterCorona(unsigned int nID, CEntity* pAttachTo, unsigned char R, unsigned char G, unsigned char B, unsigned char A, const CVector& Position, float Size, float Range, RwTexture* pTex, unsigned char flareType, unsigned char reflectionType, unsigned char LOSCheck, unsigned char unused, float normalAngle, bool bNeonFade, float PullTowardsCam, bool bFadeIntensity, float FadeSpeed, bool bOnlyFromBelow, bool bWhiteCore){ UNREFERENCED_PARAMETER(unused); CVector vecPosToCheck; if (pAttachTo) { // TODO: AllocateMatrix vecPosToCheck = *pAttachTo->GetMatrix() * Position; } else vecPosToCheck = Position; CVector* pCamPos = TheCamera.GetCoords(); if (Range * Range >= (pCamPos->x - vecPosToCheck.x)*(pCamPos->x - vecPosToCheck.x) + (pCamPos->y - vecPosToCheck.y)*(pCamPos->y - vecPosToCheck.y)) { if (bNeonFade) { float fDistFromCam = CVector(*pCamPos - vecPosToCheck).Magnitude(); if (fDistFromCam < 35.0f) return; if (fDistFromCam < 50.0f) A *= static_cast<unsigned char>((fDistFromCam - 35.0f) * (2.0f / 3.0f)); } // Is corona already present? CRegisteredCorona* pSuitableSlot; auto it = UsedMap.find(nID); if (it != UsedMap.end()) { pSuitableSlot = it->second->GetFrom(); if (pSuitableSlot->FadedIntensity == 0 && A == 0) { // Mark as free it->second->GetFrom()->Identifier = 0; it->second->Add(&FreeList); UsedMap.erase(nID); return; } } else { if (!A) return; // Adding a new element auto pNewEntry = FreeList.First(); if (!pNewEntry) { MessageBoxA(0, "ERROR: Not enough space for coronas!", "ERROR: Not enough space for coronas!", 0); return; } pSuitableSlot = pNewEntry->GetFrom(); // Add to used list and push this index to the map pNewEntry->Add(&UsedList); UsedMap[nID] = pNewEntry; pSuitableSlot->FadedIntensity = bFadeIntensity ? 255 : 0; pSuitableSlot->OffScreen = true; pSuitableSlot->JustCreated = true; pSuitableSlot->Identifier = nID; } pSuitableSlot->Red = R; pSuitableSlot->Green = G; pSuitableSlot->Blue = B; pSuitableSlot->Intensity = A; pSuitableSlot->Coordinates = Position; pSuitableSlot->Size = Size; pSuitableSlot->NormalAngle = normalAngle; pSuitableSlot->Range = Range; pSuitableSlot->pTex = pTex; pSuitableSlot->FlareType = flareType; pSuitableSlot->ReflectionType = reflectionType; pSuitableSlot->LOSCheck = LOSCheck; pSuitableSlot->RegisteredThisFrame = true; pSuitableSlot->PullTowardsCam = PullTowardsCam; pSuitableSlot->FadeSpeed = FadeSpeed; pSuitableSlot->NeonFade = bNeonFade; pSuitableSlot->OnlyFromBelow = bOnlyFromBelow; pSuitableSlot->WhiteCore = bWhiteCore; if (pAttachTo) { pSuitableSlot->bIsAttachedToEntity = true; pSuitableSlot->pEntityAttachedTo = pAttachTo; pAttachTo->RegisterReference(&pSuitableSlot->pEntityAttachedTo); } else { pSuitableSlot->bIsAttachedToEntity = false; pSuitableSlot->pEntityAttachedTo = nullptr; }//.........这里部分代码省略.........
开发者ID:ThirteenAG,项目名称:III.VC.SA.LimitAdjuster,代码行数:101,
示例5: CVectorvoid CEntity::Tick(CMap* pMap){ if(Mov != CVector(0,0) && CanMove(pMap, Mov)) Pos += Mov; Mov = CVector(0,0);}
开发者ID:Niautanor,项目名称:Abiturkomponente-5---Roguelike,代码行数:6,
示例6: CVectorvoid CEnemy10::Move() { Scale = CVector(1.2f, 1, 1)*0.22f; Position = Owner->Position + CVector(0.01, 0.06f, 0);}
开发者ID:owarisoranaki,项目名称:Homebrew-games,代码行数:4,
|