本文整理汇总了C++中CVector函数的典型用法代码示例。如果您正苦于以下问题:C++ CVector函数的具体用法?C++ CVector怎么用?C++ CVector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CVector函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CVector
BOOL 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,代码来源:RVTrackerNodeMove.cpp
示例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,代码来源:CVertexStreamBoundingBoxManager.cpp
示例3: while
void 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,代码来源:TestScenarios.cpp
示例4: UNREFERENCED_PARAMETER
void 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,代码来源:Coronas.cpp
示例5: CVector
void CEntity::Tick(CMap* pMap)
{
if(Mov != CVector(0,0) && CanMove(pMap, Mov))
Pos += Mov;
Mov = CVector(0,0);
}
开发者ID:Niautanor,项目名称:Abiturkomponente-5---Roguelike,代码行数:6,代码来源:Entity.cpp
示例6: CVector
void CEnemy10::Move() {
Scale = CVector(1.2f, 1, 1)*0.22f;
Position = Owner->Position + CVector(0.01, 0.06f, 0);
}
开发者ID:owarisoranaki,项目名称:Homebrew-games,代码行数:4,代码来源:Enemy.cpp
示例7: Apply
// 敵の移動
void CEnemy::Move() {
CHitRectangle hit;
Apply(BlockList, hit);
Apply(Block1List, hit);
Apply(Block2List, hit);
Apply(Block3List, hit);
Apply(Block5List, hit);
Apply(Block6List, hit);
Apply(Block7List, hit);
Apply(Block8List, hit);
Apply(Block9List, hit);
Apply(Block10List, hit);
Apply(Block11List, hit);
Apply(Block12List, hit);
Apply(Block13List, hit);
Apply(Block14List, hit);
Apply(Block15List, hit);
Apply(Block16List, hit);
Apply(Block17List, hit);
Apply(Block18List, hit);
Apply(Block19List, hit);
Apply(Block20List, hit);
Apply(Block22List, hit);
Apply(Block23List, hit);
Apply(Block28List, hit);
Apply(Block29List, hit);
//Apply(EnemyList, hit);
Velocity.Y -= 0.002f;
Position += Velocity;
Block3List.Apply([&](CMover* b) {//赤ブロック接触
if (Length(Position - b->Position) < 0.21f) {
Color.A = 1;
Ept = 1;
}
});
Block5List.Apply([&](CMover* b) {//黒ブロック接触
if (Length(Position - b->Position) < 0.21f) {
Color.A = 1;
Ept = 2;
}
});
if (Ept == 1){//左向き
if (Time % 30 == 10)Texture = GetTexture(L"kuma_r.png");
if (Time % 30 == 20)Texture = GetTexture(L"kuma_r1.png");
if (Time % 30 == 25)Texture = GetTexture(L"kuma_r2.png");
Time++;
}
if (Ept == 2){//右向き
if (Time % 30 == 10)Texture = GetTexture(L"kuma_l.png");
if (Time % 30 == 20)Texture = GetTexture(L"kuma_l1.png");
if (Time % 30 == 25)Texture = GetTexture(L"kuma_l2.png");
Time++;
}
MyShipList.Apply([&](CMover* m) {
float f = Length(Position - m->Position);//自機と敵との距離計算
if (f < 0.2 && Ept == 1 && hit.Down){//左近距離行動
Velocity.Y += 0.03f;
Velocity.X -= 0.012f;
Position += Velocity;
}
if (f < 1.5 &&f > 0.2 && Ept == 1){//左中距離行動
if (Time % 40 == 5)New<CWeapon6>(Position, CVector(-0.05f, 0, 0));
Time++;
if (hit.Down)Position.X += -0.005f;
}
if (f < 0.2 && Ept == 2 && hit.Down){//右近距離行動
Velocity.Y += 0.03f;
Velocity.X += 0.012f;
Position += Velocity;
}
if (f < 1.5 &&f > 0.2 && Ept == 2){//右中距離行動
if (Time % 40 == 5)New<CWeapon6>(Position, CVector(0.05f, 0, 0));
Time++;
if (hit.Down)Position.X += 0.005f;
}
});
}
开发者ID:owarisoranaki,项目名称:Homebrew-games,代码行数:89,代码来源:Enemy.cpp
示例8: CTransitionFadeIn
void Stage_001::Update()
{
m_frame++;
m_pConnection->Update();
for (int i = 0; i < MAX_MULTI_PLAYER; i++) {
if (m_clientPositionQueues[i].empty() || 0 == m_pOtherPlayers[i]) {
continue;
}
m_pOtherPlayers[i]->position = m_clientPositionQueues[i].front();
m_clientPositionQueues[i].pop();
}
bool isMove = false;
CVector moveVector = m_pPlayer->GetMoveVector();
if (sKeyPadManager->GetMainKeyPad()->IsOn(KeyPadLeft)) {
isMove = true;
moveVector.x -= 4.0f;
}
/*
if (sKeyPadManager->GetMainKeyPad()->IsOn(KeyPadTop)) {
isMove = true;
moveVector.y -= 4.0f;
}*/
if (sKeyPadManager->GetMainKeyPad()->IsOn(KeyPadRight)) {
isMove = true;
moveVector.x += 4.0f;
}
/*
if (sKeyPadManager->GetMainKeyPad()->IsOn(KeyPadBottom)) {
isMove = true;
moveVector.y += 4.0f;
}*/
if (0.0f == moveVector.y && sKeyPadManager->GetMainKeyPad()->IsPress(KeyPadA)) {
isMove = true;
moveVector.y -= 16.0f;
if (sKeyPadManager->GetMainKeyPad()->IsOn(KeyPadB)) {
moveVector.y -= 4.0f;
}
}
if (isMove) {
m_pPlayer->SetMoveVector(moveVector);
if (sKeyPadManager->GetMainKeyPad()->IsOn(KeyPadB)) {
m_pPlayer->AddMoveVector(CVector(moveVector.x, 0.0f, 0.0f));
}
}
if (sKeyPadManager->GetMainKeyPad()->IsPress(KeyPadStart)) {
if (0 == CSocket::GetIP()) {
m_pView->SetTransition(new CTransitionFadeIn(0.2f, this, Stage_001TransitionID_Entry));
m_pView->RunTransition();
}
else {
m_pConnection->Search();
}
}
CRect drawRect = GetDrawRect();
CRect stepRect = CRect(drawRect.left - m_drawSize.width, drawRect.top - m_drawSize.height, drawRect.right + m_drawSize.width, drawRect.bottom + m_drawSize.height);
m_pWorld->Step(stepRect);
std::list<CBody *> bodies = m_pWorld->GetBodyList();
std::list<CBody *>::iterator i = bodies.begin();
while (i != bodies.end()) {
CRect bodyRect = (*i)->GetRect();
if (CCollision::RectOnRect(bodyRect, drawRect)) {
CPoint position = (*i)->position;
position.x -= m_drawOffset.x;
CView *surface = (*i)->GetSurface();
surface->SetPosition(position);
}
++i;
}
CVector vector = m_pPlayer->GetMoveVector();
vector.x = 0.0f;
m_pPlayer->SetMoveVector(vector);
// プレイヤーの位置に合わせてステージの表示領域を移動
CPoint center = CPoint(m_drawOffset.x + m_drawSize.width / 2.0f, m_drawOffset.y + m_drawSize.height / 2.0f);
m_drawOffset.x += m_pPlayer->GetRect().right - center.x;
if (0.0f > m_drawOffset.x || (0.0f >= (GetStageSize().width - m_drawSize.width))) {
m_drawOffset.x = 0.0f;
}
else if ((GetStageSize().width - m_drawSize.width) < m_drawOffset.x) {
m_drawOffset.x = GetStageSize().width - m_drawSize.width;
}
CPoint realPosition = m_pPlayer->GetSurface()->GetPosition() + m_drawOffset;
m_pConnection->Move(realPosition);
}
开发者ID:ttoApps,项目名称:wizapply_library_by_cpp_study,代码行数:99,代码来源:Stage_001.cpp
示例9: CVector
CPolygon::CPolygon()
{
//not computed
m_cached_midpoint = CVector(FLT_EPSILON,FLT_EPSILON,FLT_EPSILON);
m_normal = CVector(FLT_EPSILON,FLT_EPSILON,FLT_EPSILON);
}
开发者ID:PNZA,项目名称:ICT290,代码行数:6,代码来源:polygon.cpp
示例10: mrqmin
void mrqmin( double x[], double y[], double sig[], int ndata, CVector a,
int ia[], int ma, CMatrix covar, CMatrix alpha, double *chisq,
void (*funcs)(double, double [], double *, double [], int),
double *alamda)
{
int j,k,l,m;
static int mfit;
static double ochisq;
CMatrix oneda;
CVector atry,beta,da;
if (*alamda < 0.0) {
atry=CVector(1,ma);
beta=CVector(1,ma);
da=CVector(1,ma);
for (mfit=0,j=1;j<=ma;j++)
if (ia[j]) mfit++;
oneda=CMatrix(1,mfit);
*alamda=0.001;
mrqcof(x,y,sig,ndata,a,ia,ma,alpha,beta,chisq,funcs);
ochisq=(*chisq);
for (j=1;j<=ma;j++) atry[j]=a[j];
}
for (j=0,l=1;l<=ma;l++) {
if (ia[l]) {
for (j++,k=0,m=1;m<=ma;m++) {
if (ia[m]) {
k++;
covar[j][k]=alpha[j][k];
}
}
covar[j][j]=alpha[j][j]*(1.0+(*alamda));
oneda[j][1]=beta[j];
}
}
covar.ColMax();
for (j=1;j<=mfit;j++) da[j]=oneda[j][1];
if (*alamda == 0.0) {
covsrt(covar,ma,ia,mfit);
return;
}
for (j=0,l=1;l<=ma;l++)
if (ia[l]) atry[l]=a[l]+da[++j];
mrqcof(x,y,sig,ndata,atry,ia,ma,covar,da,chisq,funcs);
if (*chisq < ochisq) {
*alamda *= 0.1;
ochisq=(*chisq);
for (j=0,l=1;l<=ma;l++) {
if (ia[l]) {
for (j++,k=0,m=1;m<=ma;m++) {
if (ia[m]) {
k++;
alpha[j][k]=covar[j][k];
}
}
beta[j]=da[j];
a[l]=atry[l];
}
}
} else {
*alamda *= 10.0;
*chisq=ochisq;
}
}
开发者ID:onethousand,项目名称:Computer,代码行数:64,代码来源:nlinfit.cpp
示例11: setAccel
void PlayerMoveComponent::determineDirection(){
//Je nach dem welche Taste eingegeben wurde wird mit maximaler Beschleunigung in die zugwiesene Richtung beschleunigt
if(keyStates['w'] || keyStates['W']){
if(keyStates['a'] || keyStates['A'])
setAccel(CVector(-MAX_ACCEL,MAX_ACCEL));
else if(keyStates['d'] || keyStates['D'])
setAccel(CVector(MAX_ACCEL,MAX_ACCEL));
else setAccel(CVector(0.0,MAX_ACCEL));
return;
}
if(keyStates['a'] || keyStates['A']){
if(keyStates['w'] || keyStates['W'])
setAccel(CVector(-MAX_ACCEL,MAX_ACCEL));
else if(keyStates['s'] || keyStates['S'])
setAccel(CVector(-MAX_ACCEL,-MAX_ACCEL));
else setAccel(CVector(-MAX_ACCEL,0));
return;
}
if(keyStates['s'] || keyStates['S']){
if(keyStates['d'] || keyStates['D'])
setAccel(CVector(MAX_ACCEL,-MAX_ACCEL));
else if(keyStates['a'] || keyStates['A'])
setAccel(CVector(-MAX_ACCEL,-MAX_ACCEL));
else setAccel(CVector(0,-MAX_ACCEL));
return;
}
if(keyStates['d'] || keyStates['D']){
if(keyStates['s'] || keyStates['S'])
setAccel(CVector(MAX_ACCEL,-MAX_ACCEL));
else if(keyStates['w'] || keyStates['W'])
setAccel(CVector(MAX_ACCEL,MAX_ACCEL));
else setAccel(CVector(MAX_ACCEL,0));
return;
}
//Wenn nichts gedrückt wurde, kommt der Spieler langsam zum stehen
if(velocity!=CVector(0,0)){
float x = 0.0;
float y = 0.0;
if(velocity[0]>0)
x = -MAX_ACCEL;
else
x = MAX_ACCEL;
if(velocity[1]>0)
y = -MAX_ACCEL;
else
y = MAX_ACCEL;
setAccel(CVector(x,y));
}
}
开发者ID:Goriar,项目名称:Ai-Project,代码行数:54,代码来源:PlayerMoveComponent.cpp
示例12: CVector
void CFoo::Test ( const char* szString )
{
CClientManager* pManager = g_pClientGame->GetManager ();
CClientPlayer* pLocal = pManager->GetPlayerManager ()->GetLocalPlayer ();
CClientVehicleManager* pVehicleManager = pManager->GetVehicleManager ();
CVector vecLocal;
pLocal->GetPosition ( vecLocal );
CClientCamera* pCamera = pManager->GetCamera ();
// ChrML: Trying to reproduce mantis issue #2760
if ( stricmp ( szString, "2760" ) == 0 )
{
vecLocal = CVector ( 0.0f, 0.0f, 5.0f );
for ( int i = 0; i < 20; i++ )
{
vecLocal.fX += 5.0f;
CClientPlayer* pPlayer = new CClientPlayer ( pManager, i + 50 );
pPlayer->SetDeadOnNetwork ( false );
pPlayer->SetModel ( 168 + i );
pPlayer->AttachTo ( NULL );
pPlayer->SetFrozen ( false );
pPlayer->RemoveAllWeapons ();
pPlayer->Teleport ( vecLocal );
pPlayer->SetCameraRotation ( 0 );
pPlayer->ResetInterpolation ();
pPlayer->SetMoveSpeed ( CVector () );
pPlayer->SetHealth ( 100.0f );
pPlayer->SetArmor ( 0 );
pPlayer->SetCurrentRotation ( 0 );
pPlayer->SetInterior ( 0 );
pPlayer->SetDimension ( 0 );
}
pLocal->SetDeadOnNetwork ( false );
pLocal->SetModel ( 145 );
pLocal->AttachTo ( NULL );
pLocal->SetFrozen ( false );
pLocal->RemoveAllWeapons ();
pLocal->Teleport ( vecLocal );
pLocal->SetCameraRotation ( 0 );
pLocal->ResetInterpolation ();
pLocal->SetMoveSpeed ( CVector () );
pLocal->SetHealth ( 100.0f );
pLocal->SetArmor ( 0 );
pLocal->SetCurrentRotation ( 0 );
pLocal->SetInterior ( 0 );
pLocal->SetDimension ( 0 );
g_pClientGame->SetAllDimensions ( 0 );
// Reset return position so we can't warp back to where we were if local player
g_pClientGame->GetNetAPI ()->ResetReturnPosition ();
// Make sure the camera is normal
pCamera->SetFocusToLocalPlayer ();
pCamera->FadeIn ( 0.0f );
}
// Player load crash
else if ( stricmp ( szString, "2741" ) == 0 )
{
bFoo_PlayerLimitCrash = true;
}
//
else if ( strnicmp ( szString, "interp", 6 ) == 0 )
{
if ( pVehicleManager->Count () > 0 )
{
CClientVehicle* pVehicle = *pVehicleManager->IterBegin ();
float fdelta = atof ( szString + 7 );
CVector vecT;
pVehicle->GetPosition ( vecT );
vecT.fZ = fdelta;
pVehicle->SetTargetPosition ( vecT, TICK_RATE );
g_pCore->ChatPrintf ( "Done %f", false, fdelta );
static_cast < CDeathmatchVehicle* > ( pVehicle )->SetIsSyncing ( false );
}
}
//
else if ( strnicmp ( szString, "interr", 6 ) == 0 )
{
if ( pVehicleManager->Count () > 0 )
{
CClientVehicle* pVehicle = *pVehicleManager->IterBegin ();
CVector vecT;
//.........这里部分代码省略.........
开发者ID:50p,项目名称:multitheftauto,代码行数:101,代码来源:CFoo.cpp
示例13: getPosition
//Mittels des Seperating Axis Theorem wird auf eine Kolission mit den Hindernissen geprüft
void PlayerMoveComponent::quadColission()
{
CVector position = getPosition();
double size = parent->getSize();
//Die Eckpunkte des Spielers
CVector v1 = CVector(position[0]-size,position[1]+size);
CVector v2 = CVector(position[0]+size,position[1]+size);
CVector v3 = CVector(position[0]+size,position[1]-size);
CVector v4 = CVector(position[0]-size,position[1]-size);
//Die zu prüfenden Achsen werden mit Hilfe der Vektoren der Spielerposition erstellt
CVector a1 = v1 - v2;
a1 = CVector(a1[1],-a1[0]);
a1.normalize();
CVector a2 = v2 - v3;
a2 = CVector(a2[1],-a2[0]);
a2.normalize();
CVector a3 = v3 - v4;
a3 = CVector(a3[1],-a3[0]);
a3.normalize();
CVector a4 = v4 - v1;
a4 = CVector(a4[1],-a4[0]);
a4.normalize();
CVector a[4] = {a1,a2,a3,a4};
CVector v[4] = {CVector(-size,size),CVector(size,size),CVector(size,-size),CVector(-size,-size)};
vector<Character *> characters = parent->getCharacterManager()->getAllNearbyCharacters(getPosition(),OBSTACLE_TAG,200.0);
vector<Character *>::iterator it = characters.begin();
while(it != characters.end())
{
Character *c = (*it);
it++;
CVector cPos = c->getPosition()-position;
double cSize = c->getSize();
//Die Eckpunkte eines Obstacles
CVector w1 = CVector(cPos[0]-cSize,cPos[1]+cSize);
CVector w2 = CVector(cPos[0]+cSize,cPos[1]+cSize);
CVector w3 = CVector(cPos[0]+cSize,cPos[1]-cSize);
CVector w4 = CVector(cPos[0]-cSize,cPos[1]-cSize);
CVector w[4] = {w1,w2,w3,w4};
CVector moveVector = CVector(9999999,9999999);
//Die Punkte werden auf eine Achse projiziert. Anschließend werden die Maxima und Minima miteinander verglichen
for(int i = 0; i<4; ++i){
CVector maxV = CVector();
CVector minV = CVector();
CVector maxW = CVector();
CVector minW = CVector();
for(int j = 0; j<4; ++j){
CVector projV = (a[i] * v[j]) * a[i];
if(projV[0]>maxV[0] || maxV.isNil())
maxV[0] = projV[0];
if(projV[1]>maxV[1] || maxV.isNil())
maxV[1] = projV[1];
if(projV[0]<minV[0] || minV.isNil())
minV[0] = projV[0];
if(projV[1]<minV[1] || minV.isNil())
minV[1] = projV[1];
CVector projW = (a[i] * w[j]) * a[i];
if(projW[0]>maxW[0] || maxW.isNil())
maxW[0] = projW[0];
if(projW[1]>maxW[1] || maxW.isNil())
maxW[1] = projW[1];
if(projW[0]<minW[0] || minW.isNil())
minW[0] = projW[0];
if(projW[1]<minW[1] || minW.isNil())
minW[1] = projW[1];
}
//Der Vektor in dessen Richtung der Spieler abgestoßen wird,wird berechnet...
if((maxV[0]>=minW[0] && maxV[1]>=minW[1])&& (minV[0] <= maxW[0] && minV[1] <= maxW[1])){
CVector vec = (maxV - minW).getLength() < (minV - maxW).getLength() ? maxV-minW : minV - maxW;
if(moveVector.getLength() > vec.getLength()){
moveVector = vec;
}
} else {
moveVector = CVector();
break;
}
//.........这里部分代码省略.........
开发者ID:Goriar,项目名称:Ai-Project,代码行数:101,代码来源:PlayerMoveComponent.cpp
示例14: ProcessInput
void CIATestMainWindow::OnDraw(IGenericRender *piRender)
{
if(!m_FrameManager.m_piFrameManager)
{
return;
}
m_FrameManager.m_piFrameManager->ProcessFrame();
double dTimeFraction=m_FrameManager.m_piFrameManager->GetTimeFraction();
double dRealTimeFraction=m_FrameManager.m_piFrameManager->GetRealTimeFraction();
if(m_bPauseOnNextFrame)
{
m_FrameManager.m_piFrameManager->SetPauseOnNextFrame(true);
m_bPauseOnNextFrame=false;
}
ProcessInput(dTimeFraction,dRealTimeFraction);
if(m_FrameManager.m_piFrameManager->GetTimeFraction()>0)
{
ProcessPhysics(dTimeFraction);
ProcessIA(dTimeFraction);
}
double dAspectRatio=m_rRealRect.h/m_rRealRect.w;
double dNearPlane=0,dFarPlane=0;
double dViewAngle=m_Camera.m_piCamera->GetViewAngle();
CVector vAngles,vPosition;
m_Camera.m_piCamera->SetAspectRatio(dAspectRatio);
m_Camera.m_piCamera->GetClippingPlanes(dNearPlane,dFarPlane);
vAngles=m_Camera.m_piCamera->GetAngles();
vPosition=m_Camera.m_piCamera->GetPosition();
piRender->SetPerspectiveProjection(dViewAngle,dNearPlane,100000);
piRender->SetCamera(vPosition,vAngles.c[YAW],vAngles.c[PITCH],vAngles.c[ROLL]);
glGetDoublev(GL_MODELVIEW_MATRIX,(double*)m_pdModelMatrix);
glGetDoublev(GL_PROJECTION_MATRIX,(double*)m_pdProjectionMatrix);
glGetIntegerv(GL_VIEWPORT,m_pnViewport);
RenderBox(CVector(0,0,-dBaseThickness),CVector(dBaseSize,dBaseSize,0),CVector(0.3,0.3,0.3));
RenderAxises();
char A[200];
sprintf(A,"Fps: %.02f",m_FrameManager.m_piFrameManager->GetCurrentFps());
m_piSTFps->SetText(A);
sprintf(A,"Time: %.02f",((double)m_FrameManager.m_piFrameManager->GetCurrentTime())/1000.0);
if(m_FrameManager.m_piFrameManager->IsPaused())
{
strcat(A," (Paused)");
}
m_piSTTime->SetText(A);
CVector entityPos=m_pSelectedEntity?m_pSelectedEntity->GetPosition():CVector(0,0,0);
sprintf(A,"Pos: %.02f , %.02f , %.02f",entityPos.c[0],entityPos.c[1],entityPos.c[2]);
m_piSTEntityPos->SetText(A);
CVector entityVel=m_pSelectedEntity?m_pSelectedEntity->GetVelocity():CVector(0,0,0);
sprintf(A,"Vel: %.02f , %.02f , %.02f - %.02f/%.02f ",entityVel.c[0],entityVel.c[1],entityVel.c[2],(double)entityVel,m_pSelectedEntity?m_pSelectedEntity->GetMaxVelocity():0);
m_piSTEntityVel->SetText(A);
map<string,CIAEntityBase *>::iterator i;
for(i=m_mEntities.begin();i!=m_mEntities.end();i++)
{
i->second->Render();
}
}
开发者ID:theclai,项目名称:friking-shark,代码行数:71,代码来源:IATestMainWindow.cpp
示例15: return
CVector CVector::mul (CVector b)
{
return(CVector(x*b.x, y*b.y, z*b.z));
}
开发者ID:ajakubek,项目名称:crrcsim_extensions,代码行数:4,代码来源:CVector.cpp
示例16: ASSERT
// Create a sphere primitive
void CRegionView::DoCreatePrimitiveSphere(CVector &vCenter, int nSubdivisionsX, int nSubdivisionsY, CReal fRadius, BOOL bDome)
{
// Do some error checking on the parameters
if (nSubdivisionsX <= 0 || nSubdivisionsY <= 0 || fRadius <= 0.0f)
{
ASSERT(FALSE);
return;
}
// Setup a new brush
CEditBrush *pNewBrush = no_CreateNewBrush(GetRegion(), GetRegion()->GetActiveParentNode());
ASSERT( pNewBrush );
if( !pNewBrush )
{
return;
}
// Setup an undo.
GetRegionDoc()->Modify(new CPreAction(ACTION_ADDEDNODE, pNewBrush), TRUE);
// The number of polygons for the center bands
int nNumPolies=nSubdivisionsX*(nSubdivisionsY-1);
// Add the number of polies for the bottom cap
if (bDome)
{
nNumPolies++;
}
else
{
nNumPolies+=nSubdivisionsX;
}
// Add the number of polies for the top cap
nNumPolies+=nSubdivisionsX;
CEditPoly **ppNewPoly=new CEditPoly*[nNumPolies];
int i;
for (i=0; i < nNumPolies; i++)
{
ppNewPoly[i]=new CEditPoly(pNewBrush);
}
// The height for the middle bands is slightly less (one band worth total) than the radius.
// This is so the triangle caps can be added.
float fHeight=(fRadius-(fRadius/nSubdivisionsY/2.0f))*2.0f;
// Initialize the vertices for the strips
int nSubY;
for (nSubY=0; nSubY < nSubdivisionsY; nSubY++)
{
// The percentage of the sphere that we are on in the Y direction
// For example, the middle subdivision is 0.50
float fYPercent;
// Create the top half of the sphere if we are in dome mode
if (bDome)
{
fYPercent=0.5f+((float)nSubY/(float)(nSubdivisionsY-1)/2.0f);
}
else
{
fYPercent=(float)nSubY/(float)(nSubdivisionsY-1);
}
// Calculate the Y position for this subdivision
float fYPos=(0.0f-(fHeight/2))+(fYPercent*fHeight);
// Calculate the radius (girth) for this subdivision
float fCurrentRadius=cos(asin(fYPos/fRadius))*fRadius;
int nSubX;
for (nSubX=0; nSubX < nSubdivisionsX; nSubX++)
{
// The percentage around the circle
float fXPercent=(float)nSubX/(float)(nSubdivisionsX-1);
// The current angle in radians
float theta=fXPercent*3.14159f*2.0f;
// Calculate the X and Y positions
float fXPos=cos(theta)*fCurrentRadius;
float fZPos=sin(theta)*fCurrentRadius;
// Set the vertex
CVector vPoint=CVector(fXPos, fYPos, fZPos)+vCenter;
pNewBrush->m_Points.Append(vPoint);
}
}
// Add the top point
CEditVert v;
v.x = vCenter.x;
v.y = vCenter.y + fRadius;
v.z = vCenter.z;
pNewBrush->m_Points.Append(v);
int nTopPointIndex=pNewBrush->m_Points.GetSize()-1;
//.........这里部分代码省略.........
开发者ID:Joincheng,项目名称:lithtech,代码行数:101,代码来源:CreatePrimitive.cpp
示例17: ComputeTimeSpaceWeights
void TV::IterativeReconstruction(CVector &data_gpu, CVector &x, CVector &b1_gpu)
{
unsigned N = width * height * frames;
ComputeTimeSpaceWeights(params.timeSpaceWeight, params.ds, params.dt);
Log("Setting ds: %.3e, dt: %.3e\n", params.ds, params.dt);
Log("Setting Primal-Dual Gap of %.3e as stopping criterion \n", params.stopPDGap);
// primal
CVector x_old(N);
CVector ext(N);
agile::copy(x, ext);
// dual
std::vector<CVector> y;
y.push_back(CVector(N));
y.push_back(CVector(N));
y.push_back(CVector(N));
y[0].assign(N, 0);
y[1].assign(N, 0);
y[2].assign(N, 0);
std::vector<CVector> tempGradient;
tempGradient.push_back(CVector(N));
tempGradient.push_back(CVector(N));
tempGradient.push_back(CVector(N));
CVector z(data_gpu.size());
zTemp.resize(data_gpu.size(), 0.0);
z.assign(z.size(), 0.0);
CVector norm(N);
unsigned loopCnt = 0;
// loop
Log("Starting iteration\n");
while ( loopCnt < params.maxIt )
{
// dual ascent step
utils::Gradient(ext, tempGradient, width, height, params.ds, params.ds,
params.dt);
agile::addScaledVector(y[0], params.sigma, tempGradient[0], y[0]);
agile::addScaledVector(y[1], params.sigma, tempGradient[1], y[1]);
agile::addScaledVector(y[2], params.sigma, tempGradient[2], y[2]);
mrOp->BackwardOperation(ext, zTemp, b1_gpu);
agile::addScaledVector(z, params.sigma, zTemp, z);
// Proximal mapping
utils::ProximalMap3(y, 1.0);
agile::subScaledVector(z, params.sigma, data_gpu, z);
agile::scale((float)(1.0 / (1.0 + params.sigma / params.lambda)), z, z);
// primal descent
mrOp->ForwardOperation(z, imgTemp, b1_gpu);
utils::Divergence(y, divTemp, width, height, frames, params.ds, params.ds,
params.dt);
agile::subVector(imgTemp, divTemp, divTemp);
agile::subScaledVector(x, params.tau, divTemp, ext);
// save x_n+1
agile::copy(ext, x_old);
// extra gradient
agile::scale(2.0f, ext, ext);
agile::subVector(ext, x, ext);
// x_n = x_n+1
agile::copy(x_old, x);
// adapt step size
if (loopCnt < 10 || (loopCnt % 50 == 0))
{
CVector temp(N);
agile::subVector(ext, x, temp);
AdaptStepSize(temp, b1_gpu);
}
// compute PD Gap (export,verbose,stopping)
if ( (verbose && (loopCnt < 10 || (loopCnt % 50 == 0)) ) ||
((debug) && (loopCnt % debugstep == 0)) ||
((params.stopPDGap > 0) && (loopCnt % 20 == 0)) )
{
RType pdGap =
ComputePDGap(x, y, z, data_gpu, b1_gpu);
pdGap=pdGap/N;
pdGapExport.push_back( pdGap );
Log("Normalized Primal-Dual Gap after %d iterations: %.4e\n", loopCnt, pdGap);
if ( pdGap < params.stopPDGap )
return;
}
loopCnt++;
if (loopCnt % 10 == 0)
std::cout << "." << std::flush;
}
std::cout << std::endl;
//.........这里部分代码省略.........
开发者ID:IMTtugraz,项目名称:AVIONIC,代码行数:101,代码来源:tv.cpp
示例18: DoAutoScroll
BOOL CRVTrackerNodeMove::OnUpdate(const CUIEvent &cEvent)
{
// Only update on idle
if (cEvent.GetType() != UIEVENT_NONE)
return TRUE;
// Don't update if it hasn't moved
if (m_cCurPt == m_cLastPt)
return TRUE;
LTVector newVert, moveOffset, translateAmount;
DWORD i, j;
CWorldNode *pNode;
CEditBrush *pBrush;
CEditPoly *pPoly;
// If the mouse is outside of the view, then autoscroll the view
DoAutoScroll();
// Use the current mouse position and use the delta from the last to update the
// position of the node in 3d views...
if( m_pView->GetVertexFromPoint(m_cCurPt, newVert))
{
moveOffset = newVert - m_vStartVec;
// Snap the movement to the current move axis (may be all axis)
moveOffset.x *= m_vMoveSnapAxis.x;
moveOffset.y *= m_vMoveSnapAxis.y;
moveOffset.z *= m_vMoveSnapAxis.z;
// If the shift key is pressed, then snap the object to horizontal or vertical movement if
// that hasn't been done already.
if (m_bLockAxis)
{
// Make sure that there isn't currently a move axis defined
if (m_vMoveSnapAxis == CVector(1.0f, 1.0f, 1.0f))
{
// Create an absolute vector so that the magnitudes can be compared
CVector vAbsolute(fabs(m_vTotalMoveOffset.x), fabs(m_vTotalMoveOffset.y), fabs(m_vTotalMoveOffset.z));
// Check to see if we should snap to the x axis
if (vAbsolute.x > vAbsolute.y && vAbsolute.x > vAbsolute.z)
{
// Cancel the movement along the y and z axis
moveOffset.y=(-1)*m_vTotalMoveOffset.y;
moveOffset.z=(-1)*m_vTotalMoveOffset.z;
m_vMoveSnapAxis=CVector(1.0f, 0.0f, 0.0f);
}
// Check to see if we should snap to the y axis
if (vAbsolute.y > vAbsolute.x && vAbsolute.y > vAbsolute.z)
{
// Cancel the movement along the y and z axis
moveOffset.x=(-1)*m_vTotalMoveOffset.x;
moveOffset.z=(-1)*m_vTotalMoveOffset.z;
m_vMoveSnapAxis=CVector(0.0f, 1.0f, 0.0f);
}
// Check to see if we should snap to the z axis
if (vAbsolute.z > vAbsolute.x && vAbsolute.z > vAbsolute.y)
{
// Cancel the movement along the y and z axis
moveOffset.x=(-1)*m_vTotalMoveOffset.x;
moveOffset.y=(-1)*m_vTotalMoveOffset.y;
m_vMoveSnapAxis=CVector(0.0f, 0.0f, 1.0f);
}
}
}
else
{
m_vMoveSnapAxis=CVector(1.0f, 1.0f, 1.0f);
}
// Update the total move offset. This is used to snap the nodes when the shift key is pressed.
m_vTotalMoveOffset+=moveOffset;
// Go through all the selected nodes and move them...
for( i=0; i < m_pView->GetRegion()->m_Selections; i++ )
{
pNode = m_pView->GetRegion()->m_Selections[i];
// Handle movement for Brush nodes...
if(pNode->GetType() == Node_Brush)
{
// Get the brush pointer...
pBrush = pNode->AsBrush();
// Check for perpendicular movement...
if(m_bPerp)
{
translateAmount = -(m_pView->EditGrid().Forward() * (CReal)(m_cCurPt.y - m_cLastPt.y));
}
// planar movement...
else
{
translateAmount = moveOffset;
}
//.........这里部分代码省略.........
开发者ID:Joincheng,项目名称:lithtech,代码行数:101,代码来源:RVTrackerNodeMove.cpp
|
请发表评论