예제 #1
0
NxI32 OBJ::ParseLine(NxI32 lineno,NxI32 argc,const char **argv)  // return TRUE to continue parsing, return FALSE to abort parsing process
{
  NxI32 ret = 0;

  if ( argc >= 1 )
  {
    const char *foo = argv[0];
    if ( *foo != '#' )
    {
      if ( _stricmp(argv[0],"v") == 0 && argc == 4 )
      {
        NxF32 vx = (NxF32) atof( argv[1] );
        NxF32 vy = (NxF32) atof( argv[2] );
        NxF32 vz = (NxF32) atof( argv[3] );
        mVerts.push_back(vx);
        mVerts.push_back(vy);
        mVerts.push_back(vz);
      }
      else if ( _stricmp(argv[0],"vt") == 0 && (argc == 3 || argc == 4))
      {
        // ignore 4rd component if present
        NxF32 tx = (NxF32) atof( argv[1] );
        NxF32 ty = (NxF32) atof( argv[2] );
        mTexels.push_back(tx);
        mTexels.push_back(ty);
      }
      else if ( _stricmp(argv[0],"vn") == 0 && argc == 4 )
      {
        NxF32 normalx = (NxF32) atof(argv[1]);
        NxF32 normaly = (NxF32) atof(argv[2]);
        NxF32 normalz = (NxF32) atof(argv[3]);
        mNormals.push_back(normalx);
        mNormals.push_back(normaly);
        mNormals.push_back(normalz);
      }
      else if ( _stricmp(argv[0],"f") == 0 && argc >= 4 )
      {
        GeometryVertex v[32];

        NxI32 vcount = argc-1;

        for (NxI32 i=1; i<argc; i++)
        {
          GetVertex(v[i-1],argv[i] );
        }

		mCallback->NodeTriangle(&v[0],&v[1],&v[2], mTextured);

        if ( vcount >=3 ) // do the fan
        {
          for (NxI32 i=2; i<(vcount-1); i++)
          {
            mCallback->NodeTriangle(&v[0],&v[i],&v[i+1], mTextured);
          }
        }

      }
    }
  }

  return ret;
}
예제 #2
0
int OBJ::ParseLine(int lineno,int argc,const char **argv)  // return TRUE to continue parsing, return FALSE to abort parsing process
{
  int ret = 0;

  if ( argc >= 1 )
  {
    const char *foo = argv[0];
    if ( *foo != '#' )
    {
  if ( strcmp(argv[0],"v") == 0 && argc == 4 )

      //if ( stricmp(argv[0],"v") == 0 && argc == 4 )
      {
        float vx = (float) atof( argv[1] );
        float vy = (float) atof( argv[2] );
        float vz = (float) atof( argv[3] );
        mVerts.push_back(vx);
        mVerts.push_back(vy);
        mVerts.push_back(vz);
      }
  else if ( strcmp(argv[0],"vt") == 0 && argc == 3 )

 //     else if ( stricmp(argv[0],"vt") == 0 && argc == 3 )
      {
        float tx = (float) atof( argv[1] );
        float ty = (float) atof( argv[2] );
        mTexels.push_back(tx);
        mTexels.push_back(ty);
      }
	//  else if ( stricmp(argv[0],"vn") == 0 && argc == 4 )

      else if ( strcmp(argv[0],"vn") == 0 && argc == 4 )
      {
        float normalx = (float) atof(argv[1]);
        float normaly = (float) atof(argv[2]);
        float normalz = (float) atof(argv[3]);
        mNormals.push_back(normalx);
        mNormals.push_back(normaly);
        mNormals.push_back(normalz);
      }
//  else if ( stricmp(argv[0],"f") == 0 && argc >= 4 )

      else if ( strcmp(argv[0],"f") == 0 && argc >= 4 )
      {
        GeometryVertex v[32];

        int vcount = argc-1;

        for (int i=1; i<argc; i++)
        {
          getVertex(v[i-1],argv[i] );
        }

        // need to generate a normal!
#if 0 // not currently implemented
        if ( mNormals.empty() )
        {
          Vector3d<float> p1( v[0].mPos );
          Vector3d<float> p2( v[1].mPos );
          Vector3d<float> p3( v[2].mPos );

          Vector3d<float> n;
          n.ComputeNormal(p3,p2,p1);

          for (int i=0; i<vcount; i++)
          {
            v[i].mNormal[0] = n.x;
            v[i].mNormal[1] = n.y;
            v[i].mNormal[2] = n.z;
          }

        }
#endif

        mCallback->NodeTriangle(&v[0],&v[1],&v[2]);

        if ( vcount >=3 ) // do the fan
        {
          for (int i=2; i<(vcount-1); i++)
          {
            mCallback->NodeTriangle(&v[0],&v[i],&v[i+1]);
          }
        }

      }
    }
  }

  return ret;
}
예제 #3
0
int OBJ::ParseLine(int /*lineno*/,int argc,const char **argv)  // return TRUE to continue parsing, return FALSE to abort parsing process
{
    int ret = 0;

    if ( argc >= 1 )
    {
        const char *foo = argv[0];
        if ( *foo != '#' )
        {
            if ( strcasecmp(argv[0],"v") == 0 && argc == 4 )
            {
                float vx = (float) atof( argv[1] );
                float vy = (float) atof( argv[2] );
                float vz = (float) atof( argv[3] );
                mVerts.push_back(vx);
                mVerts.push_back(vy);
                mVerts.push_back(vz);
            }
            else if ( strcasecmp(argv[0],"vt") == 0 && (argc == 3 || argc == 4))
            {
                // ignore 4rd component if present
                float tx = (float) atof( argv[1] );
                float ty = (float) atof( argv[2] );
                mTexels.push_back(tx);
                mTexels.push_back(ty);
            }
            else if ( strcasecmp(argv[0],"vn") == 0 && argc == 4 )
            {
                float normalx = (float) atof(argv[1]);
                float normaly = (float) atof(argv[2]);
                float normalz = (float) atof(argv[3]);
                mNormals.push_back(normalx);
                mNormals.push_back(normaly);
                mNormals.push_back(normalz);
            }
            else if ( strcasecmp(argv[0],"f") == 0 && argc >= 4 )
            {
                GeometryVertex v[32];

                int vcount = argc-1;

                for (int i=1; i<argc; i++)
                {
                    GetVertex(v[i-1],argv[i] );
                }


                mCallback->NodeTriangle(&v[0],&v[1],&v[2], mTextured);

                if ( vcount >=3 ) // do the fan
                {
                    for (int i=2; i<(vcount-1); i++)
                    {
                        mCallback->NodeTriangle(&v[0],&v[i],&v[i+1], mTextured);
                    }
                }

            }
        }
    }

    return ret;
}
예제 #4
0
	int OBJ::ParseLine(int lineno,int argc,const char **argv)  // return TRUE to continue parsing, return FALSE to abort parsing process
	{
		int ret = 0;

		if ( argc >= 1 )
		{
			const char *foo = argv[0];
			if ( *foo != '#' )
			{
				if (strcmp(argv[0], "v") == 0 && argc == 4 )
				{
					float vx = (float) atof( argv[1] );
					float vy = (float) atof( argv[2] );
					float vz = (float) atof( argv[3] );
					Resize(mVerts, mMaxVerts, mNumVerts, mNumVerts + 3);
					mVerts[mNumVerts++] = vx;
					mVerts[mNumVerts++] = vy;
					mVerts[mNumVerts++] = vz;
				}
				else if (strcmp(argv[0],"vt") == 0 && (argc == 3 || argc == 4))
				{
					// ignore 4rd component if present
					float tx = (float) atof( argv[1] );
					float ty = (float) atof( argv[2] );
					Resize(mTexels, mMaxTexels, mNumTexels, mNumTexels + 2);
					mTexels[mNumTexels++] = tx;
					mTexels[mNumTexels++] = ty;
				}
				else if (strcmp(argv[0],"vn") == 0 && argc == 4 )
				{
					float normalx = (float) atof(argv[1]);
					float normaly = (float) atof(argv[2]);
					float normalz = (float) atof(argv[3]);
					Resize(mNormals, mMaxNormals, mNumNormals, mNumNormals + 3);
					mNormals[mNumNormals++] = normalx;
					mNormals[mNumNormals++] = normaly;
					mNormals[mNumNormals++] = normalz;

				}
				else if (strcmp(argv[0],"f") == 0 && argc >= 4 )
				{
					GeometryVertex v[32];

					int vcount = argc-1;

					for (int i=1; i<argc; i++)
					{
						GetVertex(v[i-1],argv[i] );
					}

					// need to generate a normal!
#if 0 // not currently implemented
					if ( mNormals.empty() )
					{
						Vector3d<float> p1( v[0].mPos );
						Vector3d<float> p2( v[1].mPos );
						Vector3d<float> p3( v[2].mPos );

						Vector3d<float> n;
						n.ComputeNormal(p3,p2,p1);

						for (int i=0; i<vcount; i++)
						{
							v[i].mNormal[0] = n.x;
							v[i].mNormal[1] = n.y;
							v[i].mNormal[2] = n.z;
						}

					}
#endif

					mCallback->NodeTriangle(&v[0],&v[1],&v[2], mTextured);

					if ( vcount >=3 ) // do the fan
					{
						for (int i=2; i<(vcount-1); i++)
						{
							mCallback->NodeTriangle(&v[0],&v[i],&v[i+1], mTextured);
						}
					}

				}
			}
		}

		return ret;
	}