Ejemplo n.º 1
0
  NxI32 CommandCallback(NxI32 token,NxI32 count,const char **arglist)
  {
  	NxI32 ret = 0;

    saveMenuState();

		switch ( token )
		{
      case MC_MEMORY_REPORT:
        break;

      case MC_FLOATING_POINT_RESOLUTION:
        if ( count == 2 )
        {
          MultiFloatType type = MFT_MEDIUM;
          if ( stricmp(arglist[1],"SMALL") == 0 )
            type = MFT_SMALL;
          else if ( stricmp(arglist[1],"MEDIUM") == 0 )
            type = MFT_MEDIUM;
          else if ( stricmp(arglist[1],"BIGFLOAT") == 0 )
            type = MFT_BIG;
          else if ( stricmp(arglist[1],"FIXED32") == 0 )
            type = MFT_FIXED32;
          tf_setFloatingPointResolution(gTfrac,type);
          gLog->Display("Setting Floating Point Resolution to: %s\r\n", arglist[1] );
        }
        break;
      case MC_SHOW_NORMALS:
        if ( count == 2 )
        {
          setShowNormals( getBool(arglist[1]) );
        }
        break;
      case MC_ENVIRONMENT_TEXTURE:
        if ( count == 2 )
        {
          const char *t = arglist[1];
          if ( gFileSystem ) t = gFileSystem->FileOpenString(t,true);
          gPd3d->setEnvironmentTexture(t);
        }
        break;
      case MC_ROTATION_SPEED:
        if ( count == 2 )
        {
          NxF32 rspeed = (NxF32)atof( arglist[1] );
          setRotationSpeed(rspeed);
        }
        break;
		  case MC_OPTIMIZE_MESH:
				if ( !mStartup )
				{
					tf_state(gTfrac,TS_OPTIMIZE_MESH);
				}
				break;
      case MC_FILTER_FRACTAL:
        if ( !mStartup )
        {
          tf_state(gTfrac,TS_FILTER_FRACTAL);
        }
        break;
      case MC_DEFAULT_MANDELBROT:
				if ( !mStartup )
				{
          BigFloat xleft;
          BigFloat xright;
          BigFloat ytop;
          xleft.FromDouble(-2.5);
          xright.FromDouble(0.75);
          ytop.FromDouble(-1.5);
          tf_setFractalCoordinates(gTfrac,xleft,xright,ytop);
          tf_action(gTfrac,FA_MOUSE_CENTER,false,1024/2,768/2);
				}
        break;
      case MC_CLAMP_LOW:
        if ( count == 2 && gTfrac )
        {
          NxF32 c = (NxF32) atof( arglist[1] );
          tf_state(gTfrac,TS_CLAMP_LOW,false,0,c);
        }
        break;
      case MC_CLAMP_HIGH:
        if ( count == 2 && gTfrac )
        {
          NxF32 c = (NxF32) atof( arglist[1] );
          tf_state(gTfrac,TS_CLAMP_HIGH,false,0,c);
        }
        break;
      case MC_CLAMP_SCALE:
        if ( count == 2 && gTfrac )
        {
          NxF32 c = (NxF32) atof( arglist[1] );
          tf_state(gTfrac,TS_CLAMP_SCALE,false,0,c);
        }
        break;
      case MC_WIREFRAME_OVERLAY:
        if ( count == 2 && gTfrac )
        {
          bool state = getBool(arglist[1]);
          tf_state(gTfrac,TS_WIREFAME_OVERLAY,state);
        }
        break;
      case MC_VIEW3D:
        if ( count == 2 )
        {
					gView3d = getBool(arglist[1]);
          if ( gView3d )
          {
            NxF32 eye[3];
            NxF32 look[3];
            look[0] = 0;
            look[1] = 0;
            look[2] = 0;
            eye[0] = 200;
            eye[1] = 250;
            eye[2] = 200;
            lookAt(eye,look);
          }
        }
        break;
      case MC_FRACTAL_COORDINATES:
        if ( count == 4 && gTfrac )
        {
          BigFloat xleft =  arglist[1];
          BigFloat xright = arglist[2];
          BigFloat ytop   = arglist[3];
          tf_setFractalCoordinates(gTfrac,xleft,xright,ytop);
        }
        break;
      case MC_COLOR_PALETTE:
        if ( count == 2 && gTfrac )
        {
          tf_setPal(gTfrac,arglist[1]);
        }
        break;
		  case MC_ITERATION_COUNT:
				if ( count == 2 && gTfrac )
				{
					NxU32 icount = (NxU32)atoi(arglist[1]);
					tf_state(gTfrac,TS_ITERATION_COUNT,false,icount);
				}
				break;
		  case MC_CLOCK_CYCLES:
				if ( count == 2 && gTfrac )
				{
					NxU32 icount = (NxU32)atoi(arglist[1]);
					tf_state(gTfrac,TS_CLOCK_CYCLES,false,icount);
				}
				break;
			case MC_USE_THREADING:
				if ( count == 2 && gTfrac )
				{
					bool state = getBool(arglist[1]);
  			  tf_state(gTfrac,TS_THREADING,state);
  			}
				break;

			case MC_SMOOTH_COLOR:
				if ( count == 2 && gTfrac )
				{
					NxI32 cscale  = atoi(arglist[1]);
					tf_state(gTfrac,TS_SMOOTH_COLOR,false,cscale);
				}
				break;

      case MC_PREVIEW_ONLY:
        if ( count == 2 && gTfrac )
        {
          bool state = getBool(arglist[1]);
          tf_state(gTfrac,TS_PREVIEW_ONLY,state);
        }
        break;
			case MC_RECTANGLE_SUBDIVISION:
        if ( count == 2 && gTfrac )
        {
          bool state = getBool(arglist[1]);
          tf_state(gTfrac,TS_RECTANGLE_SUBDIVISION,state);
        }
        break;
			case MC_PSLOOKAT:
				//            0      1      2      3       4      5       6
				// Usage: PsLookAt <eyex> <eyey> <eyez> <lookx> <looky> <lookz>
				if ( count == 7 )
				{
					NxF32 eye[3];
					NxF32 look[3];

					eye[0] = (NxF32) atof( arglist[1] );
					eye[1] = (NxF32) atof( arglist[2] );
					eye[2] = (NxF32) atof( arglist[3] );

					look[0] = (NxF32) atof(arglist[4] );
					look[1] = (NxF32) atof(arglist[5] );
					look[2] = (NxF32) atof(arglist[6] );

					lookAt(eye,look);

				}
				break;
			case MC_PSSCRIPT:
				{
					const char *fname = 0;
					if ( count >= 2 )
					{
						fname = arglist[1];
					}
#if TODO
  				SoftFileInterface *sfi = gSoftBodySystem->getSoftFileInterface();
  				if ( sfi )
  				{
  					fname = sfi->getLoadFileName(".psc", "Select a demo script to run.");
  				}
  				if ( fname )
  				{
  					CPARSER.Parse("Run \"%s\"",fname);
  				}
#endif
				}
				break;
		}


    return ret;
  }
