本文整理汇总了C++中CVar::GetFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ CVar::GetFloat方法的具体用法?C++ CVar::GetFloat怎么用?C++ CVar::GetFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVar
的用法示例。
在下文中一共展示了CVar::GetFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateBullet
void CEffectsGame::CreateBullet( Vector3 pos, Vector3 dir )
{
// find empty slot
int i = 0;
for (i=0; i<MAX_BULLETS; i++)
if (bullets[i] == NULL) break;
if (i == MAX_BULLETS) return;
static CTexture *fxTex = new CTexture("textures/fx.png");
CSprite3D *bullet = new CSprite3D(fxTex, 0.2f, 2.0f, false);
float margin = 0.1f;
bullet->texcoord[0] = Vector2(1-margin,1);
bullet->texcoord[1] = Vector2(0.75+margin,0.75);
bullet->locked = true;
bullet->lockedAxis = pCamera->forward;
bullet->color = YELLOW;
bullet->SetPosition(car->pBarrel->GetWorldPosition()/* + car->pBarrel->up * 1.0f*/);
float s = cv_bulletScatter.GetFloat()/2;
dir.x += frand(-s, s);
dir.y += frand(-s, s);
dir.z += frand(-s, s);
bullet->velocity = dir.Normalize() * cv_bulletSpeed.GetFloat();
pScene->Add(bullet);
bullets[i] = bullet;
bulletsNum++;
}
示例2: Think
void CStructure::Think()
{
BaseClass::Think();
if (GameData().GetCommandMenu())
{
if (IsUnderConstruction() && IsWorkingConstructionTurn())
{
CCommandMenu* pMenu = GameData().GetCommandMenu();
pMenu->SetProgressBar(GameServer()->GetGameTime() - m_flConstructionTurnTime, build_time_construct.GetFloat());
}
if (GameData().GetCommandMenu()->WantsToClose())
GameData().CloseCommandMenu();
else
GameData().GetCommandMenu()->Think();
}
if (GameServer()->GetGameTime() > m_flConstructionTurnTime + build_time_construct.GetFloat())
ConstructionTurn();
if (IsUnderConstruction())
{
if (CanAutoOpenMenu())
{
// If the player is nearby, looking at me, and not already looking at another command menu, open a temp command menu showing construction info.
CCommandMenu* pMenu = GameData().CreateCommandMenu(GetOwner()->GetPlayerCharacter());
SetupMenuButtons();
}
else if (CanAutoCloseMenu())
{
// If the player goes away or stops looking, close it.
GameData().CloseCommandMenu();
}
if (GameData().GetCommandMenu())
GameData().GetCommandMenu()->Think();
}
else if (TakesPower() && GetOwner() && GetOwner()->GetPlayerCharacter() && GetOwner()->GetPlayerCharacter()->IsHoldingPowerCord())
{
if (CanAutoOpenMenu())
{
// If the player is nearby, looking at me, and not already looking at another command menu, open a temp command menu showing construction info.
CCommandMenu* pMenu = GameData().CreateCommandMenu(GetOwner()->GetPlayerCharacter());
SetupMenuButtons();
}
else if (CanAutoCloseMenu())
{
// If the player goes away or stops looking, close it.
GameData().CloseCommandMenu();
}
if (GameData().GetCommandMenu())
GameData().GetCommandMenu()->Think();
}
}
示例3: OnMouseMove
bool RabidEngine::OnMouseMove(int dx, int dy)
{
if(!g_console->Active())
{
{
cl_camroty.SetFloat(cl_camroty.GetFloat() - dx);
cl_camrotx.SetFloat(cl_camrotx.GetFloat() - dy);
while(cl_camroty.GetFloat() > 360.0f)
cl_camroty.SetFloat(cl_camroty.GetFloat() - 360.0f);
while(cl_camroty.GetFloat() < 0.0f)
cl_camroty.SetFloat(cl_camroty.GetFloat() + 360.0f);
if(cl_camrotx.GetFloat() > 90)
cl_camrotx.SetFloat(90.0);
if(cl_camrotx.GetFloat() < -90)
cl_camrotx.SetFloat(-90.0);
}
return true;
}
return false;
}
示例4: Paint
void CLessonPanel::Paint(float x, float y, float w, float h)
{
if (m_flStartTime < 0 || GameServer()->GetGameTime() > m_flStartTime + lesson_time.GetFloat())
return;
if (m_pLesson->m_flSlideAmount > 0)
{
if (m_pLesson->m_bSlideX)
x += Bias(RemapValClamped((float)(GameServer()->GetGameTime() - m_flStartTime), 0, 1, 1.0f, 0.0f), 0.2f) * m_pLesson->m_flSlideAmount;
else
y += Bias(RemapValClamped((float)(GameServer()->GetGameTime() - m_flStartTime), 0, 1, 1.0f, 0.0f), 0.2f) * m_pLesson->m_flSlideAmount;
}
bool bScrolling = false;
if (!m_bDoneScrolling)
{
int iPrintChars = (int)((GameServer()->GetGameTime() - m_flStartTime)*70);
m_pText->SetPrintChars(iPrintChars);
bScrolling = (iPrintChars < (int)m_pText->GetText().length());
if (!bScrolling)
m_bDoneScrolling = true;
}
else
m_pText->SetPrintChars(-1);
CRootPanel::PaintRect(x, y, w, h, Color(0, 0, 0, 50), 1);
CPanel::Paint(x, y, w, h);
}
示例5: Instructor_LessonLearned
void CPlayer::Instructor_LessonLearned(const tstring& sLesson)
{
if (!GameWindow()->GetInstructor()->IsInitialized())
GameWindow()->GetInstructor()->Initialize();
auto it = m_apLessonProgress.find(sLesson);
TAssert(it != m_apLessonProgress.end());
if (it == m_apLessonProgress.end())
return;
CLessonProgress* pLessonProgress = &it->second;
TAssert(pLessonProgress);
if (!pLessonProgress)
return;
// Can only learn a lesson once in a while, to ensure that it is truly learned.
// The idea is that the player spends a couple seconds toying around with the
// new feature, but won't spend all of the lessons in that time.
if (GameServer()->GetGameTime() < pLessonProgress->m_flLastTimeLearned + lesson_learntime.GetFloat())
return;
pLessonProgress->m_flLastTimeLearned = GameServer()->GetGameTime();
pLessonProgress->m_iTimesLearned++;
if (lesson_debug.GetBool())
{
CLesson* pLesson = GameWindow()->GetInstructor()->GetLesson(sLesson);
if (pLessonProgress->m_iTimesLearned < pLesson->m_iTimesToLearn)
TMsg(tsprintf("Instructor: Trained lesson " + sLesson + " - %d/%d\n", pLessonProgress->m_iTimesLearned, pLesson->m_iTimesToLearn));
else if (pLessonProgress->m_iTimesLearned == pLesson->m_iTimesToLearn)
TMsg("Instructor: Learned lesson " + sLesson + "\n");
}
}
示例6: GetCVarFloat
float CVar::GetCVarFloat(tstring sName)
{
CVar* pVar = FindCVar(sName);
if (!pVar)
return 0;
return pVar->GetFloat();
}
示例7: Update
void ConstructBuilding::Update(const float t)
{
if (m_buildprogress < 1.0f && m_build.BeginPass(m_chief.GetNumWorkers(EBW_Work)+v_autowork.GetFloat(), t))
{
m_build << m_stone;
m_build << m_wood;
m_build >> m_buildprogress;
m_build.Commit();
}
示例8: Update
void Sugar::Update(const float t)
{
float work = m_cooker.Update(t, m_coal);
if (m_cooker.WarmStart()) this->m_part.emitor->Start();
if (m_cooker.WarmEnd()) this->m_part.emitor->Stop();
if (!InBuildProcess() && work &&
m_work.BeginPass(m_chief.GetNumWorkers(EBW_Work)+v_autowork.GetFloat(),
t * work))
{
m_work << m_cane;
m_work >> m_sugar;
m_work.Commit();
}
示例9: SetupMenuButtons
void CStructure::SetupMenuButtons()
{
CCommandMenu* pMenu = GameData().GetCommandMenu();
if (!pMenu)
return;
if (IsUnderConstruction())
{
pMenu->SetTitle(GetStructureName(m_eStructureType));
pMenu->SetSubtitle(sprintf("UNDER CONSTRUCTION - %d/%d", m_iTotalTurnsToConstruct-m_iTurnsToConstruct, m_iTotalTurnsToConstruct));
if (IsWorkingConstructionTurn())
pMenu->SetProgressBar(GameServer()->GetGameTime() - m_flConstructionTurnTime, build_time_construct.GetFloat());
else
pMenu->DisableProgressBar();
}
else if (GetOwner() && GetOwner()->GetPlayerCharacter() && GetOwner()->GetPlayerCharacter()->IsHoldingPowerCord())
{
pMenu->SetTitle(GetStructureName(m_eStructureType));
pMenu->SetSubtitle("Connect power?");
}
}
示例10: PlayerWalk
void CCharacterController::PlayerWalk(btCollisionWorld* pCollisionWorld, btScalar dt)
{
Vector vecCurrentVelocity = m_hEntity->GetLocalVelocity();
vecCurrentVelocity.z = 0;
// Calculate friction first, so that the player's movement commands can overwhelm it.
if (vecCurrentVelocity.Length2DSqr() > 0.00001f)
{
if (m_hEntity->GetGroundEntity())
{
float flSpeed2D = vecCurrentVelocity.Length2D();
float flFriction = sv_friction.GetFloat() * flSpeed2D * dt;
float flNewSpeed = flSpeed2D - flFriction;
if (flNewSpeed < 0)
flNewSpeed = 0;
float flScale = flNewSpeed / flSpeed2D;
vecCurrentVelocity *= flScale;
m_hEntity->SetLocalVelocity(vecCurrentVelocity);
}
}
// Calculate a new velocity using the player's desired direction of travel.
btVector3 vecWishDirection = m_vecMoveVelocity;
vecWishDirection.setZ(0);
float flWishVelocity = m_vecMoveVelocity.length();
if (flWishVelocity)
vecWishDirection = vecWishDirection / flWishVelocity;
else
vecWishDirection = btVector3(0, 0, 0);
if (flWishVelocity > m_hEntity->CharacterSpeed())
flWishVelocity = m_hEntity->CharacterSpeed();
float flVelocityInWishDirection = GetVelocity().dot(vecWishDirection);
float flDirectionChange = flWishVelocity - flVelocityInWishDirection;
if (flDirectionChange > 0)
{
float flAccelerationAmount = flWishVelocity * m_hEntity->CharacterAcceleration() * dt;
if (flAccelerationAmount > flDirectionChange)
flAccelerationAmount = flDirectionChange;
vecCurrentVelocity = vecCurrentVelocity + ToTVector(vecWishDirection) * flAccelerationAmount;
TAssert(vecCurrentVelocity.z == 0);
}
float flCurrentVelocity = vecCurrentVelocity.Length();
if (flCurrentVelocity > m_hEntity->CharacterSpeed())
vecCurrentVelocity *= m_hEntity->CharacterSpeed()/flCurrentVelocity;
if (vecCurrentVelocity.LengthSqr() < 0.001f)
{
m_hEntity->SetLocalVelocity(Vector());
return;
}
btTransform mWorld = m_pGhostObject->getWorldTransform();
// Try moving the player directly, if it's possible.
{
btVector3 vecTargetPosition = mWorld.getOrigin() + ToBTVector(vecCurrentVelocity) * dt;
CTraceResult tr;
PlayerTrace(pCollisionWorld, mWorld.getOrigin(), vecTargetPosition, tr);
if (tr.m_flFraction == 1)
{
mWorld.setOrigin(vecTargetPosition);
m_pGhostObject->setWorldTransform(mWorld);
m_hEntity->SetLocalVelocity(vecCurrentVelocity);
return;
}
}
// There was something blocking the way. Try walking up a step or along walls.
btVector3 vecSavedStepUp(0, 0, 0);
{
// Move up a bit to try to clear a step.
btVector3 vecStartPosition = m_pGhostObject->getWorldTransform().getOrigin();
btVector3 vecTargetPosition = m_pGhostObject->getWorldTransform().getOrigin() + GetUpVector() * m_flStepHeight;
CTraceResult tr;
PlayerTrace(pCollisionWorld, vecStartPosition, vecTargetPosition, tr);
if (tr.m_flFraction < 1)
{
// we moved up only a fraction of the step height
btVector3 vecInterpolated;
vecInterpolated.setInterpolate3(m_pGhostObject->getWorldTransform().getOrigin(), vecTargetPosition, tr.m_flFraction);
m_pGhostObject->getWorldTransform().setOrigin(vecInterpolated);
//.........这里部分代码省略.........
示例11: UpdateBullets
void CEffectsGame::UpdateBullets( float frametime )
{
for (int i=0; i<MAX_BULLETS; i++)
{
if (bullets[i] == NULL) continue;;
CSprite3D *bullet = bullets[i];
Vector3 move = bullet->velocity * frametime;
Vector3 start = bullet->GetPosition();
bullet->Move(move.x, move.y, move.z);
bullet->velocity.y -= frametime * cv_bulletGravity.GetFloat();
bullet->lockedAxis = bullet->velocity;
bullet->lockedAxis.Normalize();
Vector3 v = bullet->velocity;
v.Normalize();
gRenderer.AddLine(bullet->GetPosition(), bullet->GetPosition() + v, SRGBA(255,230,180,180));
if (bullet->GetWorldPosition().y < 0)
{
RemoveBullet(i);
}
SMapTile *tileHit;
Vector3 tileHitPos;
Vector3 pos;
bool hit = false;
if (hit = pLevel->CastRay(start, bullet->GetPosition(), OUT tileHitPos, OUT &tileHit, OUT &pos))
{
EnterCriticalSection(&renderCS);
tileHit->type = 0;
LeaveCriticalSection(&renderCS);
// remove tile from the level and mark for update
SMapChunk *chunk = pLevel->GetChunk(
floor(tileHitPos.x/SMapChunk::Size),
floor(tileHitPos.y/SMapChunk::Size),
floor(tileHitPos.z/SMapChunk::Size) );
chunk->dirtyBody = true;
chunk->dirty = true;
// add a box to spawn list
SSpawnTile s;
s.pos = tileHitPos;
s.vel = v * cv_bulletforce.GetFloat();
boxesToSpawn.push(s);
// remove bullet
RemoveBullet(i);
float puffSpeed = 0.5;
// add puff effect
for (int i = 0; i<6; i++)
{
static CTexture *puffTex = new CTexture("particles/explosion4.dds");
CParticle *p = new CParticle(puffTex);
p->size = Vector2(1.35, 1.35);
p->position = pos;
p->velocity = Vector3( frand(-puffSpeed,puffSpeed), frand(-puffSpeed,puffSpeed), frand(-puffSpeed,puffSpeed) );
p->lifetime = 1;
//p->color = SRGBA(155,155,155,255);
p->color = SRGB(clamp(pos.x*255.0f/32.0f,0,255)*0.9f, clamp(pos.y*255.0f/32.0f,0,255)*0.9f, clamp(pos.z*255.0f/32.0f,0,255)*0.9f);
p->colorChange = p->color;// SRGBA(255,255,255,0);
p->colorChange.a = 0;
p->colorTime = 1;
p->sizeVel = Vector2(0.85,0.85);
particles->Add(p);
}
}
}
//PrintText("Bullets: %d", bulletsNum);
}
示例12: CarBoxCallback
void CarBoxCallback(const NewtonBody* body, float timestep, int threadIndex)
{
float mass, ix, iy, iz;
NewtonBodyGetMassMatrix(body, &mass, &ix, &iy, &iz);
Vector4 gravityForce = Vector4(0.0f, mass * GRAVITY, 0.0f, 1.0f);
// set gravity as a force
//NewtonBodySetForce(body, (float*)&gravityForce);
CMesh *object = (CMesh*)NewtonBodyGetUserData(body);
Vector3 force;
if (Keydown('w')) force = object->forward;
if (Keydown('s')) force = -object->forward;
//if (Keydown('a')) force -= object->right;
//if (Keydown('d')) force += object->right;
force *= cv_speed.GetFloat(); // speed
//force.y = GRAVITY;
force *= mass;
/*float f[3];
NewtonBodyGetForce(body, &f[0]);
Debug("BODY: %f %f %f", f[0], f[1], f[2]);
Debug("FORCE: %f %f %f", force.x, force.y, force.z);
*/
NewtonBodySetForce(body, &force[0]);
//NewtonBodyAddImpulse(body, &force[0], &object->GetWorldPosition()[0]);
//NewtonBodySetVelocity(body, &force[0]);
float torqueForce = cv_rspeed.GetFloat();
Vector3 torque;
if (Keydown('a')) torque.y -= torqueForce;
if (Keydown('d')) torque.y += torqueForce;
// Damping has no effect at all
/* static float damp = 0.5f;
if (KeyPressed('p')) damp += 0.1f;
if (KeyPressed('o')) damp -= 0.1f;
Vector3 damping = Vector3(damp,damp,damp);
damping *= damp;
NewtonBodySetAngularDamping(body, &damping[0]);
*/
NewtonBodySetOmega(body, &torque[0]);
//torque *= mass;
//NewtonBodyAddTorque(body, &torque[0]);
int sleep = NewtonBodyGetSleepState(body);
object->color = sleep == 1 ? GREEN : RED;
//Vector3 speed;
//NewtonBodyGetVelocity(body, &speed[0]);
}
示例13: PostRender
void CSupplier::PostRender() const
{
BaseClass::PostRender();
if (!GameServer()->GetRenderer()->IsRenderingTransparent())
return;
float flGrowthTime = (float)(GameServer()->GetGameTime() - m_flTendrilGrowthStartTime);
if (flGrowthTime < 0)
return;
if (m_flTendrilGrowthStartTime == 0)
{
DigitanksGame()->GetDigitanksRenderer()->AddTendrilBatch(this);
return;
}
COverheadCamera* pCamera = DigitanksGame()->GetOverheadCamera();
Vector vecCamera = pCamera->GetGlobalOrigin();
float flDistanceSqr = GetGlobalOrigin().DistanceSqr(vecCamera);
float flFadeDistance = tendril_fade_distance.GetFloat();
float flFadeAlpha = RemapValClamped(flDistanceSqr, flFadeDistance*flFadeDistance, (flFadeDistance+20)*(flFadeDistance+20), 1.0f, 0.0f);
if (flFadeAlpha <= 0)
return;
float flTreeAlpha = 1.0f;
if (DigitanksGame()->GetTerrain()->GetBit(CTerrain::WorldToArraySpace(GetGlobalOrigin().x), CTerrain::WorldToArraySpace(GetGlobalOrigin().y), TB_TREE))
flTreeAlpha = 0.3f;
CRenderingContext r(GameServer()->GetRenderer(), true);
if (DigitanksGame()->ShouldRenderFogOfWar())
r.UseFrameBuffer(DigitanksGame()->GetDigitanksRenderer()->GetVisibilityMaskedBuffer());
r.SetDepthMask(false);
r.UseMaterial(s_hTendrilBeam);
r.SetUniform("flTime", (float)GameServer()->GetGameTime());
r.SetUniform("iTexture", 0);
r.SetUniform("flAlpha", flFadeAlpha * flTreeAlpha);
Color clrTeam = GetPlayerOwner()?GetPlayerOwner()->GetColor():Color(255,255,255,255);
clrTeam = (Vector(clrTeam) + Vector(1,1,1))/2;
if (m_flTendrilGrowthStartTime > 0)
{
float flTotalSize = (float)m_aTendrils.size() + GetBoundingRadius();
for (size_t i = 0; i < m_aTendrils.size(); i++)
{
if (i < m_aTendrils.size() - 15)
continue;
const CTendril* pTendril = &m_aTendrils[i];
float flGrowthLength = RemapVal(flGrowthTime, 0, GROWTH_TIME, pTendril->m_flLength-flTotalSize, pTendril->m_flLength);
if (flGrowthLength < 0)
continue;
Vector vecDestination = GetGlobalOrigin() + (pTendril->m_vecEndPoint - GetGlobalOrigin()).Normalized() * flGrowthLength;
Vector vecPath = vecDestination - GetGlobalOrigin();
vecPath.y = 0;
float flDistance = vecPath.Length2D();
Vector vecDirection = vecPath.Normalized();
size_t iSegments = (size_t)(flDistance/3);
r.SetUniform("flSpeed", pTendril->m_flSpeed);
clrTeam.SetAlpha(105);
CRopeRenderer oRope(GameServer()->GetRenderer(), s_hTendrilBeam, DigitanksGame()->GetTerrain()->GetPointHeight(GetGlobalOrigin()) + Vector(0, 0, 1), 1.0f);
oRope.SetColor(clrTeam);
oRope.SetTextureScale(pTendril->m_flScale);
oRope.SetTextureOffset(pTendril->m_flOffset);
oRope.SetForward(Vector(0, 0, -1));
for (size_t i = 1; i < iSegments; i++)
{
clrTeam.SetAlpha((int)RemapVal((float)i, 1, (float)iSegments, 100, 30));
oRope.SetColor(clrTeam);
float flCurrentDistance = ((float)i*flDistance)/iSegments;
oRope.AddLink(DigitanksGame()->GetTerrain()->GetPointHeight(GetGlobalOrigin() + vecDirection*flCurrentDistance) + Vector(0, 0, 1));
}
oRope.Finish(DigitanksGame()->GetTerrain()->GetPointHeight(vecDestination) + Vector(0, 0, 1));
}
}
}
示例14: Update
void StoneMine::Update(const float dtime)
{
m_line.Update(dtime * v_numzpr.GetFloat(), m_stone, v_numworks.GetInt());
}
示例15: OnIdle
void RabidEngine::OnIdle()
{
g_timer.Update();
const float dt = g_timer.GetTimeChange();
g_console->Update(dt);
Transformation view;
view.Rotate().FromEulerXYZ(cl_camrotx.GetFloat(),
cl_camroty.GetFloat(),
cl_camrotz.GetFloat());
// move
const Vector3f forward = -view.Rotate().GetColumn(2);
const Vector3f right = view.Rotate().GetColumn(0);
const float vel = 50.0 * dt;
if(keyState[B_FORWARD])
{
cl_camx.SetFloat(cl_camx.GetFloat() + forward.x * vel);
cl_camy.SetFloat(cl_camy.GetFloat() + forward.y * vel);
cl_camz.SetFloat(cl_camz.GetFloat() + forward.z * vel);
}
if(keyState[B_BACKWARD])
{
cl_camx.SetFloat(cl_camx.GetFloat() + -forward.x * vel);
cl_camy.SetFloat(cl_camy.GetFloat() + -forward.y * vel);
cl_camz.SetFloat(cl_camz.GetFloat() + -forward.z * vel);
}
if(keyState[B_RIGHT])
{
cl_camx.SetFloat(cl_camx.GetFloat() + right.x * vel);
cl_camy.SetFloat(cl_camy.GetFloat() + right.y * vel);
cl_camz.SetFloat(cl_camz.GetFloat() + right.z * vel);
}
if(keyState[B_LEFT])
{
cl_camx.SetFloat(cl_camx.GetFloat() + -right.x * vel);
cl_camy.SetFloat(cl_camy.GetFloat() + -right.y * vel);
cl_camz.SetFloat(cl_camz.GetFloat() + -right.z * vel);
}
if(keyState[B_RENDER])
{
done.Set("0");
keyState[B_RENDER] = 0;
}
if(keyState[B_LIGHT_MODE])
{
if(r_resid.GetBool())
r_resid.Set("0");
else
r_resid.Set("1");
keyState[B_LIGHT_MODE] = 0;
}
if(keyState[B_TOGGLE_BRIGHTEST])
{
if(r_showbrightest.GetBool())
r_showbrightest.Set("0");
else
r_showbrightest.Set("1");
keyState[B_TOGGLE_BRIGHTEST] = 0;
}
static int pass;
static int surf = -1;
static int brightest;
static int patches;
if(done.GetBool())
{
}
else
{
if(pass == 0)
{
// clear accumulation buffers
for(unsigned int i = 0; i < surfaces.Size(); i++)
{
// if(surfaces[i]->GetType() != S_LIGHT)
// surfaces[i]->ClearAccum();
}
}
if(surf >= (int)surfaces.Size())
{
surf = -2;
pass++;
done.Set("1");
}
else if(surf == -1)
{
// Find Brightest Surface
//.........这里部分代码省略.........