本文整理汇总了C++中Sphere::getTranslation方法的典型用法代码示例。如果您正苦于以下问题:C++ Sphere::getTranslation方法的具体用法?C++ Sphere::getTranslation怎么用?C++ Sphere::getTranslation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sphere
的用法示例。
在下文中一共展示了Sphere::getTranslation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: matMulVec
void computeBV<AABB>(const Sphere& s, AABB& bv)
{
Vec3f T = matMulVec(s.getRotation(), s.getLocalTranslation()) + s.getTranslation();
bv.max_ = T + Vec3f(s.radius, s.radius, s.radius);
bv.min_ = T + Vec3f(-s.radius, -s.radius, -s.radius);
}
示例2: GraphicsCallback
//
// The Graphics Callback runs in the application "client thread" (qhStart) and sets the transformations
// for the Red Sphere and Green Line of the Cursor. Also, this callback sets the WorldToDevice matrix
// for use in the ServoLoopCallback.
//
void GraphicsCallback(void)
{
QHGLUT* localDisplayObject = QHGLUT::searchWindow("Coulomb Field Demo");//Get a Pointer to the display object
Cursor* localDeviceCursor = Cursor::searchCursor("devCursor");//Get a pointer to the cursor
Cylinder* localForceArrow = Cylinder::searchCylinder("forceArrow");//get a pointer to the cylinder
Cone* localForceArrowTip = Cone::searchCone("forceArrowTip");//get a pointer to the cylinder
Sphere* localCursorSphere = Sphere::searchSphere("cursorSphere");//get a pointer top the Sphere
if( localDisplayObject == NULL || localDeviceCursor == NULL || localForceArrow == NULL || localCursorSphere == NULL)
return;
hduMatrix CylinderTransform;//Transformation for the Cylinder. This transform makes it point toward the Model
hduVector3Dd localCursorPosition;
hduVector3Dd DirectionVecX;
hduVector3Dd PointOnPlane;
hduVector3Dd DirectionVecY;
hduVector3Dd DirectionVecZ;
//Compute the world to device transform
WorldToDevice = localDisplayObject->getWorldToDeviceTransform();
// Set transform for Red Sphere
localCursorPosition = localDeviceCursor->getPosition();//Get the local cursor position in World Space
hduVector3Dd localCursorSpherePos = localCursorSphere->getTranslation();
localCursorSphere->setTranslation(-localCursorSpherePos);
localCursorSphere->setTranslation(localCursorPosition);//Set the position of the Sphere the same as the cursor
////////////////////////////////////////////////////////////////////////////////////////////
//Code to calculate the transform of the green cylinder to point along the force direction
////////////////////////////////////////////////////////////////////////////////////////////
hduMatrix DeviceToWorld = WorldToDevice.getInverse();
HDdouble ForceMagnitude = forceVec.magnitude();
DeviceToWorld[3][0] = 0.0;
DeviceToWorld[3][1] = 0.0;
DeviceToWorld[3][2] = 0.0;
DirectionVecX = forceVec * DeviceToWorld;
DirectionVecX.normalize();
PointOnPlane.set(0.0,0.0,(DirectionVecX[0]*localCursorPosition[0] + DirectionVecX[1]*localCursorPosition[1] + DirectionVecX[2]*localCursorPosition[2])/DirectionVecX[2]);
DirectionVecY = PointOnPlane - localCursorPosition;
DirectionVecY.normalize();
DirectionVecZ = -DirectionVecY.crossProduct(DirectionVecX);
CylinderTransform[0][0] = DirectionVecZ[0]; CylinderTransform[0][1] = DirectionVecZ[1]; CylinderTransform[0][2] = DirectionVecZ[2]; CylinderTransform[0][3] = 0.0;
CylinderTransform[1][0] = DirectionVecX[0]; CylinderTransform[1][1] = DirectionVecX[1]; CylinderTransform[1][2] = DirectionVecX[2]; CylinderTransform[1][3] = 0.0;
CylinderTransform[2][0] = DirectionVecY[0]; CylinderTransform[2][1] = DirectionVecY[1]; CylinderTransform[2][2] = DirectionVecY[2]; CylinderTransform[2][3] = 0.0;
CylinderTransform[3][0] = 0.0 ; CylinderTransform[3][1] = 0.0 ; CylinderTransform[3][2] = 0.0 ; CylinderTransform[3][3] = 1.0;
CylinderTransform = CylinderTransform * hduMatrix::createTranslation(localCursorPosition[0], localCursorPosition[1], localCursorPosition[2]);
localForceArrow->update(chargeRadius/4, ForceMagnitude*50, 15);
localForceArrow->setTranslation(localCursorPosition);
localForceArrow->setTransform(CylinderTransform);
hduMatrix ConeTransform = CylinderTransform * hduMatrix::createTranslation(DirectionVecX[0]
* ForceMagnitude*50,DirectionVecX[1] * ForceMagnitude*50,DirectionVecX[2] * ForceMagnitude*50 );
localForceArrowTip->setTransform(ConeTransform);
/////////////////////////////////////////////
}