当前位置: 首页>>代码示例>>C++>>正文


C++ Point2F类代码示例

本文整理汇总了C++中Point2F的典型用法代码示例。如果您正苦于以下问题:C++ Point2F类的具体用法?C++ Point2F怎么用?C++ Point2F使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Point2F类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: originShadow4F

// This "rounds" the projection matrix to remove subtexel movement during shadow map
// rasterization.  This is here to reduce shadow shimmering.
void PSSMLightShadowMap::_roundProjection(const MatrixF& lightMat, const MatrixF& cropMatrix, Point3F &offset, U32 splitNum)
{
   // Round to the nearest shadowmap texel, this helps reduce shimmering
   MatrixF currentProj = GFX->getProjectionMatrix();
   currentProj = cropMatrix * currentProj * lightMat;

   // Project origin to screen.
   Point4F originShadow4F(0,0,0,1);
   currentProj.mul(originShadow4F);
   Point2F originShadow(originShadow4F.x / originShadow4F.w, originShadow4F.y / originShadow4F.w);   

   // Convert to texture space (0..shadowMapSize)
   F32 t = mNumSplits < 4 ? mShadowMapTex->getWidth() / mNumSplits : mShadowMapTex->getWidth() / 2;
   Point2F texelsToTexture(t / 2.0f, mShadowMapTex->getHeight() / 2.0f);
   if (mNumSplits >= 4) texelsToTexture.y *= 0.5f;
   originShadow.convolve(texelsToTexture);

   // Clamp to texel boundary
   Point2F originRounded;
   originRounded.x = mFloor(originShadow.x + 0.5f);
   originRounded.y = mFloor(originShadow.y + 0.5f);

   // Subtract origin to get an offset to recenter everything on texel boundaries
   originRounded -= originShadow;

   // Convert back to texels (0..1) and offset
   originRounded.convolveInverse(texelsToTexture);
   offset.x += originRounded.x;
   offset.y += originRounded.y;
}
开发者ID:1414648814,项目名称:Torque3D,代码行数:32,代码来源:pssmLightShadowMap.cpp

示例2: convertGradientRangeFromDegrees

void afxZodiacData::convertGradientRangeFromDegrees(Point2F& gradrange, const Point2F& gradrange_deg)
{
  F32 x = mCos(mDegToRad(gradrange_deg.x));
  F32 y = mCos(mDegToRad(gradrange_deg.y));
  if (y > x)
    gradrange.set(x, y);
  else
    gradrange.set(y, x);
}
开发者ID:nev7n,项目名称:Torque3D,代码行数:9,代码来源:afxZodiac.cpp

示例3: CalculateDrag

Point2F Mover::CalculateDrag(float dragMag)
{
	//F drag=-v*v*dragMag
	Point2F drag = -mVelocity;
	drag.Normalize();

	drag *= dragMag;
	drag *= mVelocity.LengthSquared();
	return drag;
}
开发者ID:fjz13,项目名称:Medusa,代码行数:10,代码来源:Mover.cpp

示例4: CalculateAttract

Point2F Mover::CalculateAttract(const Mover& other, float g, float minDistanceSquared/*=1.f*/)
{
	//F=G*m1*m2/(r*r)
	Point2F force = mPosition - other.mPosition;
	float distanceSquared =Math::Max(force.LengthSquared(),minDistanceSquared);

	force.Normalize();
	force *= g*mMass*other.mMass;
	force /= distanceSquared;
	return force;
}
开发者ID:fjz13,项目名称:Medusa,代码行数:11,代码来源:Mover.cpp

示例5: CalculateFriction

Point2F Mover::CalculateFriction(float frictionMag, const Point2F& gravity)
{
	//Friction=-frictionMag*N*v
	//v==mVelocity.Normalize()

	Point2F friction = -mVelocity;
	friction.Normalize();

	friction *= frictionMag;
	friction *= mMass*gravity;
	return friction;
}
开发者ID:fjz13,项目名称:Medusa,代码行数:12,代码来源:Mover.cpp

示例6: dir

//=============================================================================
Point2F Rectangle2::center() const
{
    Point2F result;

    Vector2F dir2 = dir();
    dir2.multiply(0.5);
    result.add(dir2);

    Vector2F up2 = up();
    up2.multiply(0.5);
    result.add(up2);

    return result;
}
开发者ID:ta2la,项目名称:geogebra,代码行数:15,代码来源:T2lRectangle2.cpp

示例7: TEST

TEST(Point2, SetMethods) {
    Point2F pt;
    pt.set(4.f, 2.f);
    EXPECT_FLOAT_EQ(4.f, pt.x);
    EXPECT_FLOAT_EQ(2.f, pt.y);

    auto lst = {0.f, 5.f};
    pt.set(lst);
    EXPECT_FLOAT_EQ(0.f, pt.x);
    EXPECT_FLOAT_EQ(5.f, pt.y);

    pt.set(Point2F(9.f, 8.f));
    EXPECT_FLOAT_EQ(9.f, pt.x);
    EXPECT_FLOAT_EQ(8.f, pt.y);
}
开发者ID:doyubkim,项目名称:fluid-engine-dev,代码行数:15,代码来源:point2_tests.cpp

