当前位置: 首页>>代码示例>>C++>>正文


C++ idParser::UnreadToken方法代码示例

本文整理汇总了C++中idParser::UnreadToken方法的典型用法代码示例。如果您正苦于以下问题:C++ idParser::UnreadToken方法的具体用法?C++ idParser::UnreadToken怎么用?C++ idParser::UnreadToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在idParser的用法示例。


在下文中一共展示了idParser::UnreadToken方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MA_ParseTVert

bool MA_ParseTVert( idParser &parser, maAttribHeader_t *header )
{

	maMesh_t *pMesh = &maGlobal.currentObject->mesh;
	idToken token;
	
	//This is not the texture coordinates. It is just the name so ignore it
	if( strstr( header->name, "uvsn" ) )
	{
		return true;
	}
	
	//Allocate enough space for all the data
	if( !pMesh->tvertexes )
	{
		pMesh->numTVertexes = header->size;
		pMesh->tvertexes = ( idVec2 * ) Mem_Alloc( sizeof( idVec2 ) * pMesh->numTVertexes );
	}
	
	//Get the start and end index for this attribute
	int minIndex, maxIndex;
	
	if( !MA_ParseHeaderIndex( header, minIndex, maxIndex, "TextureCoordHeader", "uvsp" ) )
	{
		//This was just a header
		return true;
	}
	
	parser.ReadToken( &token );
	
	if( !token.Icmp( "-" ) )
	{
		idToken tk2;
		parser.ReadToken( &tk2 );
		
		if( !tk2.Icmp( "type" ) )
		{
			parser.SkipUntilString( "float2" );
		}
		else
		{
			parser.UnreadToken( &tk2 );
			parser.UnreadToken( &token );
		}
	}
	else
	{
		parser.UnreadToken( &token );
	}
	
	//Read each tvert
	for( int i = minIndex; i <= maxIndex; i++ )
	{
		pMesh->tvertexes[i].x = parser.ParseFloat();
		pMesh->tvertexes[i].y = 1.0f - parser.ParseFloat();
	}
	
	return true;
}
开发者ID:revelator,项目名称:MHDoom,代码行数:59,代码来源:Model_ma.cpp

示例2: MA_ParseNormal

bool MA_ParseNormal(idParser& parser, maAttribHeader_t* header) {

    maMesh_t* pMesh = &maGlobal.currentObject->mesh;
    idToken token;

    //Allocate enough space for all the verts if this is the first attribute for verticies
    if(!pMesh->normals) {
        pMesh->numNormals = header->size;
        pMesh->normals = (idVec3 *)Mem_Alloc( sizeof( idVec3 ) * pMesh->numNormals );
    }

    //Get the start and end index for this attribute
    int minIndex, maxIndex;
    if(!MA_ParseHeaderIndex(header, minIndex, maxIndex, "NormalHeader", NULL)) {
        //This was just a header
        return true;
    }


    parser.ReadToken(&token);
    if(!token.Icmp("-")) {
        idToken tk2;
        parser.ReadToken(&tk2);
        if(!tk2.Icmp("type")) {
            parser.SkipUntilString("float3");
        } else {
            parser.UnreadToken(&tk2);
            parser.UnreadToken(&token);
        }
    } else {
        parser.UnreadToken(&token);
    }


    //Read each vert
    for(int i = minIndex; i <= maxIndex; i++) {
        pMesh->normals[i].x = parser.ParseFloat();

        //Adjust the normals for the change in coordinate systems
        pMesh->normals[i].z = parser.ParseFloat();
        pMesh->normals[i].y = -parser.ParseFloat();

        pMesh->normals[i].Normalize();

    }

    pMesh->normalsParsed = true;
    pMesh->nextNormal = 0;

    return true;
}
开发者ID:boscorillium,项目名称:dhewm3,代码行数:51,代码来源:Model_ma.cpp

示例3: MA_ParseVertexTransforms

