本文整理汇总了C++中idParser::ParseFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ idParser::ParseFloat方法的具体用法?C++ idParser::ParseFloat怎么用?C++ idParser::ParseFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idParser
的用法示例。
在下文中一共展示了idParser::ParseFloat方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MA_ParseEdge
bool MA_ParseEdge(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->edges) {
pMesh->numEdges = header->size;
pMesh->edges = (idVec3 *)Mem_Alloc( sizeof( idVec3 ) * pMesh->numEdges );
}
//Get the start and end index for this attribute
int minIndex, maxIndex;
if(!MA_ParseHeaderIndex(header, minIndex, maxIndex, "EdgeHeader", NULL)) {
//This was just a header
return true;
}
//Read each vert
for(int i = minIndex; i <= maxIndex; i++) {
pMesh->edges[i].x = parser.ParseFloat();
pMesh->edges[i].y = parser.ParseFloat();
pMesh->edges[i].z = parser.ParseFloat();
}
return true;
}
示例2: MA_ParseColor
bool MA_ParseColor(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->colors) {
pMesh->numColors = header->size;
pMesh->colors = (byte *)Mem_Alloc( sizeof( byte ) * pMesh->numColors * 4 );
}
//Get the start and end index for this attribute
int minIndex, maxIndex;
if(!MA_ParseHeaderIndex(header, minIndex, maxIndex, "ColorHeader", NULL)) {
//This was just a header
return true;
}
//Read each vert
for(int i = minIndex; i <= maxIndex; i++) {
pMesh->colors[i*4] = parser.ParseFloat() * 255;
pMesh->colors[i*4+1] = parser.ParseFloat() * 255;
pMesh->colors[i*4+2] = parser.ParseFloat() * 255;
pMesh->colors[i*4+3] = parser.ParseFloat() * 255;
}
return true;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: MA_ReadVec3
bool MA_ReadVec3(idParser& parser, idVec3& vec) {
idToken token;
if(!parser.SkipUntilString("double3")) {
throw idException( va("Maya Loader '%s': Invalid Vec3", parser.GetFileName()) );
}
//We need to flip y and z because of the maya coordinate system
vec.x = parser.ParseFloat();
vec.z = parser.ParseFloat();
vec.y = parser.ParseFloat();
return true;
}
示例7: ParseFilter
/*
================
sdDeclDamageFilter::ParseFilter
================
*/
bool sdDeclDamageFilter::ParseFilter( damageFilter_t& filter, idParser& src ) {
idToken token;
if( !src.ReadToken( &token ) || token.Cmp( "{" ) ) {
return false;
}
while ( true ) {
if ( !src.ReadToken( &token ) ) {
return false;
}
if ( !token.Cmp( "}" ) ) {
break;
}
if( !token.Icmp( "damage" ) ) {
bool error;
filter.damage = src.ParseFloat( &error );
if ( error ) {
src.Error( "sdDeclDamageFilter::ParseLevel Invalid Parm for 'damage'" );
return false;
}
if ( src.PeekTokenString( "%" ) ) {
src.ReadToken( &token );
filter.mode = DFM_PERCENT;
} else {
filter.mode = DFM_NORMAL;
}
} else if( !token.Icmp( "target" ) ) {
if ( !src.ReadToken( &token ) ) {
src.Error( "sdDeclDamageFilter::ParseLevel Missing Parm for 'target'" );
return false;
}
filter.target = gameLocal.declTargetInfoType.LocalFind( token, false );
if ( !filter.target ) {
src.Error( "sdDeclDamageFilter::ParseLevel Invalid Target '%s'", token.c_str() );
return false;
}
} else if( !token.Icmp( "noScale" ) ) {
filter.noScale = true;
} else {
src.Error( "sdDeclDamageFilter::ParseLevel Unknown Parameter %s", token.c_str() );
return false;
}
}
return true;
}
示例8: Parse
/*
============
sdDemoCamera_Fixed::Parse
============
*/
bool sdDemoCamera_Fixed::Parse( idParser& src ) {
if ( !src.ExpectTokenString( "{" ) ) {
return false;
}
idToken token;
while( true ) {
if ( !src.ExpectAnyToken( &token ) ) {
return false;
}
if ( !token.Cmp( "}" ) ) {
break;
} else if ( !token.Icmp( "origin" ) ) {
if ( !src.Parse1DMatrix( 3, origin.ToFloatPtr() ) ) {
return false;
}
} else if ( !token.Icmp( "axis" ) ) {
if ( !src.Parse2DMatrix( 3, 3, axis.ToFloatPtr() ) ) {
return false;
}
} else if ( !token.Icmp( "angles" ) ) {
idAngles angles;
if ( !src.Parse1DMatrix( 3, angles.ToFloatPtr() ) ) {
return false;
}
axis = angles.ToMat3();
} else if ( !token.Icmp( "fov" ) ) {
fov = src.ParseFloat();
} else if ( !sdDemoCamera::ParseKey( token, src ) ) {
src.Error( "sdDemoCamera_Fixed::Parse : Unknown keyword '%s'", token.c_str() );
return false;
}
}
return true;
}