示例8: toLUV

ColorF toLUV( const ColorF &rgbColor )
{
   static const Point3F scXYZLUVDot( 1.0f, 15.0f, 3.0f );
   static const Point2F sc49( 4.0f, 9.0f );

   ColorF xyzColor = ConvertRGB::toXYZ( rgbColor );

   const Point2F &xyz_xy = *((Point2F *)&xyzColor);

   Point2F uvColor = sc49;
   uvColor.convolve( xyz_xy );
   uvColor /= mDot( *(Point3F *)&xyzColor, scXYZLUVDot );

   return ColorF( uvColor.x, uvColor.y, xyzColor.green, rgbColor.alpha );
}
开发者ID:adhistac,项目名称:ee-client-2-0,代码行数:15,代码来源:rgb2luv.cpp

示例9:

//=============================================================================
Point2F Ray2::getPoint(double parameter, double offset) const
{
    Vector2F delta = dir_;
    delta.multiply(parameter);
    Point2F result =  origin_;
    result.add(delta);

    if (offset == 0.0) return result;

    Vector2F offsetVec = dir_;
    offsetVec.setPerpendLeft();
    offsetVec.multiply( offset/offsetVec.getLength() );
    result.add(offsetVec);

    return result;
}
开发者ID:ta2la,项目名称:geogebra,代码行数:17,代码来源:T2lRay2.cpp

示例10: calculateHandAxisRotation

void calculateHandAxisRotation(const MatrixF& handRotation, const F32& maxHandAxisRadius, Point2F& outRotation)
{
   const VectorF& controllerUp = handRotation.getUpVector();
   outRotation.x = controllerUp.x;
   outRotation.y = controllerUp.y;

   // Limit the axis angle to that given to us
   if(outRotation.len() > maxHandAxisRadius)
   {
      outRotation.normalize(maxHandAxisRadius);
   }

   // Renormalize to the range of 0..1
   if(maxHandAxisRadius != 0.0f)
   {
      outRotation /= maxHandAxisRadius;
   }
}
开发者ID:03050903,项目名称:Torque3D,代码行数:18,代码来源:leapMotionUtil.cpp

示例11: Point2F

void MaterialEditor::onMouseMoveEvent(const GuiEvent &event)
{
   lastMousePoint = event.mousePoint;

   for(S32 n = 0; n < nodeList.size(); ++n )
   {
      Node* node = &nodeList[n];
      node->mouseOver = false;

      if ( event.mousePoint.x >= node->x && event.mousePoint.x <= node->x + node->width
         && event.mousePoint.y >= node->y && event.mousePoint.y <= node->y + node->height )
      {
         node->mouseOver = true;

         for ( S32 i = 0; i < node->inputs.size(); ++i )
         {
            InputPoint* input = &node->inputs[i];
            input->mouseOver = false;

            Point2F dist = input->lastPosition - Point2F(lastMousePoint.x, lastMousePoint.y);
            if (  dist.len() <= 5 )
               input->mouseOver = true;
         }

         for ( S32 i = 0; i < node->outputs.size(); ++i )
         {
            OutputPoint* output = &node->outputs[i];
            output->mouseOver = false;

            Point2F dist = output->lastPosition - Point2F(lastMousePoint.x, lastMousePoint.y);
            if (  dist.len() <= 5 )
               output->mouseOver = true;
         }
      }
   }
}
开发者ID:hreikin,项目名称:Torque6,代码行数:36,代码来源:MaterialEditor.cpp

示例12: while

//=============================================================================
Point2F Rectangle2::point(int index) const
{
    while ( index < 0 ) index += 4;
    while ( index > 3 ) index -= 4;

    Point2F result = origin_;

    switch (index)
    {
    case 1:
        result.add(width_);
        break;
    case 2:
        result.add(width_);
    case 3:
        result.add(up_());
        break;
    case 0:
    default:
        break;
    }

    return result;
}
开发者ID:ta2la,项目名称:geogebra,代码行数:25,代码来源:T2lRectangle2.cpp

示例13: findNode