bool MA_ParseVertexTransforms(idParser& parser, maAttribHeader_t* header) {

    maMesh_t* pMesh = &maGlobal.currentObject->mesh;
    idToken token;

    //Allocate enough space for all the verts if this is the first attribute for verticies
    if(!pMesh->vertTransforms) {
        if(header->size == 0) {
            header->size = 1;
        }

        pMesh->numVertTransforms = header->size;
        pMesh->vertTransforms = (idVec4 *)Mem_Alloc( sizeof( idVec4 ) * pMesh->numVertTransforms );
        pMesh->nextVertTransformIndex = 0;
    }

    //Get the start and end index for this attribute
    int minIndex, maxIndex;
    if(!MA_ParseHeaderIndex(header, minIndex, maxIndex, "VertexTransformHeader", NULL)) {
        //This was just a header
        return true;
    }

    parser.ReadToken(&token);
    if(!token.Icmp("-")) {
        idToken tk2;
        parser.ReadToken(&tk2);
        if(!tk2.Icmp("type")) {
            parser.SkipUntilString("float3");
        } else {
            parser.UnreadToken(&tk2);
            parser.UnreadToken(&token);
        }
    } else {
        parser.UnreadToken(&token);
    }

    //Read each vert
    for(int i = minIndex; i <= maxIndex; i++) {
        pMesh->vertTransforms[pMesh->nextVertTransformIndex].x = parser.ParseFloat();
        pMesh->vertTransforms[pMesh->nextVertTransformIndex].z = parser.ParseFloat();
        pMesh->vertTransforms[pMesh->nextVertTransformIndex].y = -parser.ParseFloat();

        //w hold the vert index
        pMesh->vertTransforms[pMesh->nextVertTransformIndex].w = i;

        pMesh->nextVertTransformIndex++;
    }

    return true;
}
开发者ID:boscorillium,项目名称:dhewm3,代码行数:51,代码来源:Model_ma.cpp

示例4: ParseConstantValue

/*
================
idTypeInfoGen::ParseConstantValue
================
*/
void idTypeInfoGen::ParseConstantValue( const char *scope, idParser &src, idStr &value ) {
	idToken token;
	idStr constantString;

	int indent = 0;
	while( src.ReadToken( &token ) ) {
		if ( token == "(" ) {
			indent++;
		} else if ( token == ")" ) {
			indent--;
		} else if ( indent == 0 && ( token == ";" || token == "," || token == "}" ) ) {
			src.UnreadToken( &token );
			break;
		} else if ( token.type == TT_NAME ) {
			constantString = token;
			while( src.CheckTokenString( "::" ) ) {
				src.ExpectTokenType( TT_NAME, 0, &token );
				constantString += "::" + token;
			}
			value += va( "%d", GetIntegerConstant( scope, constantString, src ) );
			continue;
		}
		value += token;
	}
}
开发者ID:Deepfreeze32,项目名称:idtech4cdk,代码行数:30,代码来源:TypeInfoGen.cpp

示例5: MA_ParseTransform

bool MA_ParseTransform(idParser& parser) {

    maNodeHeader_t	header;
    maTransform_t*	transform;
    memset(&header, 0, sizeof(header));

    //Allocate room for the transform
    transform = (maTransform_t *)Mem_Alloc( sizeof( maTransform_t ) );
    memset(transform, 0, sizeof(maTransform_t));
    transform->scale.x = transform->scale.y = transform->scale.z = 1;

    //Get the header info from the transform
    MA_ParseNodeHeader(parser, &header);

    //Read the transform attributes
    idToken token;
    while(parser.ReadToken(&token)) {
        if(IsNodeComplete(token)) {
            parser.UnreadToken(&token);
            break;
        }
        if(!token.Icmp("setAttr")) {
            parser.ReadToken(&token);
            if(!token.Icmp(".t")) {
                if(!MA_ReadVec3(parser, transform->translate)) {
                    return false;
                }
                transform->translate.y *=  -1;
            } else if (!token.Icmp(".r")) {
                if(!MA_ReadVec3(parser, transform->rotate)) {
                    return false;
                }
            } else if (!token.Icmp(".s")) {
                if(!MA_ReadVec3(parser, transform->scale)) {
                    return false;
                }
            } else {
                parser.SkipRestOfLine();
            }
        }
    }

    if(header.parent[0] != 0) {
        //Find the parent
        maTransform_t**	parent;
        maGlobal.model->transforms.Get(header.parent, &parent);
        if(parent) {
            transform->parent = *parent;
        }
    }

    //Add this transform to the list
    maGlobal.model->transforms.Set(header.name, transform);
    return true;
}
开发者ID:boscorillium,项目名称:dhewm3,代码行数:55,代码来源:Model_ma.cpp

示例6: MA_ParseFileNode

