コード例 #1
0
ファイル: VPathNode.cpp プロジェクト: AnteSim/Verve
bool VPathNode::fromString( const String &pString )
{
    // Split Data.
    // {Position} {Rotation} {Weight}
    const char *baseData = StringUnit::getUnit( pString.c_str(), 0, "\t" );

    Point3F  pos;
    AngAxisF aa;
    F32      weight;

    // Scan Base.
    dSscanf( baseData, "%g %g %g %g %g %g %g %g", &pos.x, &pos.y, &pos.z,
                                                  &aa.axis.x, &aa.axis.y, &aa.axis.z, &aa.angle,
                                                  &weight );

    // Apply Changes.
    setLocalPosition( pos );
    setLocalRotation( QuatF( aa ) );
    setWeight( weight );

    // Fetch Orientation Data.
    String orientationData = StringUnit::getUnit( pString.c_str(), 1, "\t" );

    // Fetch Orientation Type.
    String orientationTypeString = orientationData;
    if ( orientationData.find( " " ) )
    {
        // Use First Word.
        orientationTypeString = orientationData.substr( 0, orientationData.find( " " ) );
    }

    // Set Orientation Type.
    const eOrientationType &orientationType = getOrientationTypeEnum( orientationTypeString.c_str() );
    switch( orientationType )
    {
        case k_OrientationFree : 
            {
                // Apply Mode.
                setOrientationMode( orientationType );

            } break;

        case k_OrientationToPoint:
            {
                // Fetch Point.
                Point3F lookAtPoint;
                // Buffer String.
                dSscanf( orientationData.c_str(), "%*s %f %f %f", &lookAtPoint.x, &lookAtPoint.y, &lookAtPoint.z );

                // Apply Mode.
                setOrientationMode( orientationType, lookAtPoint );

            } break;
    }

    return true;
}
コード例 #2
0
ファイル: propertyParsing.cpp プロジェクト: nev7n/Torque3D
 //-----------------------------------------------------------------------------
 // Colors
 //-----------------------------------------------------------------------------
 bool default_scan(const String &data, LinearColorF & result)
 {
    if(StringUnit::getUnitCount(data," ") == 3)
    {
       dSscanf(data.c_str(),"%g %g %g",&result.red,&result.green,&result.blue);
       result.alpha = 1.0f;
    }
    else
       dSscanf(data.c_str(),"%g %g %g %g",&result.red,&result.green,&result.blue,&result.alpha);
    return true;
 }
コード例 #3
0
ファイル: propertyParsing.cpp プロジェクト: nev7n/Torque3D
 bool default_scan(const String &data, Point2I & result)
 {
    // Handle passed as floating point from script
    if(data.find('.') != String::NPos)
    {
       Point2F tempResult;
       dSscanf(data.c_str(),"%f %f",&tempResult.x,&tempResult.y);
       result.x = mFloor(tempResult.x);
       result.y = mFloor(tempResult.y);
    }
    else
       dSscanf(data.c_str(),"%d %d",&result.x,&result.y);
    return true;
 }
コード例 #4
0
ファイル: convexShape.cpp プロジェクト: fr1tz/alux3d
bool ConvexShape::protectedSetSurface( void *object, const char *index, const char *data )
{
   ConvexShape *shape = static_cast< ConvexShape* >( object );

   QuatF quat;
	Point3F pos;
	//MatrixF mat;

	/*
   dSscanf( data, "%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g", 
      &mat[0], &mat[1], &mat[2], &mat[3], 
      &mat[4], &mat[5], &mat[6], &mat[7], 
      &mat[8], &mat[9], &mat[10], &mat[11],
      &mat[12], &mat[13], &mat[14], &mat[15] );
	*/

	dSscanf( data, "%g %g %g %g %g %g %g", &quat.x, &quat.y, &quat.z, &quat.w, &pos.x, &pos.y, &pos.z );

	MatrixF surface;
	quat.setMatrix( &surface );
	surface.setPosition( pos );

   shape->mSurfaces.push_back( surface );   

   return false;
}
コード例 #5
0
ファイル: propertyParsing.cpp プロジェクト: nev7n/Torque3D
 bool default_scan(const String &data, ColorI & result)
 {
    if(StringUnit::getUnitCount(data," ") == 3)
    {
       S32 r,g,b;
       dSscanf(data.c_str(),"%i %i %i",&r,&g,&b);
       result.set(r,g,b);
    }
    else
    {
       S32 r,g,b,a;
       dSscanf(data.c_str(),"%i %i %i %i",&r,&g,&b,&a);
       result.set(r,g,b,a);
    }
    return true;
 }
