コード例 #1
0
ファイル: NXU_ScaledCopy.cpp プロジェクト: xDusk/lostisland04
  void copyTriangleMeshScaled(NxTriangleMeshDesc *dest, NxTriangleMeshDesc *source, const NxVec3 &scale, NxPhysicsSDK *sdk, const char *sourceId, const char *destId)
  {
    if(source->mCookedData.empty())
    {
      dest->mId             = source->mId;
      dest->mUserProperties = source->mUserProperties;
      dest->convexEdgeThreshold = source->convexEdgeThreshold;
      dest->flags = source->flags;
      dest->heightFieldVerticalAxis = source->heightFieldVerticalAxis;
      dest->heightFieldVerticalExtent = source->heightFieldVerticalExtent;
      dest->mMaterialIndices = source->mMaterialIndices;
      dest->mPmapData = 0;
      dest->mPmapDensity = 0; // scaled pmaps are not supported.
      dest->mPmapSize = 0;
      dest->mInstance = 0;

      for(unsigned int i = 0; i < source->mPoints.size(); i++)
      {
        NxVec3 v = source->mPoints[i];
        v.x *= scale.x;
        v.y *= scale.y;
        v.z *= scale.z;
        dest->mPoints.push_back(v);
      }

      dest->mTriangles = source->mTriangles;
      dest->flags      = source->flags;
      dest->mCookedDataSize = 0;
    }
    else
    {
      if(sdk)
      {
        if(source->mInstance == 0)
        {
          NxuPhysicsInstantiator ip;
          CustomCopy cc(0, 0);
          source->mInstance = ip.instantiateTriangleMesh(*sdk, *source, sourceId, 0, cc);
        }

        if(source->mInstance)    // now we have to export just this one item..
        {
          NxuPhysicsExport pe;
          bool saveCooked = gCookOnExport;
          gCookOnExport = false;
          pe.exportTriangleMesh((NxTriangleMesh *)source->mInstance, source->mUserProperties, source->mId, *dest);
          scalePoints(*dest, scale);
          createCookedData(*dest);
          clearNonCooked(*dest);
          gCookOnExport = saveCooked;
        }
      }
      else
      {
        assert(0); // to be done...
      }
    }
  }
コード例 #2
0
ファイル: NXU_ScaledCopy.cpp プロジェクト: xDusk/lostisland04
  void copyConvexMeshScaled(NxConvexMeshDesc *dest, NxConvexMeshDesc *source, const NxVec3 &scale, NxPhysicsSDK *sdk, const char *sourceId, const char *destId)
  {
    if(source->mCookedData.empty())
    {
      dest->mId             = source->mId;
      dest->mUserProperties = source->mUserProperties;

      for(unsigned int i = 0; i < source->mPoints.size(); i++)
      {
        NxVec3 v = source->mPoints[i];
        v.x *= scale.x;
        v.y *= scale.y;
        v.z *= scale.z;
        dest->mPoints.push_back(v);
      }

      dest->mTriangles = source->mTriangles;
      dest->flags      = source->flags;
      dest->mCookedDataSize = 0;
    }
    else
    {
      if(sdk)
      {
        if(source->mInstance == 0)
        {
          NxuPhysicsInstantiator ip;
          CustomCopy cc(0, 0);
          source->mInstance = ip.instantiateConvexMesh(*sdk, *source, sourceId, 0, cc);
        }

        if(source->mInstance)    // now we have to export just this one item..
        {
          NxuPhysicsExport pe;
          bool saveCooked = gCookOnExport;
          gCookOnExport = false;
          pe.exportConvexMesh((NxConvexMesh *)source->mInstance, source->mUserProperties, source->mId, *dest);
          scalePoints(*dest, scale);
          createCookedData(*dest);
          clearNonCooked(*dest);
          gCookOnExport = saveCooked;
        }
      }
      else
      {
        assert(0); // to be done...
      }
    }
  }
コード例 #3
0
void ofxOpticalFlow::scalePointsToScreen(){
	float scaleX = (float)ofGetWidth() / (float)width;
	float scaleY = (float)ofGetHeight() / (float)height;
	scalePoints(scaleX, scaleY);
}