Ejemplo n.º 2
0
  int CommandCallback(int token,int count,const char **arglist)
  {
  	int ret = 0;

  	ret = gSoftBodySystem->processCommand( (SoftBodyCommand) token, count, arglist );

		switch ( token )
		{
			case MC_ASYNC:
				if ( count == 2 )
				{
					px_setAsync( stricmp(arglist[1],"true") == 0 );
				}
				break;
			case MC_TIME_SCALE:
				if ( count == 2 )
				{
					float scale = (float) atof( arglist[1] );
					px_setTimeScale(scale);
				}
				break;
		  case MC_GRAVITY:
		  	if ( count == 2 )
		  	{
		  		NxVec3 g;
		  		g.x = 0;
		  		g.y = (float) atof( arglist[1] );
		  		g.z = 0;
		  		px_setGravity(&g.x);
		  	}
		  	break;
			case MC_PSLOOKAT:
				//            0      1      2      3       4      5       6
				// Usage: PsLookAt <eyex> <eyey> <eyez> <lookx> <looky> <lookz>
				if ( count == 7 )
				{
					float eye[3];
					float look[3];

					eye[0] = (float) atof( arglist[1] );
					eye[1] = (float) atof( arglist[2] );
					eye[2] = (float) atof( arglist[3] );

					look[0] = (float) atof(arglist[4] );
					look[1] = (float) atof(arglist[5] );
					look[2] = (float) atof(arglist[6] );

					lookAt(eye,look);

				}
				break;
			case SBC_IMPORT:
        px_createGroundPlane();
				break;
			case MC_PSSCRIPT:
				if ( 1 )
				{
					const char *fname = 0;
					if ( count >= 2 )
					{
						fname = arglist[1];
					}
  				SoftFileInterface *sfi = gSoftBodySystem->getSoftFileInterface();
  				if ( sfi )
  				{
  					fname = sfi->getLoadFileName(".psc", "Select a demo script to run.");
  				}
  				if ( fname )
  				{
  					CPARSER.Parse("Run \"%s\"",fname);
  				}
				}
				break;
			case MC_CREATE_DYNAMICS:
				if ( count >= 3 )
				{
					const char *fname  = arglist[1];
					const char *output = arglist[2];

					CreateDynamicsAPI *api = getCreateDynamicsDLL(this);
          if ( api )
          {

            CD_Format format = CD_XML;
            if ( strcmp(output,"COLLADA") == 0 )
            	format = CD_COLLADA;

            CreateDynamicsResult result;

            bool ok = api->createDynamics(arglist[1], "rules.rul", format, &result );

            if ( ok )
            {
 							gAllGlobals.gLog.ref()->Display("===========================================================\r\n");
 							gAllGlobals.gLog.ref()->Display("BoneCount:           %4d\r\n", result.mBoneCount);
 							gAllGlobals.gLog.ref()->Display("IgnoreCount:         %4d\r\n", result.mIgnoreCount);
 							gAllGlobals.gLog.ref()->Display("CollapseCount:       %4d\r\n", result.mCollapseCount);
 							gAllGlobals.gLog.ref()->Display("BodyPairCount:       %4d\r\n", result.mBodyPairCount);
 							gAllGlobals.gLog.ref()->Display("BoxCount:            %4d\r\n", result.mBoxCount);
 							gAllGlobals.gLog.ref()->Display("SphereCount:         %4d\r\n", result.mSphereCount);
 							gAllGlobals.gLog.ref()->Display("CapsuleCount:        %4d\r\n", result.mCapsuleCount);
 							gAllGlobals.gLog.ref()->Display("ConvexCount:         %4d\r\n", result.mConvexCount);
 							gAllGlobals.gLog.ref()->Display("NullCount:           %4d\r\n", result.mNullCount );
 							gAllGlobals.gLog.ref()->Display("CompoundCount:       %4d\r\n", result.mCompoundCount);
 							gAllGlobals.gLog.ref()->Display("ClothCount:          %4d\r\n", result.mClothCount);
 							gAllGlobals.gLog.ref()->Display("ClothVertices:       %4d\r\n", result.mClothVertices);
 							gAllGlobals.gLog.ref()->Display("ClothTrianges:       %4d\r\n", result.mClothTriangles);
 							gAllGlobals.gLog.ref()->Display("ActorCount:          %4d\r\n", result.mActorCount);
 							gAllGlobals.gLog.ref()->Display("ShapeCount:          %4d\r\n", result.mShapeCount);
 							gAllGlobals.gLog.ref()->Display("JointCount:          %4d\r\n", result.mJointCount);
 							gAllGlobals.gLog.ref()->Display("===========================================================\r\n");

   						char scratch[512];
							char base[256];
							char path[256];
							char postfix[256];
							if ( IsDirectory(fname,path,base,postfix) )
							{
								strcpy(scratch,base);
							}
							else
							{
					      strcpy(scratch, fname );
							}

              char *dot = strchr(scratch,'.');

					    if ( dot )
					    {
   							*dot = 0;
								if ( format == CD_XML )
   							  strcat(scratch,".xml");
								else
									strcat(scratch,".dae");
   							const char *argv[2];
   							argv[0] = 0;
   							argv[1] = scratch;
					      gSoftBodySystem->processCommand(SBC_RESET_SCENE,1,0);
					      if ( format == CD_XML )
            			gSoftBodySystem->processCommand(SBC_IMPORT_XML,2,argv);
            		else
            			gSoftBodySystem->processCommand(SBC_IMPORT_COLLADA,2,argv);
   						}

   					}
   				}
				}
				break;
		}


    return ret;
  }