コード例 #6
0
ファイル: propertyParsing.cpp プロジェクト: nev7n/Torque3D
 bool default_scan(const String &data, Box3F & result)
 {
    dSscanf(data.c_str(),"%g %g %g %g %g %g",
       &result.minExtents.x,&result.minExtents.y,&result.minExtents.z,
       &result.maxExtents.x,&result.maxExtents.y,&result.maxExtents.z);
    return true;
 }
コード例 #7
0
ファイル: propertyParsing.cpp プロジェクト: nev7n/Torque3D
   bool default_scan( const String &data, QuatF & result )
   {
      if(StringUnit::getUnitCount(data," ") < 4)
         return false;

      dSscanf(data.c_str(),"%g %g %g %g", &result.x,&result.y,&result.z,&result.w);
      return true;
   }
コード例 #8
0
ファイル: propertyParsing.cpp プロジェクト: nev7n/Torque3D
   bool default_scan( const String &data, AngAxisF & result )
   {
      if(StringUnit::getUnitCount(data," ") < 4)
         return false;

      dSscanf(data.c_str(),"%g %g %g %g", &result.axis.x,&result.axis.y,&result.axis.z,&result.angle);
      result.angle = mDegToRad(result.angle);
      return true;
   }
コード例 #9
0
ファイル: decalRoad.cpp プロジェクト: Adhdcrazzy/Torque3D
bool DecalRoad::addNodeFromField( void *object, const char *index, const char *data )
{
   DecalRoad *pObj = static_cast<DecalRoad*>(object);
    
   F32 x,y,z,width;      
   U32 result = dSscanf( data, "%f %f %f %f", &x, &y, &z, &width );      
   if ( result == 4 )
      pObj->_addNode( Point3F(x,y,z), width );

   return false;
}
コード例 #10
0
void GuiColorPickerCtrl::onStaticModified( const char *slotName, const char *newValue )
{
	if( !dStricmp( slotName, "baseColor" ) || !dStricmp( slotName, "pickColor" ) )
	{
		ColorF color(1, 0, 0, 1);
		dSscanf( newValue, "%f %f %f %f", &color.red, &color.green, &color.blue, &color.alpha );
		if( !dStricmp( slotName, "baseColor" ) )
			mBaseColorCopy = color;
		else
			mPickColorCopy = color;
	}
}
コード例 #11
0
ファイル: propertyParsing.cpp プロジェクト: nev7n/Torque3D
   bool default_scan( const String &data, MatrixF & result )
   {
      if(StringUnit::getUnitCount(data," ") < 16)
         return false;

      F32* m = result;
      dSscanf(data.c_str(),"%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g", 
         &m[result.idx(0,0)], &m[result.idx(0,1)], &m[result.idx(0,2)], &m[result.idx(0,3)], 
         &m[result.idx(1,0)], &m[result.idx(1,1)], &m[result.idx(1,2)], &m[result.idx(1,3)], 
         &m[result.idx(2,0)], &m[result.idx(2,1)], &m[result.idx(2,2)], &m[result.idx(2,3)], 
         &m[result.idx(3,0)], &m[result.idx(3,1)], &m[result.idx(3,2)], &m[result.idx(3,3)]);         
      return true;
   }
