本文整理汇总了C++中Point3F::normalizeSafe方法的典型用法代码示例。如果您正苦于以下问题:C++ Point3F::normalizeSafe方法的具体用法?C++ Point3F::normalizeSafe怎么用?C++ Point3F::normalizeSafe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point3F
的用法示例。
在下文中一共展示了Point3F::normalizeSafe方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initNormalize
void GFXCubemap::initNormalize( U32 size )
{
Point3F axis[6] =
{Point3F(1.0, 0.0, 0.0), Point3F(-1.0, 0.0, 0.0),
Point3F(0.0, 1.0, 0.0), Point3F( 0.0, -1.0, 0.0),
Point3F(0.0, 0.0, 1.0), Point3F( 0.0, 0.0, -1.0),};
Point3F s[6] =
{Point3F(0.0, 0.0, -1.0), Point3F( 0.0, 0.0, 1.0),
Point3F(1.0, 0.0, 0.0), Point3F( 1.0, 0.0, 0.0),
Point3F(1.0, 0.0, 0.0), Point3F(-1.0, 0.0, 0.0),};
Point3F t[6] =
{Point3F(0.0, -1.0, 0.0), Point3F(0.0, -1.0, 0.0),
Point3F(0.0, 0.0, 1.0), Point3F(0.0, 0.0, -1.0),
Point3F(0.0, -1.0, 0.0), Point3F(0.0, -1.0, 0.0),};
F32 span = 2.0;
F32 start = -1.0;
F32 stride = span / F32(size - 1);
GFXTexHandle faces[6];
for(U32 i=0; i<6; i++)
{
GFXTexHandle &tex = faces[i];
GBitmap *bitmap = new GBitmap(size, size);
// fill in...
for(U32 v=0; v<size; v++)
{
for(U32 u=0; u<size; u++)
{
Point3F vector;
vector = axis[i] +
((F32(u) * stride) + start) * s[i] +
((F32(v) * stride) + start) * t[i];
vector.normalizeSafe();
vector = ((vector * 0.5) + Point3F(0.5, 0.5, 0.5)) * 255.0;
vector.x = mClampF(vector.x, 0.0f, 255.0f);
vector.y = mClampF(vector.y, 0.0f, 255.0f);
vector.z = mClampF(vector.z, 0.0f, 255.0f);
// easy way to avoid knowledge of the format (RGB, RGBA, RGBX, ...)...
U8 *bits = bitmap->getAddress(u, v);
bits[0] = U8(vector.x);
bits[1] = U8(vector.y);
bits[2] = U8(vector.z);
}
}
tex.set(bitmap, &GFXDefaultStaticDiffuseProfile, true, "Cubemap");
}
initStatic(faces);
}
示例2: onMouseMove
void GameTSCtrl::onMouseMove(const GuiEvent &evt)
{
if(gSnapLine)
return;
MatrixF mat;
Point3F vel;
if ( GameGetCameraTransform(&mat, &vel) )
{
Point3F pos;
mat.getColumn(3,&pos);
Point3F screenPoint((F32)evt.mousePoint.x, (F32)evt.mousePoint.y, 1.0f);
Point3F worldPoint;
if (unproject(screenPoint, &worldPoint))
{
Point3F vec = worldPoint - pos;
lineTestStart = pos;
vec.normalizeSafe();
lineTestEnd = pos + vec * 500;
static U32 losMask = VehicleObjectType | StaticShapeObjectType;
RayInfo ri;
bool hit = gClientContainer.castRay( lineTestStart, lineTestEnd, losMask, &ri);
if (!hit)
{
//Con::printf("no hit!");
if (mCursorObject != NULL)
mCursorObject->setHighlighted(false);
mCursorObject = NULL;
}
else
{
if (ri.object != mCursorObject && mCursorObject != NULL)
mCursorObject->setHighlighted(false);
mCursorObject = (ShapeBase*)ri.object;
mCursorObject->setHighlighted(true);
}
}
}
}
示例3: onMouseMove
void GameTSCtrl::onMouseMove(const GuiEvent &evt)
{
if(gSnapLine)
return;
MatrixF mat;
Point3F vel;
if ( GameGetCameraTransform(&mat, &vel) )
{
Point3F pos;
mat.getColumn(3,&pos);
Point3F screenPoint((F32)evt.mousePoint.x, (F32)evt.mousePoint.y, -1.0f);
Point3F worldPoint;
if (unproject(screenPoint, &worldPoint)) {
Point3F vec = worldPoint - pos;
lineTestStart = pos;
vec.normalizeSafe();
lineTestEnd = pos + vec * 1000;
}
}
}
示例4: makeScriptCall
//---------------------------------------------------------------------------
void GameTSCtrl::makeScriptCall(const char *func, const GuiEvent &evt) const
{
// write screen position
char *sp = Con::getArgBuffer(32);
dSprintf(sp, 32, "%d %d", evt.mousePoint.x, evt.mousePoint.y);
// write world position
char *wp = Con::getArgBuffer(32);
Point3F camPos;
mLastCameraQuery.cameraMatrix.getColumn(3, &camPos);
dSprintf(wp, 32, "%g %g %g", camPos.x, camPos.y, camPos.z);
// write click vector
char *vec = Con::getArgBuffer(32);
Point3F fp(evt.mousePoint.x, evt.mousePoint.y, 1.0);
Point3F ray;
unproject(fp, &ray);
ray -= camPos;
ray.normalizeSafe();
dSprintf(vec, 32, "%g %g %g", ray.x, ray.y, ray.z);
Con::executef( (SimObject*)this, func, sp, wp, vec );
}
示例5: _generateEdges
void DecalRoad::_generateEdges()
{
PROFILE_SCOPE( DecalRoad_generateEdges );
//Con::warnf( "%s - generateEdges", isServerObject() ? "server" : "client" );
if ( mNodes.size() > 0 )
{
// Set our object position to the first node.
const Point3F &nodePt = mNodes.first().point;
MatrixF mat( true );
mat.setPosition( nodePt );
Parent::setTransform( mat );
// The server object has global bounds, which Parent::setTransform
// messes up so we must reset it.
if ( isServerObject() )
{
mObjBox.minExtents.set(-1e10, -1e10, -1e10);
mObjBox.maxExtents.set( 1e10, 1e10, 1e10);
}
}
if ( mNodes.size() < 2 )
return;
// Ensure nodes are above the terrain height at their xy position
for ( U32 i = 0; i < mNodes.size(); i++ )
{
_getTerrainHeight( mNodes[i].point );
}
// Now start generating edges...
U32 nodeCount = mNodes.size();
Point3F *positions = new Point3F[nodeCount];
for ( U32 i = 0; i < nodeCount; i++ )
{
const RoadNode &node = mNodes[i];
positions[i].set( node.point.x, node.point.y, node.width );
}
CatmullRom<Point3F> spline;
spline.initialize( nodeCount, positions );
delete [] positions;
mEdges.clear();
Point3F lastBreakVector(0,0,0);
RoadEdge slice;
Point3F lastBreakNode;
lastBreakNode = spline.evaluate(0.0f);
for ( U32 i = 1; i < mNodes.size(); i++ )
{
F32 t1 = spline.getTime(i);
F32 t0 = spline.getTime(i-1);
F32 segLength = spline.arcLength( t0, t1 );
U32 numSegments = mCeil( segLength / MIN_METERS_PER_SEGMENT );
numSegments = getMax( numSegments, (U32)1 );
F32 tstep = ( t1 - t0 ) / numSegments;
U32 startIdx = 0;
U32 endIdx = ( i == nodeCount - 1 ) ? numSegments + 1 : numSegments;
for ( U32 j = startIdx; j < endIdx; j++ )
{
F32 t = t0 + tstep * j;
Point3F splineNode = spline.evaluate(t);
F32 width = splineNode.z;
_getTerrainHeight( splineNode );
Point3F toNodeVec = splineNode - lastBreakNode;
toNodeVec.normalizeSafe();
if ( lastBreakVector.isZero() )
lastBreakVector = toNodeVec;
F32 angle = mRadToDeg( mAcos( mDot( toNodeVec, lastBreakVector ) ) );
if ( j == startIdx ||
( j == endIdx - 1 && i == mNodes.size() - 1 ) ||
angle > mBreakAngle )
{
// Push back a spline node
//slice.p1.set( splineNode.x, splineNode.y, 0.0f );
//_getTerrainHeight( slice.p1 );
slice.p1 = splineNode;
slice.uvec.set(0,0,1);
slice.width = width;
slice.parentNodeIdx = i-1;
mEdges.push_back( slice );
lastBreakVector = splineNode - lastBreakNode;
lastBreakVector.normalizeSafe();
//.........这里部分代码省略.........