本文整理汇总了C++中CVector函数的典型用法代码示例。如果您正苦于以下问题:C++ CVector函数的具体用法?C++ CVector怎么用?C++ CVector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CVector函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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 );
//.........这里部分代码省略.........
示例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++;
}
}
示例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;
}
//.........这里部分代码省略.........
示例5: CVector
void CEntity::Tick(CMap* pMap)
{
if(Mov != CVector(0,0) && CanMove(pMap, Mov))
Pos += Mov;
Mov = CVector(0,0);
}
示例6: CVector
void CEnemy10::Move() {
Scale = CVector(1.2f, 1, 1)*0.22f;
Position = Owner->Position + CVector(0.01, 0.06f, 0);
}
示例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;
}
});
}
示例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);
}
示例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);
}
示例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;
}
}
示例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));
}
}
示例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;
//.........这里部分代码省略.........
示例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;
}
//.........这里部分代码省略.........
示例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();
}
}
示例15: return
CVector CVector::mul (CVector b)
{
return(CVector(x*b.x, y*b.y, z*b.z));
}