本文整理汇总了C++中Pnt3f类的典型用法代码示例。如果您正苦于以下问题:C++ Pnt3f类的具体用法?C++ Pnt3f怎么用?C++ Pnt3f使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pnt3f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deepCloneTree
NodeTransitPtr OctreeVisualization::createNodeGeo(OctreePtr,
const Octree::OTNodePtr node,
Material* GeoMaterial,
const Node* BaseGeo)
{
//Make the Geoemtry
NodeRecPtr box = deepCloneTree(BaseGeo);
dynamic_cast<Geometry*>(box->getCore())->setMaterial(GeoMaterial);
Matrix m;
TransformRecPtr box_trans;
NodeRecPtr trans_node = makeCoredNode<Transform>(&box_trans);
Pnt3f Center;
node->getVolume().getCenter(Center);
m.setTranslate( Center.x(), Center.y(), Center.z());
const Real32 Offset(0.0f);
Vec3f Size;
node->getVolume().getSize(Size);
m.setScale(Size.x()-(Size.x()*Offset), Size.y()-(Size.y()*Offset), Size.z()-(Size.z()*Offset));
box_trans->setMatrix(m);
trans_node->addChild(box);
return NodeTransitPtr(trans_node);
}
示例2: BeaconToWorld
bool TurbulenceParticleAffector::affect(ParticleSystemRefPtr System, Int32 ParticleIndex, const Time& elps)
{
if(getBeacon() != NULL)
{
Matrix BeaconToWorld(getBeacon()->getToWorld());
Vec3f translation, tmp;
Quaternion tmp2;
BeaconToWorld.getTransform(translation,tmp2,tmp,tmp2);
Pnt3f particlePos = System->getPosition(ParticleIndex);
Real32 distanceFromAffector = particlePos.dist(Pnt3f(translation.x(),translation.y(),translation.z()));
if((getMaxDistance() < 0.0) || (distanceFromAffector <= getMaxDistance())) //only affect the particle if it is in range
{
Real32 Xparam, Yparam, Zparam;
Pnt3f pos(System->getPosition(ParticleIndex));
getPerlinDistribution()->setPhase(getPhase()[0]);
Xparam = getPerlinDistribution()->generate(pos[0]);
getPerlinDistribution()->setPhase(getPhase()[1]);
Yparam = getPerlinDistribution()->generate(pos[1]);
getPerlinDistribution()->setPhase(getPhase()[2]);
Zparam = getPerlinDistribution()->generate(pos[2]);
Vec3f fieldAffect(Vec3f(Xparam, Yparam, Zparam));
fieldAffect = fieldAffect * (getAmplitude()*
(elps/(OSG::osgClamp<Real32>(1.0f,std::pow(distanceFromAffector,getAttenuation()),TypeTraits<Real32>::getMax()))));
System->setVelocity(System->getVelocity(ParticleIndex) + fieldAffect, ParticleIndex);
} // end distance conditional
} // end null beacon conditional
return false;
}
示例3: BeaconToWorld
bool VortexParticleAffector::affect(ParticleSystemRefPtr System, Int32 ParticleIndex, const Time& elps)
{
if(getBeacon() != NULL)
{
Matrix BeaconToWorld(getBeacon()->getToWorld());
Vec3f translation, tmp;
Quaternion tmp2;
BeaconToWorld.getTransform(translation,tmp2,tmp,tmp2);
Pnt3f particlePos = System->getPosition(ParticleIndex);
Real32 distanceFromAffector = particlePos.dist(Pnt3f(translation.x(),translation.y(),translation.z()));
if((getMaxDistance() < 0.0) || (distanceFromAffector <= getMaxDistance())) //only affect the particle if it is in range
{
Vec3f particleDirectionFromVortex(particlePos.x() - translation.x(), particlePos.y() - translation.y(), particlePos.z() - translation.z());
particleDirectionFromVortex = particleDirectionFromVortex.cross(getVortexAxis());
particleDirectionFromVortex.normalize();
particleDirectionFromVortex = particleDirectionFromVortex *
((-getMagnitude() *
elps)/OSG::osgClamp<Real32>(1.0f,std::pow(distanceFromAffector,getAttenuation()),TypeTraits<Real32>::getMax()));
System->setVelocity(particleDirectionFromVortex + System->getVelocity(ParticleIndex),ParticleIndex);
}
}
return false;
}
示例4: getBounds
void SphereVolume::getBounds(Pnt3f &min, Pnt3f &max) const
{
min.setValues(_center[0] - _radius,
_center[1] - _radius,
_center[2] - _radius);
max.setValues(_center[0] + _radius,
_center[1] + _radius,
_center[2] + _radius);
}
示例5: calcDistance
Real32 DistanceLOD::calcDistance(DrawActionBase *pAction,
const Matrix &mToWorld)
{
Matrix m;
m.invertFrom(mToWorld);
m.mult(pAction->getCameraToWorld());
Pnt3f eyepos;
m.mult(eyepos, eyepos);
_lastDist = eyepos.dist(getCenter());
return _lastDist;
}
示例6: multFull
void VRMouse::multFull(Matrix _matrix, const Pnt3f &pntIn, Pnt3f &pntOut) {
float w = _matrix[0][3] * pntIn[0] +
_matrix[1][3] * pntIn[1] +
_matrix[2][3] * pntIn[2] +
_matrix[3][3];
/*if (w <1) {
fstream file("dump.txt", fstream::out | fstream::app);
file << w << endl;
file.close();
}*/
if(w == TypeTraits<float>::getZeroElement())
{
cout << "\nWARNING: w = " << _matrix[0][3] * pntIn[0] << " " << _matrix[1][3] * pntIn[1] << " " << _matrix[2][3] * pntIn[2];
pntOut.setValues(
(_matrix[0][0] * pntIn[0] +
_matrix[1][0] * pntIn[1] +
_matrix[2][0] * pntIn[2] +
_matrix[3][0] ),
(_matrix[0][1] * pntIn[0] +
_matrix[1][1] * pntIn[1] +
_matrix[2][1] * pntIn[2] +
_matrix[3][1] ),
(_matrix[0][2] * pntIn[0] +
_matrix[1][2] * pntIn[1] +
_matrix[2][2] * pntIn[2] +
_matrix[3][2] ) );
}
else
{
w = TypeTraits<float>::getOneElement() / w;
pntOut.setValues(
(_matrix[0][0] * pntIn[0] +
_matrix[1][0] * pntIn[1] +
_matrix[2][0] * pntIn[2] +
_matrix[3][0] ) * w,
(_matrix[0][1] * pntIn[0] +
_matrix[1][1] * pntIn[1] +
_matrix[2][1] * pntIn[2] +
_matrix[3][1] ) * w,
(_matrix[0][2] * pntIn[0] +
_matrix[1][2] * pntIn[1] +
_matrix[2][2] * pntIn[2] +
_matrix[3][2] ) * w );
}
}
示例7: euclideanDistanceCost
Real32 OctreeAStarAlgorithm::euclideanDistanceCost(Octree::OTNodePtr node,
const Pnt3f& Location,
Real32 CostPerUnit)
{
Pnt3f Target;
node->getVolume().getCenter(Target);
return CostPerUnit * Location.dist(Target);
}
示例8: intersect
bool FrustumVolume::intersect(const Pnt3f &point) const
{
bool retCode = true;
for(Int32 i = 0; i < 6; i++)
{
if((_planeVec[i].getNormal().x() * point.x() +
_planeVec[i].getNormal().y() * point.y() +
_planeVec[i].getNormal().z() * point.z() -
_planeVec[i].getDistanceFromOrigin() ) < 0.f)
{
retCode = false;
break;
}
}
return retCode;
}
示例9: vec2pnttest
void vec2pnttest(void)
{
Vec3f v (3.f, 3.f, 3.f);
const Vec3f cv(2.f, 2.f, 2.f);
Pnt3f p(5.f, 5.f, 5.f);
const Pnt3f cp(8.f, 8.f, 8.f);
v = p.subZero();
fprintf(stderr, "%f %f %f\n", v[0], v[1], v[2]);
v = cp.subZero();
fprintf(stderr, "%f %f %f\n", v[0], v[1], v[2]);
// p = v;
// p = cv;
}
示例10: manhattanDistanceCost
Real32 OctreeAStarAlgorithm::manhattanDistanceCost(Octree::OTNodePtr node,
const Pnt3f& Location,
Real32 CostPerUnit)
{
Pnt3f Target;
node->getVolume().getCenter(Target);
return CostPerUnit * (osgAbs(Location.x() - Target.x())
+ osgAbs(Location.y() - Target.y())
+ osgAbs(Location.z() - Target.z()));
}
示例11: randomOpenPosition
Pnt3f randomOpenPosition(const Pnt3f& Min,
const Pnt3f& Max,
OctreePtr TheOctree)
{
Pnt3f Result;
do
{
Result.setValues(RandomPoolManager::getRandomReal32(Min.x(),Max.x()),
RandomPoolManager::getRandomReal32(Min.y(),Max.y()),
RandomPoolManager::getRandomReal32(Min.z(),Max.z()));
}while(!TheOctree->getNodeThatContains(Result)->isEmpty());
return Result;
}
示例12: makeExplosion
void makeExplosion(Pnt3f Location, Real32 Impulse)
{
for(UInt32 i(0) ; i<allPhysicsBodies.size() ; ++i)
{
Vec3f Direction(allPhysicsBodies[i]->getPosition()-Location.subZero());
Real32 Distance(Direction.length());
Direction.normalize();
allPhysicsBodies[i]->addForce(physicsWorld->impulseToForce(physHandler->getStepSize(), Direction*Impulse*(1.0f/Distance)));
//The bodies need to be enabled because they may be auto-disabled when they
//come to rest
//The bodies are not re-enabled untill a new collision is detected
allPhysicsBodies[i]->setEnable(true);
}
}
示例13: age
bool RandomMovementParticleAffector::affect(ParticleSystemRefPtr System, Int32 ParticleIndex, const Time& elps)
{
//System->setUpdateSecAttribs(false);
Real32 x,
y,
z,
age(System->getAge(ParticleIndex));
if(getAttributeAffected() == VELOCITY_ATTRIBUTE)
{
Vec3f vel = System->getSecVelocity(ParticleIndex);
// grab each value independently , and adjust the phase for each
// axis, since we have a 3D phase and the 1D distribution only takes
// one value
Real32 velSum = vel.x() + vel.y() + vel.z();
getPerlinDistribution()->setPhase(getPhase().x() + velSum);
x = getPerlinDistribution()->generate(vel.x() + age);
getPerlinDistribution()->setPhase(getPhase().y() + velSum);
y = getPerlinDistribution()->generate(vel.y() + age);
getPerlinDistribution()->setPhase(getPhase().z() + velSum);
z = getPerlinDistribution()->generate(vel.z() + age);
System->setVelocity(Vec3f(x,y,z) + vel,ParticleIndex);
}else // affecting position
{
Pnt3f pos = System->getSecPosition(ParticleIndex);
Real32 posSum = pos.x() + pos.y() + pos.z();
getPerlinDistribution()->setPhase(getPhase().x() + posSum);
x = getPerlinDistribution()->generate(pos.x() + age);
getPerlinDistribution()->setPhase(getPhase().y() + posSum);
y = getPerlinDistribution()->generate(pos.y() + age);
getPerlinDistribution()->setPhase(getPhase().z() + posSum);
z = getPerlinDistribution()->generate(pos.z() + age);
System->setPosition(Pnt3f(x,y,z) + pos.subZero(),ParticleIndex);
}
return false;
}
示例14: originalGazePos
void C3DSLoader::Draw(Pnt3f pos0,Pnt3f pos1, Pnt3f orient, float scale)
{
Pnt3f originalGazePos(-pos0.x,-pos0.y,-pos0.z);
Pnt3f newGazePos(pos1.x-pos0.x,pos1.y-pos0.y,pos1.z-pos0.z);
originalGazePos.normalize();
newGazePos.normalize();
orient.normalize();
float productValue = originalGazePos.x * newGazePos.x + originalGazePos.y * newGazePos.y + originalGazePos.z * newGazePos.z;
float cosValue = productValue / 1;
float angle = acos(cosValue) * 180 / M_PI;
//glPushMatrix();
//glRotatef(angle, 0,1,0);
glPushAttrib(GL_CURRENT_BIT);
glDisable(GL_TEXTURE_2D);
for(int i = 0; i < m_3DModel.numOfObjects; i++)
{
if(m_3DModel.pObject.size() <= 0)
break;
t3DObject *pObject = &m_3DModel.pObject[i];
if(pObject->bHasTexture)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_textures[pObject->materialID]);
}
else
glDisable(GL_TEXTURE_2D);
glColor3ub(255, 255, 255);
glBegin(GL_TRIANGLES);
for(int j = 0; j < pObject->numOfFaces; j++)
{for(int tex = 0; tex < 3; tex++)
{
int index = pObject->pFaces[j].vertIndex[tex];
glNormal3f(pObject->pNormals[index].x,pObject->pNormals[index].y,
pObject->pNormals[index].z);
if(pObject->bHasTexture)
{
if(pObject->pTexVerts)
glTexCoord2f(pObject->pTexVerts[index].x,pObject->pTexVerts[index].y);
}
else
{
if(m_3DModel.pMaterials.size() && pObject->materialID>= 0)
{
BYTE *pColor = m_3DModel.pMaterials[pObject->materialID].color;
glColor3ub(pColor[0],pColor[1],pColor[2]);
}
}
//gluLookAt(pos0.x, pos0.y, pos0.z, pos1.x, pos1.y, pos1.z, 0, 1, 0);
glVertex3f(pObject->pVerts[index].x + pos0.x, pObject->pVerts[index].y + pos0.y, pObject->pVerts[index].z + pos0.z);
}
}
glEnd();
}
glEnable(GL_TEXTURE_2D);
glPopAttrib();
//glPopMatrix();
}
示例15: getPositions
void SkeletonBlendedGeometry::calculatePositions(void)
{
if(getBaseGeometry() == NULL)
{
//Error
SWARNING << "SkeletonBlendedGeometry::calculatePositions(): Base Geometry is NULL." << std::endl;
return;
if(getPositions() == NULL)
{
//Error
SWARNING << "SkeletonBlendedGeometry::calculatePositions(): Positions is NULL." << std::endl;
return;
}
if(getBaseGeometry()->getPositions() == NULL)
{
//Error
SWARNING << "SkeletonBlendedGeometry::calculatePositions(): Base Geometry Postions is NULL." << std::endl;
return;
}
if(getMFPositionIndexes()->size() != getMFJoints()->size())
{
//Error
SWARNING << "SkeletonBlendedGeometry::calculatePositions(): Positions Indexes size is not the same as the affecting Joints size." << std::endl;
return;
}
}
if(getMFPositionIndexes()->size() != getMFBlendAmounts()->size())
{
//Error
SWARNING << "SkeletonBlendedGeometry::calculatePositions(): Positions Indexes size is not the same as the affecting blend amount size." << std::endl;
return;
}
Pnt3f CalculatedPoint;
Pnt3f PointTemp;
Vec3f CalculatedNormal;
//Set the values of all points to 0
for (int i(0); i < getPositions()->size(); ++i)
{
getPositions()->setValue(Pnt3f(0, 0, 0), i);
}
//Update the Positions and Normals
for(UInt32 i(0) ; i < getMFPositionIndexes()->size() ; ++i)
{
Matrix temp = getJoints(i)->getAbsoluteDifferenceTransformation();
temp.scale(getBlendAmounts(i));
getBaseGeometry()->getPositions()->getValue<Pnt3f>(PointTemp, getPositionIndexes(i));
temp.mult(PointTemp, CalculatedPoint);
//temp.mult(getBaseGeometry()->getNormals()->getValue(getPositionIndexes(i)), CalculatedNormal);
//Add
CalculatedPoint += PointTemp.subZero();
getPositions()->setValue<Pnt3f>(CalculatedPoint, getPositionIndexes(i));
}
for(UInt32 i = 0; i < _mfParents.size(); i++)
{
_mfParents[i]->invalidateVolume();
}
_volumeCache.setValid();
_volumeCache.setEmpty();
}