void MaterialEditor::renderConnection(Connection* connection)
{
   NVGcontext* vg = Link.Graphics.dglGetNVGContext();
	if (vg)
	{
      Point2F mStart;
      Point2F mEnd;

      if ( connection->outputToMouse )
         mEnd.set(lastMousePoint.x, lastMousePoint.y);
      else {
         Node* endNode = findNode(connection->inputNodeName);
         if ( !endNode || connection->inputIndex >= endNode->inputs.size() ) 
            return;
         mEnd.set(endNode->inputs[connection->inputIndex].lastPosition.x, endNode->inputs[connection->inputIndex].lastPosition.y);
      }

      if ( connection->inputToMouse )
         mStart.set(lastMousePoint.x, lastMousePoint.y);
      else {
         Node* startNode = findNode(connection->outputNodeName);
         if ( !startNode || connection->outputIndex >= startNode->outputs.size() ) 
            return;
         mStart.set(startNode->outputs[connection->outputIndex].lastPosition.x, startNode->outputs[connection->outputIndex].lastPosition.y);
      }

      Point2F mControlPointA(mStart.x + 50, mStart.y);
      Point2F mControlPointB(mEnd.x - 50, mEnd.y);

      F32 diff = (mEnd.y - mStart.y) * 0.25f;
      mControlPointA.y -= diff;
      mControlPointB.y += diff;

		Link.NanoVG.nvgBeginPath(vg);
		Link.NanoVG.nvgMoveTo(vg, mStart.x, mStart.y);
		Link.NanoVG.nvgBezierTo(vg, mControlPointA.x, mControlPointA.y, 
                                  mControlPointB.x, mControlPointB.y, 
                                  mEnd.x, mEnd.y);
		Link.NanoVG.nvgStrokeColor(vg, Link.NanoVG.nvgRGBA(255, 255, 255, 200));
		Link.NanoVG.nvgStrokeWidth(vg, 5.0f);
		Link.NanoVG.nvgStroke(vg);
   }
}
开发者ID:hreikin,项目名称:Torque6,代码行数:43,代码来源:MaterialEditor.cpp

示例14: PROFILE_SCOPE

void PSSMLightShadowMap::setShaderParameters(GFXShaderConstBuffer* params, LightingShaderConstants* lsc)
{
   PROFILE_SCOPE( PSSMLightShadowMap_setShaderParameters );

   AssertFatal(mNumSplits > 0 && mNumSplits <= MAX_SPLITS,
      avar("PSSMLightShadowMap::_setNumSplits() - Splits must be between 1 and %d!", MAX_SPLITS));

   if ( lsc->mTapRotationTexSC->isValid() )
      GFX->setTexture( lsc->mTapRotationTexSC->getSamplerRegister(), 
                        SHADOWMGR->getTapRotationTex() );

   const ShadowMapParams *p = mLight->getExtended<ShadowMapParams>();

   Point4F  sx(Point4F::Zero), 
            sy(Point4F::Zero),
            ox(Point4F::Zero), 
            oy(Point4F::Zero), 
            aXOff(Point4F::Zero), 
            aYOff(Point4F::Zero);

   for (U32 i = 0; i < mNumSplits; i++)
   {
      sx[i] = mScaleProj[i].x;
      sy[i] = mScaleProj[i].y;
      ox[i] = mOffsetProj[i].x;
      oy[i] = mOffsetProj[i].y;
   }

   Point2F shadowMapAtlas;
   if (mNumSplits < 4)
   {
      shadowMapAtlas.x = 1.0f / (F32)mNumSplits;
      shadowMapAtlas.y = 1.0f;
   
      // 1xmNumSplits
      for (U32 i = 0; i < mNumSplits; i++)
         aXOff[i] = (F32)i * shadowMapAtlas.x;
   }
   else
   {
      shadowMapAtlas.set(0.5f, 0.5f);
  
      // 2x2
      for (U32 i = 0; i < mNumSplits; i++)
      {
         if (i == 1 || i == 3)
            aXOff[i] = 0.5f;
         if (i > 1)
            aYOff[i] = 0.5f;
      }
   }

   params->setSafe(lsc->mScaleXSC, sx);
   params->setSafe(lsc->mScaleYSC, sy);
   params->setSafe(lsc->mOffsetXSC, ox);
   params->setSafe(lsc->mOffsetYSC, oy);
   params->setSafe(lsc->mAtlasXOffsetSC, aXOff);
   params->setSafe(lsc->mAtlasYOffsetSC, aYOff);
   params->setSafe(lsc->mAtlasScaleSC, shadowMapAtlas);

   Point4F lightParams( mLight->getRange().x, p->overDarkFactor.x, 0.0f, 0.0f );
   params->setSafe( lsc->mLightParamsSC, lightParams );
      
   params->setSafe( lsc->mFarPlaneScalePSSM, mFarPlaneScalePSSM);

   Point2F fadeStartLength(p->fadeStartDist, 0.0f);
   if (fadeStartLength.x == 0.0f)
   {
      // By default, lets fade the last half of the last split.
      fadeStartLength.x = (mSplitDist[mNumSplits-1] + mSplitDist[mNumSplits]) / 2.0f;
   }
   fadeStartLength.y = 1.0f / (mSplitDist[mNumSplits] - fadeStartLength.x);
   params->setSafe( lsc->mFadeStartLength, fadeStartLength);
   
   params->setSafe( lsc->mOverDarkFactorPSSM, p->overDarkFactor);

   // The softness is a factor of the texel size.
   params->setSafe( lsc->mShadowSoftnessConst, p->shadowSoftness * ( 1.0f / mTexSize ) );
}
开发者ID:1414648814,项目名称:Torque3D,代码行数:79,代码来源:pssmLightShadowMap.cpp

示例15: WritePoint

 void PathSerializer::WritePoint(const Point2F& point) {
     result << point.GetX() << ' ' << point.GetY() << ' ';
 }
开发者ID:maxtyutmanov,项目名称:imtrcr,代码行数:3,代码来源:PathSerializer.cpp


注:本文中的Point2F类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。