MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / ParseLine

Method ParseLine

physx/samples/samplebase/wavefront.cpp:659–745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

657 }
658
659 int OBJ::ParseLine(int lineno,int argc,const char **argv) // return TRUE to continue parsing, return FALSE to abort parsing process
660 {
661 int ret = 0;
662
663 if ( argc >= 1 )
664 {
665 const char *foo = argv[0];
666 if ( *foo != '#' )
667 {
668 if (strcmp(argv[0], "v") == 0 && argc == 4 )
669 {
670 float vx = (float) atof( argv[1] );
671 float vy = (float) atof( argv[2] );
672 float vz = (float) atof( argv[3] );
673 Resize(mVerts, mMaxVerts, mNumVerts, mNumVerts + 3);
674 mVerts[mNumVerts++] = vx;
675 mVerts[mNumVerts++] = vy;
676 mVerts[mNumVerts++] = vz;
677 }
678 else if (strcmp(argv[0],"vt") == 0 && (argc == 3 || argc == 4))
679 {
680 // ignore 4rd component if present
681 float tx = (float) atof( argv[1] );
682 float ty = (float) atof( argv[2] );
683 Resize(mTexels, mMaxTexels, mNumTexels, mNumTexels + 2);
684 mTexels[mNumTexels++] = tx;
685 mTexels[mNumTexels++] = ty;
686 }
687 else if (strcmp(argv[0],"vn") == 0 && argc == 4 )
688 {
689 float normalx = (float) atof(argv[1]);
690 float normaly = (float) atof(argv[2]);
691 float normalz = (float) atof(argv[3]);
692 Resize(mNormals, mMaxNormals, mNumNormals, mNumNormals + 3);
693 mNormals[mNumNormals++] = normalx;
694 mNormals[mNumNormals++] = normaly;
695 mNormals[mNumNormals++] = normalz;
696
697 }
698 else if (strcmp(argv[0],"f") == 0 && argc >= 4 )
699 {
700 GeometryVertex v[32];
701
702 int vcount = argc-1;
703
704 for (int i=1; i<argc; i++)
705 {
706 GetVertex(v[i-1],argv[i] );
707 }
708
709 // need to generate a normal!
710#if 0 // not currently implemented
711 if ( mNormals.empty() )
712 {
713 Vector3d<float> p1( v[0].mPos );
714 Vector3d<float> p2( v[1].mPos );
715 Vector3d<float> p3( v[2].mPos );
716

Callers 1

ProcessLineMethod · 0.80

Calls 4

strcmpFunction · 0.85
ResizeFunction · 0.85
emptyMethod · 0.45
NodeTriangleMethod · 0.45

Tested by

no test coverage detected