void MA_ParseFileNode( idParser &parser )
{

	//Get the header info from the node
	maNodeHeader_t	header;
	MA_ParseNodeHeader( parser, &header );
	
	//Read the transform attributes
	idToken token;
	
	while( parser.ReadToken( &token ) )
	{
		if( IsNodeComplete( token ) )
		{
			parser.UnreadToken( &token );
			break;
		}
		
		if( !token.Icmp( "setAttr" ) )
		{
			maAttribHeader_t attribHeader;
			MA_ParseAttribHeader( parser, &attribHeader );
			
			if( strstr( attribHeader.name, ".ftn" ) )
			{
				parser.SkipUntilString( "string" );
				parser.ReadToken( &token );
				
				if( !token.Icmp( "(" ) )
				{
					parser.ReadToken( &token );
				}
				
				maFileNode_t *fileNode;
				fileNode = ( maFileNode_t * ) Mem_Alloc( sizeof( maFileNode_t ) );
				strcpy( fileNode->name, header.name );
				strcpy( fileNode->path, token.c_str() );
				
				maGlobal.model->fileNodes.Set( fileNode->name, fileNode );
			}
			else
			{
				parser.SkipRestOfLine();
			}
		}
	}
}
开发者ID:revelator,项目名称:MHDoom,代码行数:47,代码来源:Model_ma.cpp

示例7: MA_ParseMesh