コード例 #12
0
void ProcessedCustomMaterial::setMatrixParameter(MaterialParameters* param, 
                                                 MaterialParameterHandle* handle,
                                                 const String& value, GFXShaderConstType matrixType)
{
   MatrixF result(true);
   F32* m = result;
   switch (matrixType)
   {
   case GFXSCT_Float2x2 :
      dSscanf(value.c_str(),"%g %g %g %g", 
         m[result.idx(0,0)], m[result.idx(0,1)], 
         m[result.idx(1,0)], m[result.idx(1,1)]);
      break;
   case GFXSCT_Float3x3 :
      dSscanf(value.c_str(),"%g %g %g %g %g %g %g %g %g", 
         m[result.idx(0,0)], m[result.idx(0,1)], m[result.idx(0,2)], 
         m[result.idx(1,0)], m[result.idx(1,1)], m[result.idx(1,2)], 
         m[result.idx(2,0)], m[result.idx(2,1)], m[result.idx(2,2)]);         
      break;
   default:
      AssertFatal(false, "Invalid type!");
      break;
   }
}
コード例 #13
0
ファイル: projectile.cpp プロジェクト: AlkexGas/Torque3D
bool Projectile::_setInitialVelocity( void *object, const char *index, const char *data )
{
   Projectile* p = static_cast<Projectile*>( object );
   if ( p )
   {
	   Point3F vel;

	   S32 count = dSscanf( data, "%f %f %f", 
		   &vel.x, &vel.y, &vel.z);
   	
	   if ( (count != 3) )
      {
         Con::printf("Projectile: Failed to parse initial velocity \"vx vy vz\" from '%s'", data);
         return false;
      }

      p->setInitialVelocity( vel );
   }
   return false;
}
コード例 #14
0
ファイル: projectile.cpp プロジェクト: AlkexGas/Torque3D
bool Projectile::_setInitialPosition( void *object, const char *index, const char *data )
{
   Projectile* p = static_cast<Projectile*>( object );
   if ( p )
   {
	   Point3F pos;

	   S32 count = dSscanf( data, "%f %f %f", 
		   &pos.x, &pos.y, &pos.z);
   	
	   if ( (count != 3) )
      {
         Con::printf("Projectile: Failed to parse initial position \"px py pz\" from '%s'", data);
         return false;
      }

      p->setInitialPosition( pos );
   }
   return false;
}
コード例 #15
0
ファイル: engineDoc.cpp プロジェクト: Adhdcrazzy/Torque3D
static void dumpClassHeader(  Stream &stream, 
                              const char *usage, 
                              const char *className, 
                              const char *superClassName )
{
   if ( usage )
   {
      stream.writeText( "/*!\r\n" );
      stream.writeText( usage );

      const char *group = dStrstr( usage, "@ingroup" );
      if ( group )
      {
         char groupName[256] = { 0 };
         dSscanf( group, "@ingroup %s", groupName );
         smDocGroups.insertUnique( groupName, 0 );
      }
#ifdef USE_UNDOCUMENTED_GROUP
      else
      {
         smDocGroups.insertUnique( "UNDOCUMENTED", 0 );
         stream.writeText( "\r\n@ingroup UNDOCUMENTED\r\n" );
      }
#endif
      
      stream.writeText( "\r\n*/\r\n" );
   }
   else
   {
      // No documentation string.  Check whether ther is a separate
      // class doc fragement.
      
      bool haveClassDocFragment = false;
      if( className )
      {
         char buffer[ 1024 ];
         dSprintf( buffer, sizeof( buffer ), "@class %s", className );
         
         for(  ConsoleDocFragment* fragment = ConsoleDocFragment::smFirst;
               fragment != NULL; fragment = fragment->mNext )
            if( !fragment->mClass && dStrstr( fragment->mText, buffer ) != NULL )
            {
               haveClassDocFragment = true;
               break;
            }
      }
#ifdef USE_UNDOCUMENTED_GROUP
      if( !haveClassDocFragment )
      {
         smDocGroups.insertUnique( "UNDOCUMENTED", 0 );
         stream.writeText( "/*! UNDOCUMENTED!\r\n@ingroup UNDOCUMENTED\r\n */\r\n" );
      }
#endif
   }

   // Print out appropriate class header
   if ( superClassName )
      stream.writeText( String::ToString( "class %s : public %s {\r\npublic:\r\n", className, superClassName ? superClassName : "" ) );
   else if ( className )
      stream.writeText( String::ToString( "class %s {\r\npublic:\r\n", className ) );
   else
      stream.writeText( "namespace {\r\n" );
}
コード例 #16
0
ファイル: propertyParsing.cpp プロジェクト: nev7n/Torque3D
 bool default_scan(const String &data, Point4F & result)
 {
    dSscanf(data.c_str(),"%g %g %g %g",&result.x,&result.y,&result.z,&result.w);
    return true;
 }
