本文整理汇总了C++中Vec4类的典型用法代码示例。如果您正苦于以下问题:C++ Vec4类的具体用法?C++ Vec4怎么用?C++ Vec4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vec4类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: setOpacity
void Marker::setOpacity(float opacity)
{
Vec4 color = _shapeDrawable->getColor();
color.set(color[0], color[1], color[2], opacity);
setColor(color);
}
开发者ID:nixz,项目名称:covise,代码行数:6,代码来源:Marker.cpp
示例2: VEC4_CONST
void FastClusterFit::Compress4( void* block )
{
Vec4 const one = VEC4_CONST(1.0f);
Vec4 const zero = VEC4_CONST(0.0f);
Vec4 const half = VEC4_CONST(0.5f);
Vec4 const two = VEC4_CONST(2.0);
Vec4 const onethird = VEC4_CONST( 1.0f/3.0f );
Vec4 const twothirds = VEC4_CONST( 2.0f/3.0f );
// declare variables
Vec4 beststart = VEC4_CONST( 0.0f );
Vec4 bestend = VEC4_CONST( 0.0f );
Vec4 besterror = VEC4_CONST( FLT_MAX );
Vec4 x0 = zero;
int b0 = 0, b1 = 0, b2 = 0;
int i = 0;
// check all possible clusters for this total order
for( int c0 = 0; c0 <= 16; c0++)
{
Vec4 x1 = zero;
for( int c1 = 0; c1 <= 16-c0; c1++)
{
Vec4 x2 = zero;
for( int c2 = 0; c2 <= 16-c0-c1; c2++)
{
Vec4 const constants = Vec4((const float *)&s_fourElement[i]);
Vec4 const alpha2_sum = constants.SplatX();
Vec4 const beta2_sum = constants.SplatY();
Vec4 const alphabeta_sum = constants.SplatZ();
Vec4 const factor = constants.SplatW();
i++;
Vec4 const alphax_sum = x0 + MultiplyAdd(x1, twothirds, x2 * onethird);
Vec4 const betax_sum = m_xsum - alphax_sum;
Vec4 a = NegativeMultiplySubtract(betax_sum, alphabeta_sum, alphax_sum*beta2_sum) * factor;
Vec4 b = NegativeMultiplySubtract(alphax_sum, alphabeta_sum, betax_sum*alpha2_sum) * factor;
// clamp the output to [0, 1]
a = Min( one, Max( zero, a ) );
b = Min( one, Max( zero, b ) );
// clamp to the grid
Vec4 const grid( 31.0f, 63.0f, 31.0f, 0.0f );
Vec4 const gridrcp( 0.03227752766457f, 0.01583151765563f, 0.03227752766457f, 0.0f );
a = Truncate( MultiplyAdd( grid, a, half ) ) * gridrcp;
b = Truncate( MultiplyAdd( grid, b, half ) ) * gridrcp;
// compute the error
Vec4 e1 = MultiplyAdd( a, alphax_sum, b*betax_sum );
Vec4 e2 = MultiplyAdd( a*a, alpha2_sum, b*b*beta2_sum );
Vec4 e3 = MultiplyAdd( a*b*alphabeta_sum - e1, two, e2 );
// apply the metric to the error term
Vec4 e4 = e3 * m_metricSqr;
Vec4 error = e4.SplatX() + e4.SplatY() + e4.SplatZ();
// keep the solution if it wins
if( CompareAnyLessThan( error, besterror ) )
{
besterror = error;
beststart = a;
bestend = b;
b0 = c0;
b1 = c1;
b2 = c2;
}
x2 += m_unweighted[c0+c1+c2];
}
x1 += m_unweighted[c0+c1];
}
x0 += m_unweighted[c0];
}
// save the block if necessary
if( CompareAnyLessThan( besterror, m_besterror ) )
{
// compute indices from cluster sizes.
/*uint bestindices = 0;
{
int i = b0;
for(; i < b0+b1; i++) {
bestindices = 2 << (2 * m_order[i]);
}
for(; i < b0+b1+b2; i++) {
bestindices = 3 << (2 * m_order[i]);
}
for(; i < 16; i++) {
bestindices = 1 << (2 * m_order[i]);
}
}*/
u8 bestindices[16];
{
//.........这里部分代码省略.........
开发者ID:NeoAnomaly,项目名称:xray,代码行数:101,代码来源:fastclusterfit.cpp
示例3: saveObject
QString Cube::saveObject()
{
QString obj;
QString aux;
obj += "c ";
Vec4 parameters;
//translacao
parameters = transform.getTranslateSeted();
obj += aux.sprintf("%.3f %.3f %.3f ",parameters.x(),parameters.y(),parameters.z());
//escala
parameters = transform.getScaleSeted();
obj += aux.sprintf("%.3f %.3f %.3f ",parameters.x(),parameters.y(),parameters.z());
//rotação
parameters = transform.getRotationSeted();
obj += aux.sprintf("%.3f %.3f %.3f ",parameters.x(),parameters.y(),parameters.z());
obj += aux.sprintf("%d ",this->getIdMaterial());
parameters = this->getMesh()->getMaterialM()->getAmbiente();
obj += aux.sprintf("%.3f %.3f %.3f ",parameters.x(),parameters.y(),parameters.z());
parameters = this->getMesh()->getMaterialM()->getDiffuse();
obj += aux.sprintf("%.3f %.3f %.3f ",parameters.x(),parameters.y(),parameters.z());
parameters = this->getMesh()->getMaterialM()->getSpecular();
obj += aux.sprintf("%.3f %.3f %.3f ",parameters.x(),parameters.y(),parameters.z());
obj += aux.sprintf("%.3f ",this->getMesh()->getMaterialM()->getShininess());
obj += aux.sprintf("%.3f ",this->getMesh()->getMaterialM()->getReflection());
obj += aux.sprintf("%.3f ",this->getMesh()->getMaterialM()->getRefraction());
obj += aux.sprintf("%.3f %.3f ",this->getMesh()->getMaterialM()->getGlossyReflection(),this->getMesh()->getMaterialM()->getGlossyRefraction());
obj += aux.sprintf("%.3f %.3f %.3f ",motion.x(),motion.y(),motion.z());
if (this->enabled)
obj += "t ";
else
obj += "f ";
if (this->selected)
obj += "t ";
else
obj += "f ";
obj +=this->name+"\n";
return obj;
}
开发者ID:danilob,项目名称:SceneBuild,代码行数:40,代码来源:cube.cpp
示例4: setVec4Parameter
void setVec4Parameter(const std::string name,
const Vec4 value,
bool isShaderConstant = true)
{ setColorParameter(name,
Color(value.x(), value.y(), value.z(), value.w()),
isShaderConstant); }
开发者ID:CaringLabs,项目名称:MediaFramework,代码行数:6,代码来源:FilterEffect.hpp
示例5: BuildJenga
void BuildJenga (osgViewer::Viewer* const viewer, osg::newtonWorld* const world, const Vec3& location, int high)
{
dAssert (viewer->getSceneData());
Group* const rootGroup = viewer->getSceneData()->asGroup();
dAssert (rootGroup);
Vec3 blockBoxSize (0.4f, 0.4f * 3.0f, 0.2f);
// find the floor position
Vec4 start(Vec4(location, 0.0f) + Vec4 (0.0f, 0.0f, 10.0f, 1.0f));
Vec4 end (start - Vec4 (0.0f, 0.0f, 20.0f, 1.0f));
newtonRayCast raycaster(world, DemoExample::m_rayCast);
raycaster.CastRay (start, end);
Vec4 position (raycaster.m_contact + Vec4 (0.0f, 0.0f, blockBoxSize.z() * 0.5f, 1.0f));
Matrix baseMatrix;
baseMatrix.setTrans (position.x(), position.y(), position.z());
// set realistic mass and inertia matrix for each block
dFloat mass = 5.0f;
// create a 90 degree rotation matrix
Matrix rotMatrix (Quat (90.0f * 3.141592f / 180.0f, Vec3 (0.0f, 0.0f, 1.0f)));
dFloat collisionPenetration = 1.0f / 256.0f;
// make a box collision shape
dNewtonCollisionBox boxShape (world, blockBoxSize.x(), blockBoxSize.y(), blockBoxSize.z(), DemoExample::m_all);
// create a visual for visual representation
newtonMesh boxMesh (&boxShape);
boxMesh.Triangulate();
// create a texture and apply uv to this mesh
ref_ptr<Texture2D> texture = new Texture2D;
ref_ptr<Image> image = osgDB::readImageFile("images\\crate.tga");
texture->setImage (image.get());
texture->setWrap(Texture::WRAP_S, Texture::REPEAT);
texture->setWrap(Texture::WRAP_R, Texture::REPEAT);
texture->setWrap(Texture::WRAP_T, Texture::REPEAT);
int materialId = boxMesh.AddMaterial(texture);
// apply uv to this mesh
boxMesh.ApplyBoxMapping (materialId, materialId, materialId);
// create a manual object for rendering
ref_ptr<Geode> geometryNode = boxMesh.CreateGeodeNode();
for (int i = 0; i < high; i ++) {
Matrix matrix(baseMatrix);
Vec3 step_x (Matrix::transform3x3 (Vec3(1.0f, 0.0f, 0.0f), matrix));
step_x = step_x * blockBoxSize.x();
matrix.setTrans (matrix.getTrans() - step_x);
for (int j = 0; j < 3; j ++) {
ref_ptr<MatrixTransform> transformNode = new MatrixTransform(matrix);
transformNode->addChild(geometryNode.get());
rootGroup->addChild(transformNode.get());
new newtonDynamicBody (world, mass, &boxShape, transformNode.get(), matrix);
matrix.setTrans (matrix.getTrans() + step_x);
}
baseMatrix = rotMatrix * baseMatrix;
Vec3 step_y (Matrix::transform3x3 (Vec3(0.0f, 0.0f, 1.0f), matrix));
step_y = step_y * (blockBoxSize.z() - collisionPenetration);
baseMatrix.setTrans (baseMatrix.getTrans() + step_y);
}
}
开发者ID:MCA4213,项目名称:osgnewton,代码行数:71,代码来源:BuildJenga.cpp
示例6: vConstants
//--------------------------------------------------------------------------------------
// The Taylor Series smooths and removes jitter based on a taylor series expansion
//--------------------------------------------------------------------------------------
void FilterTaylorSeries::Update( const SKinSkeletonRawData& pSkeletonData, const float fDeltaTime )
{
const float fJitterRadius = 0.05f;
const float fAlphaCoef = 1.0f - m_fSmoothing;
const float fBetaCoeff = (fAlphaCoef * fAlphaCoef ) / ( 2 - fAlphaCoef );
Vec4 vRawPos;
// Velocity, acceleration and Jolt are 1st, 2nd and 3rd degree derivatives of position respectively.
Vec4 vCurFilteredPos, vEstVelocity, vEstAccelaration, vEstJolt;
Vec4 vPrevFilteredPos, vPrevEstVelocity, vPrevEstAccelaration, vPrevEstJolt;
Vec4 vDiff;
float fDiff;
Vec4 vPredicted, vError;
Vec4 vConstants(0.0f, 1.0f, 0.5f, 0.1667f);
for (int i = 0; i < KIN_SKELETON_POSITION_COUNT; i++)
{
vRawPos = pSkeletonData.vSkeletonPositions[i];
vPrevFilteredPos = m_History[i].vPos;
vPrevEstVelocity = m_History[i].vEstVelocity;
vPrevEstAccelaration = m_History[i].vEstAccelaration;
vPrevEstJolt = m_History[i].vEstJolt;
if (!JointPositionIsValid(vPrevFilteredPos))
{
vCurFilteredPos = vRawPos;
vEstVelocity = Vec4(0,0,0,0);
vEstAccelaration = Vec4(0,0,0,0);
vEstJolt = Vec4(0,0,0,0);
}
else if (!JointPositionIsValid(vRawPos))
{
vCurFilteredPos = vPrevFilteredPos;
vEstVelocity = vPrevEstVelocity;
vEstAccelaration = vPrevEstAccelaration;
vEstJolt = vPrevEstJolt;
}
else
{
// If the current and previous frames have valid data, perform interpolation
vDiff = vPrevFilteredPos - vRawPos;
fDiff = fabs(vDiff.GetLength());
if (fDiff <= fJitterRadius)
{
vCurFilteredPos = vRawPos * fDiff/fJitterRadius + vPrevFilteredPos * (1.0f - fDiff/fJitterRadius);
}
else
{
vCurFilteredPos = vRawPos;
}
vPredicted = vPrevFilteredPos + vPrevEstVelocity;
vPredicted = vPredicted + vPrevEstAccelaration * (vConstants.y * vConstants.y * vConstants.z);
vPredicted = vPredicted + vPrevEstJolt * (vConstants.y * vConstants.y * vConstants.y * vConstants.w);
vError = vCurFilteredPos - vPredicted;
vCurFilteredPos = vPredicted + vError * fAlphaCoef;
vEstVelocity = vPrevEstVelocity + vError * fBetaCoeff;
vEstAccelaration = vEstVelocity - vPrevEstVelocity;
vEstJolt = vEstAccelaration - vPrevEstAccelaration;
}
// Update the state
m_History[i].vPos = vCurFilteredPos;
m_History[i].vEstVelocity = vEstVelocity;
m_History[i].vEstAccelaration = vEstAccelaration;
m_History[i].vEstJolt = vEstJolt;
// Output the data
m_FilteredJoints[i] = vCurFilteredPos;
m_FilteredJoints[i].w = 1.0f;
}
}
开发者ID:aronarts,项目名称:FireNET,代码行数:79,代码来源:JointFilter.cpp
示例7: setPlane
//==============================================================================
static void setPlane(const Vec4& abcd, Plane& p)
{
Vec4 n = abcd.xyz0();
F32 len = n.getLength();
p = Plane(n / len, -abcd.w() / len);
}
开发者ID:Al1a123,项目名称:anki-3d-engine,代码行数:7,代码来源:Functions.cpp
示例8: direction
Vec4 SpotLight::calculateColor(Vec4 pit, Vec4 n,Vec4 viewer, Material *m,Vec4 pos,Vec4 texColor,int mode_texture)
{
if(mode_texture==TYPE_ONLY_TEXTURE){
Vec4 direction(direction_light->x1,direction_light->x2,direction_light->x3);
Vec4 position(position_light->x1,position_light->x2,position_light->x3);
Vec4 l = (position-pit)/(position-pit).module();
float fator = fmax((n*l)/(n.module()*l.module()),0);
Vec4 Diffuse;
Diffuse.x1 = (texColor.x() * diffuse_light->x1)*fator;
Diffuse.x2 = (texColor.y() * diffuse_light->x2)*fator;
Diffuse.x3 = (texColor.z() * diffuse_light->x3)*fator;
l = l.unitary();
Vec4 r = (n*((l*n)*2) - l);
Vec4 v = (viewer-pit)/(viewer-pit).module();
r = (r+v)/(r+v).module();
float fator2 = fmax(pow((r*v),m->shininess*128),0);
if(r*n<0) fator2 = 0;
Vec4 especular;
especular.x1 = (texColor.x() * specular_light->x1)*fator2;
especular.x2 = (texColor.y() * specular_light->x2)*fator2;
especular.x3 = (texColor.z() * specular_light->x3)*fator2;
Vec4 ambiente;
ambiente.x1 = texColor.x() * ambient_light->x1;
ambiente.x2 = texColor.y() * ambient_light->x2;
ambiente.x3 = texColor.z() * ambient_light->x3;
Vec4 color = ((Diffuse+especular))*isInDualConeSpot(pit)*pow(direction*(l*-1),expoent_light)*attenuation((position-viewer).module());
return color;
}else if(mode_texture==TYPE_REPLACE_TEXTURE){
Vec4 direction(direction_light->x1,direction_light->x2,direction_light->x3);
//calculo da contribuição difusa
Vec4 position(position_light->x1,position_light->x2,position_light->x3);
if ((position-pit).unitary()*n<=0) return Vec4();
//direction = (direction)/(direction).module();
Vec4 l = (position-pit)/(position-pit).module();
float fator = fmax((n*l)/(n.module()*l.module()),0);
Vec4 Diffuse;
Diffuse.x1 = (m->diffuse[0] * diffuse_light->x1)*fator;
Diffuse.x2 = (m->diffuse[1] * diffuse_light->x2)*fator;
Diffuse.x3 = (m->diffuse[2] * diffuse_light->x3)*fator;
//calculo da contribuicao especular
l = l.unitary();
Vec4 r = (n*((l*n)*2) - l);
Vec4 v = (viewer-pit)/(viewer-pit).module();
r = (r+v)/(r+v).module();
float fator2 = fmax(pow((r*v),m->shininess*128),0);
if(r*n<0) fator2 = 0;
Vec4 especular;
especular.x1 = (m->specular[0] * specular_light->x1)*fator2;
especular.x2 = (m->specular[1] * specular_light->x2)*fator2;
especular.x3 = (m->specular[2] * specular_light->x3)*fator2;
//calculo da contribuição ambiente
Vec4 ambiente;
ambiente.x1 = m->ambient[0] * ambient_light->x1;
ambiente.x2 = m->ambient[1] * ambient_light->x2;
ambiente.x3 = m->ambient[2] * ambient_light->x3;
Vec4 color = texColor.mult(((Diffuse+especular))*isInDualConeSpot(pit)*pow(direction*(l*-1),expoent_light)*attenuation((position-viewer).module()));
return color;
}else{
Vec4 direction(direction_light->x1,direction_light->x2,direction_light->x3);
//calculo da contribuição difusa
Vec4 position(position_light->x1,position_light->x2,position_light->x3);
if ((position-pit).unitary()*n<=0) return Vec4();
//direction = (direction)/(direction).module();
Vec4 l = (position-pit)/(position-pit).module();
float fator = fmax((n*l)/(n.module()*l.module()),0);
Vec4 Diffuse;
Diffuse.x1 = (m->diffuse[0] * diffuse_light->x1)*fator;
Diffuse.x2 = (m->diffuse[1] * diffuse_light->x2)*fator;
Diffuse.x3 = (m->diffuse[2] * diffuse_light->x3)*fator;
//calculo da contribuicao especular
l = l.unitary();
Vec4 r = (n*((l*n)*2) - l);
Vec4 v = (viewer-pit)/(viewer-pit).module();
r = (r+v)/(r+v).module();
float fator2 = fmax(pow((r*v),m->shininess*128),0);
if(r*n<0) fator2 = 0;
Vec4 especular;
especular.x1 = (m->specular[0] * specular_light->x1)*fator2;
especular.x2 = (m->specular[1] * specular_light->x2)*fator2;
especular.x3 = (m->specular[2] * specular_light->x3)*fator2;
//calculo da contribuição ambiente
Vec4 ambiente;
ambiente.x1 = m->ambient[0] * ambient_light->x1;
ambiente.x2 = m->ambient[1] * ambient_light->x2;
ambiente.x3 = m->ambient[2] * ambient_light->x3;
//.........这里部分代码省略.........
开发者ID:danilob,项目名称:Raytracing,代码行数:101,代码来源:spotlight.cpp
示例9: Vec4
void SpotLight::setPosition(Vec4 pos)
{
position_light = new Vec4(pos.x(),pos.y(),pos.z());
}
开发者ID:danilob,项目名称:Raytracing,代码行数:4,代码来源:spotlight.cpp
示例10: Vector
Vector(const Vec4& vector) :
detail::VectorType<4>(vector.x(), vector.y(), vector.z(), 0.0f)
{
}
开发者ID:mikosz,项目名称:coconut,代码行数:4,代码来源:Vector.hpp
示例11: getStartTime
//==============================================================================
void FollowPathEvent::update(F32 prevUpdateTime, F32 crntTime)
{
MoveComponent& move = movableSceneNode->getComponent<MoveComponent>();
I pointA = 0;
I pointB = 0;
// Calculate the current distance. Clamp it to max distance
F32 crntDistance = distPerTime * (crntTime - getStartTime());
ANKI_ASSERT(crntDistance >= 0.0);
crntDistance = std::min(crntDistance, path->getDistance());
const I pointsCount = path->getPoints().size();
ANKI_ASSERT(pointsCount > 1);
// Find the points that we lie between
for(I i = 1; i < pointsCount; i++)
{
const PathPoint& ppa = path->getPoints()[i - 1];
const PathPoint& ppb = path->getPoints()[i];
if(crntDistance > ppa.getDistanceFromFirst()
&& crntDistance <= ppb.getDistanceFromFirst())
{
pointA = i - 1;
pointB = i;
break;
}
}
ANKI_ASSERT(pointA < pointsCount && pointB < pointsCount);
I preA = std::max((I)0, pointA - 1);
I postB = std::min(pointsCount - 1, pointB + 1);
/*I pminus2 = std::max((I)0, pointA - 2);
I pminus1 = std::max((I)0, pointA - 1);*/
// Calculate the u [0.0, 1.0]
F32 u = path->getPoints()[pointB].getDistance() + getEpsilon<F32>();
ANKI_ASSERT(u != 0.0);
const F32 c = crntDistance
- path->getPoints()[pointA].getDistanceFromFirst();
u = c / u;
// Calculate and set new position and rotation for the movable
/*Vec3 newPos = cubicInterpolate(
path->getPoints()[preA].getPosition(),
path->getPoints()[pointA].getPosition(),
path->getPoints()[pointB].getPosition(),
path->getPoints()[postB].getPosition(),
u);*/
Vec3 newPos = interpolate(
path->getPoints()[pointA].getPosition(),
path->getPoints()[pointB].getPosition(),
u);
{
F32 u2 = u * u;
Vec4 us(1, u, u2, u2 * u);
F32 t = 0.7;
Mat4 tentionMat(
0.0, 1.0, 0.0, 0.0,
-t, 0.0, t, 0.0,
2.0 * t, t - 3.0, 3.0 - 2.0 * t, -t,
-t, 2.0 - t, t - 2.0, t);
Vec4 tmp = us * tentionMat;
Mat4 posMat;
posMat.setRows(
Vec4(path->getPoints()[preA].getPosition(), 1.0),
Vec4(path->getPoints()[pointA].getPosition(), 1.0),
Vec4(path->getPoints()[pointB].getPosition(), 1.0),
Vec4(path->getPoints()[postB].getPosition(), 1.0));
Vec4 finalPos = tmp * posMat;
newPos = finalPos.xyz();
}
Quat newRot = path->getPoints()[pointA].getRotation().slerp(
path->getPoints()[pointB].getRotation(),
u);
F32 scale = move.getLocalTransform().getScale();
Transform trf;
trf.setOrigin(newPos);
trf.setRotation(Mat3(newRot));
trf.setScale(scale);
move.setLocalTransform(trf);
}
开发者ID:zhouxh1023,项目名称:anki-3d-engine,代码行数:95,代码来源:FollowPathEvent.cpp
示例12: DrawTrack
// This method needs to be broken up
void tcHookInfo::DrawTrack(long anID)
{
std::string s;
char zBuff[128];
float ftextx = 10.0f;
float ftexty = 22.0f;
UINT8 nOwnAlliance = mpUserInfo->GetOwnAlliance();
Vec4 color;
tcSensorMapTrack* pSMTrack = mpSS->mcSensorMap.GetSensorMapTrack(anID, nOwnAlliance);
if (pSMTrack == 0) return;
const tcTrack *pTrack = pSMTrack->GetTrack();
// classification
ClassificationToString(pTrack->mnClassification, zBuff);
strcat(zBuff, " track");
color.set(0.4f, 1.0f, 0.4f, 1.0f);
if (!pSMTrack->IsIdentified())
{
DrawTextR(zBuff, ftextx-2.0f, ftexty, defaultFont.get(),
color, fontSizeLarge, LEFT_BASE_LINE);
ftexty += 20.0f;
}
else // track is identified, look up class name
{
if (tcDatabaseObject* databaseObj = database->GetObject(pSMTrack->GetDatabaseId()))
{
s = databaseObj->GetDisplayName();
}
else // error, not found in database
{
s = "Error";
}
DrawTextR(s.c_str(), ftextx-2.0f, ftexty,
defaultFont.get(), color, fontSizeLarge, LEFT_BASE_LINE);
ftexty += 15.0f;
DrawTextR(zBuff, ftextx, ftexty,
defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
ftexty += 20.0f;
}
// speed, heading, altitude, terrain info
s = "";
if (pTrack->mnFlags & TRACK_HEADING_VALID)
{
//if (heading_deg < 0) heading_deg += 360;
if (pTrack->mnFlags & TRACK_BEARING_ONLY)
{
int bearing_deg(C_180OVERPI*pTrack->bearing_rad + 0.5f);
bearing_deg = bearing_deg + int(bearing_deg < 0)*360;
sprintf(zBuff,"BRG %03d ", bearing_deg);
}
else
{
int heading_deg(C_180OVERPI*pTrack->mfHeading_rad + 0.5f);
heading_deg = heading_deg + int(heading_deg < 0)*360;
sprintf(zBuff,"HDG %03d ", heading_deg);
}
s += zBuff;
}
if (pTrack->mnFlags & TRACK_SPEED_VALID)
{
sprintf(zBuff," SPD %s ", units->GetUserSpeedString(pTrack->mfSpeed_kts));
s += zBuff;
}
if ((pTrack->mnClassification & (PTYPE_AIR | PTYPE_MISSILE))
&&(pTrack->mnFlags & TRACK_ALT_VALID))
{
sprintf(zBuff," ALT %s", units->GetUserAltitudeString(pTrack->mfAlt_m));
s += zBuff;
}
DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
ftexty += 15;
// Draw reporting platform info
size_t nContributors = pSMTrack->GetContributorCount();
s = "Detected by: ";
for (size_t k=0; k<nContributors; k++)
{
s += std::string(pSMTrack->GetContributorName(k));
if (k < nContributors-1) s += ",";
}
if (s.size() > 35)
{
s = s.substr(0, 35);
}
DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
ftexty += 15;
// Draw contact update time
double t = mpSS->GetTime();
//.........这里部分代码省略.........
开发者ID:WarfareCode,项目名称:gcblue,代码行数:101,代码来源:tcHookInfo.cpp
示例13: DrawOwn
void tcHookInfo::DrawOwn(tcGameObject *pHookedObj)
{
std::string s;
char zBuff[128];
float ftextx = 10.0f;
float ftexty = 22.0f;
Vec4 color;
if (pHookedObj == NULL) {return;}
s = pHookedObj->mzUnit.c_str();
color.set(0.4f, 1.0f, 0.4f, 1.0f);
DrawTextR(s.c_str(), ftextx-2.0f, ftexty, defaultFont.get(), color, fontSizeLarge, LEFT_BASE_LINE,
180.0f);
ftexty += 20.0f;
sprintf(zBuff, "%s (id %d)", pHookedObj->GetDisplayClassName(), pHookedObj->mnID);
s = zBuff;
DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
ftexty += 20.0f;
/*** mnClassID, mnModelType, mnType (classification) ***/
GetObjectInfo(s, pHookedObj->mpDBObject, pHookedObj);
DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
ftexty += 15.0f;
// speed, heading, altitude, terrain info
tcKinematics *pkin = &pHookedObj->mcKin;
int heading_deg = int(C_180OVERPI*pkin->mfHeading_rad + 0.5f);
heading_deg = heading_deg + (int(heading_deg < 0) - int(heading_deg >= 360))*360;
sprintf(zBuff,"%s, hdg %03d, alt %s",
units->GetUserSpeedString(pkin->mfSpeed_kts), heading_deg,
units->GetUserAltitudeString(pkin->mfAlt_m));
s = zBuff;
DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
ftexty += 15;
sprintf(zBuff, "Terrain %s", units->GetUserAltitudeString(pHookedObj->mcTerrain.mfHeight_m));
s = zBuff;
DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
ftexty+=15;
// lat, lon
LonLatToStringB(C_180OVERPI*(float)pkin->mfLon_rad,C_180OVERPI*(float)pkin->mfLat_rad,s);
DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
ftexty += 15;
/*** damage ***/
float damageLevelPercent = 100.0f * pHookedObj->GetDamageLevel();
if (damageLevelPercent > 100.0f) damageLevelPercent = 100.0f;
if (damageLevelPercent == 0)
{
strcpy(zBuff,"Damage: none");
}
else if (damageLevelPercent >= 50.0f)
{
color.set(1.0f, 0.4f, 0.4f, 1.0f);
sprintf(zBuff, "Damage: %2.0f%%", damageLevelPercent);
}
else
{
color.set(1.0f, 1.0f, 0.4f, 1.0f);
sprintf(zBuff, "Damage: %2.0f%%", damageLevelPercent);
}
s = zBuff;
DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
ftexty += 15;
color.set(0.4f, 1.0f, 0.4f, 1.0f);
// multiplayer info
if (mpSS->IsMultiplayerActive())
{
const std::string& controller = pHookedObj->GetController();
if (controller.size())
{
s = "Controlled by ";
s += controller;
}
else
{
s = "No controller";
}
DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
ftexty += 15;
color.set(0.4f, 1.0f, 0.4f, 1.0f);
}
// AI action text for platform objects
tcPlatformObject* pPlatformObj = dynamic_cast<tcPlatformObject*>(pHookedObj);
if (pPlatformObj != NULL)
//.........这里部分代码省略.........
开发者ID:WarfareCode,项目名称:gcblue,代码行数:101,代码来源:tcHookInfo.cpp
示例14: Vec4
//--------------------------------------------------------------------------------------
// Name: CombiJointFilter()
// Desc: A filter for the positional data. This filter uses a combination of velocity
// position history to filter the joint positions.
//--------------------------------------------------------------------------------------
void FilterCombination::Update( const SKinSkeletonRawData& pSkeletonData, const float fDeltaTime )
{
// Process each joint
for ( uint32 nJoint = 0; nJoint < KIN_SKELETON_POSITION_COUNT; ++nJoint )
{
// Remember where the camera thinks this joint should be
m_History[ nJoint ].m_vWantedPos = pSkeletonData.vSkeletonPositions[ nJoint ];
Vec4 vDelta;
vDelta = m_History[ nJoint ].m_vWantedPos - m_History[ nJoint ].m_vLastWantedPos;
{
Vec4 vBlended;
// Calculate the vBlended value - could optimize this by remembering the running total and
// subtracting the oldest value and then adding the newest. Saves adding them all up on each frame.
vBlended = Vec4(0,0,0,0);
for( uint32 k = 0; k < m_nUseTaps; ++k)
{
vBlended = vBlended + m_History[ nJoint ].m_vPrevDeltas[k];
}
vBlended = vBlended / ((float)m_nUseTaps);
vBlended.w = 0.0f;
vDelta.w = 0.0f;
float fDeltaLength = vDelta.GetLength();
float fBlendedLength = vBlended.GetLength();
m_History[ nJoint ].m_fWantedLocalBlendRate = m_fDefaultApplyRate;
m_History[ nJoint ].m_bActive[0] = false;
m_History[ nJoint ].m_bActive[1] = false;
m_History[ nJoint ].m_bActive[2] = false;
// Does the current velocity and history have a reasonable magnitude?
if( fDeltaLength >= m_fDeltaLengthThreshold &&
fBlendedLength >= m_fBlendedLengthThreshold )
{
float fDotProd;
float fConfidence;
if( m_bDotProdNormalize )
{
Vec4 vDeltaOne = vDelta;
vDeltaOne.Normalize();
Vec4 vBlendedOne = vBlended;
vBlendedOne.Normalize();
fDotProd = vDeltaOne.Dot( vBlendedOne );
}
else
{
fDotProd = vDelta.Dot(vBlended);
}
// Is the current frame aligned to the recent history?
if( fDotProd >= m_fDotProdThreshold )
{
fConfidence = fDotProd;
m_History[ nJoint ].m_fWantedLocalBlendRate = min( fConfidence, 1.0f );
m_History[ nJoint ].m_bActive[0] = true;
}
}
assert( m_History[ nJoint ].m_fWantedLocalBlendRate <= 1.0f );
}
// Push the previous deltas down the history
for( int j = m_nUseTaps-2; j >= 0; --j )
{
m_History[ nJoint ].m_vPrevDeltas[j+1] = m_History[ nJoint ].m_vPrevDeltas[j];
}
// Store the current history
m_History[ nJoint ].m_vPrevDeltas[0] = vDelta;
// Remember where the camera thought this joint was on the this frame
m_History[ nJoint ].m_vLastWantedPos = m_History[ nJoint ].m_vWantedPos;
}
// Secondary and tertiary blending
for ( uint32 pass = 0; pass < 2; ++pass )
{
for ( uint32 bone = 0; bone < g_numBones; ++bone )
{
float fRate1;
float fRate2;
fRate1 = m_History[ g_Bones[bone].startJoint ].m_fWantedLocalBlendRate;
fRate2 = m_History[ g_Bones[bone].endJoint ].m_fWantedLocalBlendRate;
// Blend down? Start to end
if( (fRate1 * m_fDownBlendRate) > fRate2)
{
// Yes, apply
m_History[ g_Bones[bone].endJoint ].m_fWantedLocalBlendRate = ( fRate1 * m_fDownBlendRate );
//.........这里部分代码省略.........
开发者ID:aronarts,项目名称:FireNET,代码行数:101,代码来源:JointFilter.cpp
示例15: JointPositionIsValid
void FilterDoubleExponential::Update( const SKinSkeletonRawData& pSkeletonData, uint32 i, const KIN_TRANSFORM_SMOOTH_PARAMETERS& smoothingParams )
{
Vec4 vPrevRawPosition;
Vec4 vPrevFilteredPosition;
Vec4 vPrevTrend;
Vec4 vRawPosition;
Vec4 vFilteredPosition;
Vec4 vPredictedPosition;
Vec4 vDiff;
Vec4 vTrend;
Vec4 vLength;
float fDiff;
BOOL bJointIsValid;
const Vec4* __restrict pJointPositions = pSkeletonData.vSkeletonPositions;
vRawPosition = pJointPositions[i];
vPrevFilteredPosition = m_History[i].m_vFilteredPosition;
vPrevTrend = m_History[i].m_vTrend;
vPrevRawPosition = m_History[i].m_vRawPosition;
bJointIsValid = JointPositionIsValid(vRawPosition);
// If joint is invalid, reset the filter
if (!bJointIsValid)
{
m_History[i].m_dwFrameCount = 0;
}
// Initial start values
if (m_History[i].m_dwFrameCount == 0)
{
vFilteredPosition = vRawPosition;
vTrend = Vec4(0,0,0,0);
m_History[i].m_dwFrameCount++;
}
else if (m_History[i].m_dwFrameCount == 1)
{
vFilteredPosition = (vRawPosition + vPrevRawPosition) * 0.5f;
vDiff = vFilteredPosition - vPrevFilteredPosition;
vTrend = (vDiff * smoothingParams.m_fCorrection) + (vPrevTrend * (1.0f - smoothingParams.m_fCorrection));
m_History[i].m_dwFrameCount++;
}
else
{
// First apply jitter filter
vDiff = vRawPosition - vPrevFilteredPosition;
fDiff = fabs(vDiff.GetLength());
if (fDiff <= smoothingParams.m_fJitterRadius)
{
vFilteredPosition = vRawPosition * (fDiff/smoothingParams.m_fJitterRadius) + vPrevFilteredPosition * (1.0f - fDiff/smoothingParams.m_fJitterRadius);
}
else
{
vFilteredPosition = vRawPosition;
}
// Now the double exponential smoothing filter
vFilteredPosition = vFilteredPosition * (1.0f - smoothingParams.m_fSmoothing) + (vPrevFilteredPosition + vPrevTrend) * smoothingParams.m_fSmoothing;
vDiff = vFilteredPosition - vPrevFilteredPosition;
vTrend = vDiff * smoothingParams.m_fCorrection + vPrevTrend * (1.0f - smoothingParams.m_fCorrection);
}
// Predict into the future to reduce latency
vPredictedPosition = vFilteredPosition + (vTrend * smoothingParams.m_fPrediction);
// Check that we are not too far away from raw data
vDiff = vPredictedPosition - vRawPosition;
fDiff = fabs(vDiff.GetLength());
if (fDiff > smoothingParams.m_fMaxDeviationRadius)
{
vPredictedPosition = vPredictedPosition * smoothingParams.m_fMaxDeviationRadius/fDiff + vRawPosition * (1.0f - smoothingParams.m_fMaxDeviationRadius/fDiff);
}
// Save the data from this frame
m_History[i].m_vRawPosition = vRawPosition;
m_History[i].m_vFilteredPosition = vFilteredPosition;
m_History[i].m_vTrend = vTrend;
// Output the data
m_FilteredJoints[i] = vPredictedPosition;
m_FilteredJoints[i].w = 1.0f;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:86,代码来源:JointFilter.cpp
示例16: Tform
bool Sphere::Intersect( Ray const &ray, float *tHit, float *epsilon, DifferentialGeometry *geom ) const {
Transform tf = Tform();
Ray r = ray * Inverse( tf );
float t;
if( !Intersect( ray, &t ) )
return false;
// compute differential geometry
Vec4 p = ray.Point( t );
float x = p.X();
float y = p.Y();
float z = p.Z();
if( x == 0.0f && z == 0.0f ) {
// can't have both atan2 arguments be zero
z = kEpsilon * m_radius;
}
float theta = atan2( p.X(), p.Z() );
if( theta < 0.0f ) {
// remap theta to [0, 2pi] to match sphere's definition
theta += k2Pi;
}
float phi = Acos( Clamp( z / m_radius, -1.0f, 1.0f ) );
// parameterize sphere hit
float u = theta * kInv2Pi;
float v = phi * kInvPi;
float sTheta, cTheta;
float sPhi, cPhi;
SinCos( theta, &sTheta, &cTheta );
SinCos( phi, &sPhi, &cPhi );
Vec4 dpdu( k2Pi * z, 0.0f, -k2Pi * x, 0.0f );
Vec4 dpdv( kPi * y * sTheta, -kPi * m_radius * sPhi, kPi * y * cTheta, 0.0f );
Vec4 d2pdu2( -k2Pi * k2Pi * x, 0.0f, -k2Pi * k2Pi * z, 0.0f );
Vec4 d2pduv( k2Pi * kPi * y * cTheta, 0.0f, -k2Pi * kPi * y * sTheta, 0.0f );
Vec4 d2pdv2( -kPi * kPi * x, -kPi * kPi * y, -kPi * kPi * z, 0.0f );
// change in normal is computed using Weingarten equations
Scalar E = Dot( dpdu, dpdu );
Scalar F = Dot( dpdu, dpdv );
Scalar G = Dot( dpdv, dpdv );
Vec4 N = Normalize( Cross( dpdu, dpdv ) );
Scalar e = Dot( N, d2pdu2 );
Scalar f = Dot( N, d2pduv );
Scalar g = Dot( N, d2pdv2 );
Scalar h = 1.0f / ( E * G - F * F );
Vec4 dndu = ( f * F - e * G ) * h * dpdu + ( e * F - f * E ) * h * dpdv;
Vec4 dndv = ( g * F - f * G ) * h * dpdu + ( f * F - g * E ) * h * dpdv;
*tHit = t;
*epsilon = 5e-4f * t;
// return world space differential geometry
*geom = DifferentialGeometry( Handle(), p * tf, dpdu * tf, dpdv * tf, Normal( dndu ) * tf, Normal( dndv ) * tf, u, v );
return true;
}
开发者ID:0x0002,项目名称:Renderer,代码行数:64,代码来源:Sphere.cpp
示例17: solve
void RationalBilinearInverter::solve(
Vec2 const & p,
Vec4 const & p00, Vec4 const & p10,
Vec4 const & p01, Vec4 const & p11
)
{
double m[4][6] = {
{ p00.x(), p10.x(), p01.x(), -p.x(), 0, -p11.x() },
{ p00.y(), p10.y(), p01.y(), -p.y(), 0, -p11.y() },
{ p00.z(), p10.z(), p01.z(), -1, 0, -p11.z() },
{ p00.w(), p10.w(), p01.w(), 0, 1, -p11.w() }
};
for (int j = 0; j < 4; ++j) {
double a = 0.0;
std::for_each(m[j], m[j + 1], [&] (double & f) { a = (std::max)(a, fabs(f)); });
std::for_each(m[j], m[j + 1], [&] (double & f) { f /= a; });
}
for (int j = 0; j < 4; ++j) {
int pivot_row = j; double pivot_value = fabsf(m[j][j]);
for (int k = j + 1; k < 4; ++k) {
auto t = fabsf(m[k][j]);
if (t > pivot_value) {
pivot_value = t;
pivot_row = k;
}
}
if (pivot_row != j) { swap(m[j], m[pivot_row]); }
double * row = m[j] + j, * end = m[j + 1];
normalize_front(row, end);
for (int k = j + 1; k < 4; ++k) {
scale_and_subtract_row(m[k] + j, m[k + 1], m[k][j], row);
}
}
for (int i = 3; i > 0; --i) {
for (int j = i - 1; j >= 0; --j) {
scale_and_subtract_row(m[j] + i, m[j + 1], m[j][i], m[i] + i);
}
}
double quad_a = m[0][5] - m[1][5] * m[2][5],
quad_b = m[0][4] - m[1][4] * m[2][5] - m[1][5] * m[2][4],
quad_c = - m[1][4] * m[2][4];
if (-1e-3 < quad_a && quad_a < 1e-3) { quad_a = 0.; }
if (-1e-3 < quad_b && quad_b < 1e-3) { quad_b = 0.; }
if (-1e-3 < quad_c && quad_c < 1e-3) { quad_c = 0.; }
QuadraticSolver<double> q(quad_a, quad_b, quad_c);
for (auto it = q.begin(); it != q.end(); ++it) {
double D = *it,
alpha = m[3][4] + m[3][5] * D;
if (alpha < 1.0 - 1e-3) { continue; }
double A = m[0][4] + m[0][5] * D,
B = m[1][4] + m[1][5] * D,
C = m[2][4] + m[2][5] * D,
d = A + B + C + D;
if (!d || d != d) { continue; }
double r = 1.0 / d,
u = (B + D) * r,
v = (C + D) * r;
if (u < -1e-3 || u >= 1.0-1e-3) { continue; }
if (v < -1e-3 || v >= 1.0-1e-3) { continue; }
solutions_[size_++] = std::make_pair(alpha, Vec2(u, v));
}
if (size_ == 2 && solutions_[0].first > solutions_[1].first)
{ std::swap(solutions_[0], solutions_[1]); }
}
开发者ID:bracket,项目名称:handsome,代码行数:83,代码来源:RationalBilinearInverter.cpp
示例18: setNormal
void Light::setNormal(Vec4<GLfloat> normal)
{
UBOUniform normalUbo = uniforms[std::string("normal")];
size_t size = normalUbo.getSize() * typeSize(normalUbo.getType());
memcpy(lightData + normalUbo.getOffset(), normal.getData(), size);
}
开发者ID:yaspoon,项目名称:SDL2OpenGL4Basic,代码行数:6,代码来源:Light.cpp
示例19: collision
bool Grid::collision()
{
bool ret = false;
if(!current)
{
return false;
}
Vec4<Vec2i> blocks = current->getBricks();
if(blocks.X().Y() < H && (blocks.X().Y() == 0 || GD[((blocks.X().Y()-1)*W)+blocks.X().X()]))
{
ret = true;
}
if(blocks.Y().Y() < H && (blocks.Y().Y() == 0 || GD[((blocks.Y().Y()-1)*W)+blocks.Y().X()]))
{
ret = true;
}
if(blocks.Z().Y() < H && (blocks.Z().Y() == 0 || GD[((blocks.Z().Y()-1)*W)+blocks.Z().X()]))
{
ret = true;
}
if(blocks.W().Y() < H && (blocks.W().Y() == 0 || GD[((blocks.W().Y()-1)*W)+blocks.W().X()]))
{
ret = true;
}
return ret;
}
开发者ID:VileLasagna,项目名称:WarpDrive,代码行数:29,代码来源:Grid.cpp
-
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:18245|2023-10-27
-
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9668|2022-11-06
-
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8175|2022-11-06
-
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8547|2022-11-06
-
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8454|2022-11-06
-
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9383|2022-11-06
-
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8426|2022-11-06
-
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7858|2022-11-06
-
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8410|2022-11-06
-
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7394|2022-11-06
|
请发表评论