void MA_ParseMesh(idParser& parser) {

    maObject_t	*object;
    object = (maObject_t *)Mem_Alloc( sizeof( maObject_t ) );
    memset( object, 0, sizeof( maObject_t ) );
    maGlobal.model->objects.Append( object );
    maGlobal.currentObject = object;
    object->materialRef = -1;


    //Get the header info from the mesh
    maNodeHeader_t	header;
    MA_ParseNodeHeader(parser, &header);

    //Find my parent
    if(header.parent[0] != 0) {
        //Find the parent
        maTransform_t**	parent;
        maGlobal.model->transforms.Get(header.parent, &parent);
        if(parent) {
            maGlobal.currentObject->mesh.transform = *parent;
        }
    }

    strcpy(object->name, header.name);

    //Read the transform attributes
    idToken token;
    while(parser.ReadToken(&token)) {
        if(IsNodeComplete(token)) {
            parser.UnreadToken(&token);
            break;
        }
        if(!token.Icmp("setAttr")) {
            maAttribHeader_t header;
            MA_ParseAttribHeader(parser, &header);

            if(strstr(header.name, ".vt")) {
                MA_ParseVertex(parser, &header);
            } else if (strstr(header.name, ".ed")) {
                MA_ParseEdge(parser, &header);
            } else if (strstr(header.name, ".pt")) {
                MA_ParseVertexTransforms(parser, &header);
            } else if (strstr(header.name, ".n")) {
                MA_ParseNormal(parser, &header);
            } else if (strstr(header.name, ".fc")) {
                MA_ParseFace(parser, &header);
            } else if (strstr(header.name, ".clr")) {
                MA_ParseColor(parser, &header);
            } else if (strstr(header.name, ".uvst")) {
                MA_ParseTVert(parser, &header);
            } else {
                parser.SkipRestOfLine();
            }
        }
    }


    maMesh_t* pMesh = &maGlobal.currentObject->mesh;

    //Get the verts from the edge
    for(int i = 0; i < pMesh->numFaces; i++) {
        for(int j = 0; j < 3; j++) {
            int edge = pMesh->faces[i].edge[j];
            if(edge < 0) {
                edge = idMath::Fabs(edge)-1;
                pMesh->faces[i].vertexNum[j] = pMesh->edges[edge].y;
            } else {
                pMesh->faces[i].vertexNum[j] = pMesh->edges[edge].x;
            }
        }
    }

    //Get the normals
    if(pMesh->normalsParsed) {
        for(int i = 0; i < pMesh->numFaces; i++) {
            for(int j = 0; j < 3; j++) {

                //Is this vertex shared
                int sharedFace = -1;
                int sharedVert = -1;

                if(MA_QuickIsVertShared(i, j)) {
                    MA_GetSharedFace(i, j, sharedFace, sharedVert);
                }

                if(sharedFace != -1) {
                    //Get the normal from the share
                    pMesh->faces[i].vertexNormals[j] = pMesh->faces[sharedFace].vertexNormals[sharedVert];

                } else {
                    //The vertex is not shared so get the next normal
                    if(pMesh->nextNormal >= pMesh->numNormals) {
                        //We are using more normals than exist
                        throw idException(va("Maya Loader '%s': Invalid Normals Index.", parser.GetFileName()));
                    }
                    pMesh->faces[i].vertexNormals[j] = pMesh->normals[pMesh->nextNormal];
                    pMesh->nextNormal++;
                }
            }
//.........这里部分代码省略.........
开发者ID:boscorillium,项目名称:dhewm3,代码行数:101,代码来源:Model_ma.cpp

示例8: MA_ParseFace

bool MA_ParseFace(idParser& parser, maAttribHeader_t* header) {

    maMesh_t* pMesh = &maGlobal.currentObject->mesh;
    idToken token;

    //Allocate enough space for all the verts if this is the first attribute for verticies
    if(!pMesh->faces) {
        pMesh->numFaces = header->size;
        pMesh->faces = (maFace_t *)Mem_Alloc( sizeof( maFace_t ) * pMesh->numFaces );
    }

    //Get the start and end index for this attribute
    int minIndex, maxIndex;
    if(!MA_ParseHeaderIndex(header, minIndex, maxIndex, "FaceHeader", NULL)) {
        //This was just a header
        return true;
    }

    //Read the face data
    int currentFace = minIndex-1;
    while(parser.ReadToken(&token)) {
        if(IsNodeComplete(token)) {
            parser.UnreadToken(&token);
            break;
        }

        if(!token.Icmp("f")) {
            int count = parser.ParseInt();
            if(count != 3) {
                throw idException(va("Maya Loader '%s': Face is not a triangle.", parser.GetFileName()));
            }
            //Increment the face number because a new face always starts with an "f" token
            currentFace++;

            //We cannot reorder edges until later because the normal processing
            //assumes the edges are in the original order
            pMesh->faces[currentFace].edge[0] = parser.ParseInt();
            pMesh->faces[currentFace].edge[1] = parser.ParseInt();
            pMesh->faces[currentFace].edge[2] = parser.ParseInt();

            //Some more init stuff
            pMesh->faces[currentFace].vertexColors[0] = pMesh->faces[currentFace].vertexColors[1] = pMesh->faces[currentFace].vertexColors[2] = -1;

        } else if(!token.Icmp("mu")) {
            /* int uvstIndex = */ parser.ParseInt();
            int count = parser.ParseInt();
            if(count != 3) {
                throw idException(va("Maya Loader '%s': Invalid texture coordinates.", parser.GetFileName()));
            }
            pMesh->faces[currentFace].tVertexNum[0] = parser.ParseInt();
            pMesh->faces[currentFace].tVertexNum[1] = parser.ParseInt();
            pMesh->faces[currentFace].tVertexNum[2] = parser.ParseInt();

        } else if(!token.Icmp("mf")) {
            int count = parser.ParseInt();
            if(count != 3) {
                throw idException(va("Maya Loader '%s': Invalid texture coordinates.", parser.GetFileName()));
            }
            pMesh->faces[currentFace].tVertexNum[0] = parser.ParseInt();
            pMesh->faces[currentFace].tVertexNum[1] = parser.ParseInt();
            pMesh->faces[currentFace].tVertexNum[2] = parser.ParseInt();

        } else if(!token.Icmp("fc")) {

            int count = parser.ParseInt();
            if(count != 3) {
                throw idException(va("Maya Loader '%s': Invalid vertex color.", parser.GetFileName()));
            }
            pMesh->faces[currentFace].vertexColors[0] = parser.ParseInt();
            pMesh->faces[currentFace].vertexColors[1] = parser.ParseInt();
            pMesh->faces[currentFace].vertexColors[2] = parser.ParseInt();

        }
    }

    return true;
}
开发者ID:boscorillium,项目名称:dhewm3,代码行数:77,代码来源:Model_ma.cpp

示例9: ParseScope


//.........这里部分代码省略.........
				while( src.ReadToken( &token ) ) {
					if ( token == "{" ) {
						indent++;
					} else if ( token == "}" ) {
						indent--;
					} else if ( token == ";" && indent == 1 ) {
						break;
					}
				}
			}

			varType = "";
			isConst = false;
			isStatic = false;

		} else if ( token == "const" ) {

			varType += token + " ";
			isConst = true;

		} else if ( token == "static" ) {

			varType += token + " ";
			isStatic = true;

		} else if ( token.type == TT_NAME ) {
	
			assert( indent == 1 );

			// if this is a class operator
			if ( token == "operator" ) {
				while( src.ReadToken( &token ) ) {
					if ( token == "(" ) {
						src.UnreadToken( &token );
						break;
					}
				}
			}

			// if this is a class method
			if ( src.CheckTokenString( "(" ) ) {

				indent++;
				while( indent > 1 && src.ReadToken( &token ) ) {
					if ( token == "(" ) {
						indent++;
					} else if ( token == ")" ) {
						indent--;
					}
				}

				if ( src.CheckTokenString( "(" ) ) {
					indent++;
					while( indent > 1 && src.ReadToken( &token ) ) {
						if ( token == "(" ) {
							indent++;
						} else if ( token == ")" ) {
							indent--;
						}
					}
				}

				if ( src.CheckTokenString( "const" ) ) {
				}

				if ( src.CheckTokenString( "=" ) ) {
开发者ID:Deepfreeze32,项目名称:idtech4cdk,代码行数:67,代码来源:TypeInfoGen.cpp


注:本文中的idParser::UnreadToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。