コード例 #17
0
ファイル: propertyParsing.cpp プロジェクト: nev7n/Torque3D
 bool hex_scan(const String & string, S32 & hex)
 {
    dSscanf(string.c_str(),"%i", &hex);
    return true;
 }
コード例 #18
0
ファイル: propertyParsing.cpp プロジェクト: nev7n/Torque3D
 bool default_scan(const String &data, RectF & result)
 {
    dSscanf(data.c_str(),"%g %g %g %g",&result.point.x,&result.point.y,&result.extent.x,&result.extent.y);
    return true;
 }
コード例 #19
0
//--------------------------------------------------------------------------    
void GuiColorPickerCtrl::setScriptValue(const char *value)
{
   ColorF newValue;
   dSscanf(value, "%f %f %f %f", &newValue.red, &newValue.green, &newValue.blue, &newValue.alpha);
   setValue(newValue);
}
コード例 #20
0
ファイル: engineDoc.cpp プロジェクト: Adhdcrazzy/Torque3D
static void dumpFunction(  Stream &stream,
                           bool isClassMethod,
                           Namespace::Entry* entry )
{
   String doc = entry->getDocString().trim();
   String prototype = entry->getPrototypeString().trim();
   
   // If the doc string contains @hide, skip this function.
   
   if( dStrstr( doc.c_str(), "@hide" ) || dStrstr( doc.c_str(), "@internal" ) )
      return;
   
   // Make sure we have a valid function prototype.
   
   if( prototype.isEmpty() )
   {
      Con::errorf( "Function '%s::%s' has no prototype!", entry->mNamespace->mName, entry->mFunctionName );
      return;
   }
   
   // See if it's a static method.
   
   bool isStaticMethod = false;
   if( entry->mHeader )
      isStaticMethod = entry->mHeader->mIsStatic;
      
   // Emit the doc comment.

   if( !doc.isEmpty() )
   {
      stream.writeText( "/*!\r\n" );

      // If there's no @brief, take the first line of the doc text body
      // as the description.

      const char* brief = dStrstr( doc, "@brief" );
      if( !brief )
      {
         String brief = entry->getBriefDescription( &doc );
         
         brief.trim();
         if( !brief.isEmpty() )
         {
            stream.writeText( "@brief " );
            stream.writeText( brief );
            stream.writeText( "\r\n\r\n" );
         }
      }

      stream.writeText( doc );
      
      // Emit @ingroup if it's not a class method.

      if ( !isClassMethod && !isStaticMethod ) // Extra static method check for static classes (which will come out as non-class namespaces).
      {
         const char *group = dStrstr( doc, "@ingroup" );
         if( group )
         {
            char groupName[ 256 ] = { 0 };
            dSscanf( group, "@ingroup %s", groupName );
            smDocGroups.insertUnique( groupName, 0 );
         }
#ifdef USE_UNDOCUMENTED_GROUP
         else
         {
            smDocGroups.insertUnique( "UNDOCUMENTED", 0 );
            stream.writeText( "\r\n@ingroup UNDOCUMENTED\r\n" );
         }
#endif
      }
      
      stream.writeText( "*/\r\n" );
   }
#ifdef USE_UNDOCUMENTED_GROUP
   else if( !isClassMethod )
   {
      smDocGroups.insertUnique( "UNDOCUMENTED", 0 );
      stream.writeText( "/*! UNDOCUMENTED!\r\n@ingroup UNDOCUMENTED\r\n */\r\n" );
   }
#endif
      
   if( isStaticMethod )
      stream.writeText( "static " );
      
   stream.writeText( prototype );
   stream.writeText( ";\r\n" );
}