本文整理汇总了C++中readFloat函数的典型用法代码示例。如果您正苦于以下问题:C++ readFloat函数的具体用法?C++ readFloat怎么用?C++ readFloat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readFloat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findNextNoneWhiteSpace
void CIrrMeshFileLoader::readMeshBuffer(io::IXMLReader* reader, int vertexCount, SMeshBufferLightMap* sbuffer)
{
core::stringc data = reader->getNodeData();
const c8* p = &data[0];
if (sbuffer)
{
video::S3DVertex2TCoords vtx;
for (int i=0; i<vertexCount && *p; ++i)
{
// position
findNextNoneWhiteSpace(&p);
vtx.Pos.X = readFloat(&p);
findNextNoneWhiteSpace(&p);
vtx.Pos.Y = readFloat(&p);
findNextNoneWhiteSpace(&p);
vtx.Pos.Z = readFloat(&p);
// normal
findNextNoneWhiteSpace(&p);
vtx.Normal.X = readFloat(&p);
findNextNoneWhiteSpace(&p);
vtx.Normal.Y = readFloat(&p);
findNextNoneWhiteSpace(&p);
vtx.Normal.Z = readFloat(&p);
// color
findNextNoneWhiteSpace(&p);
sscanf(p, "%08x", &vtx.Color.color);
skipCurrentNoneWhiteSpace(&p);
// tcoord1
findNextNoneWhiteSpace(&p);
vtx.TCoords.X = readFloat(&p);
findNextNoneWhiteSpace(&p);
vtx.TCoords.Y = readFloat(&p);
// tcoord2
findNextNoneWhiteSpace(&p);
vtx.TCoords2.X = readFloat(&p);
findNextNoneWhiteSpace(&p);
vtx.TCoords2.Y = readFloat(&p);
sbuffer->Vertices.push_back(vtx);
}
}
}
示例2: ASSERT
PathSegmentData SVGPathByteStreamSource::parseSegment()
{
ASSERT(hasMoreData());
PathSegmentData segment;
segment.command = static_cast<SVGPathSegType>(readSVGSegmentType());
switch (segment.command) {
case PathSegCurveToCubicRel:
case PathSegCurveToCubicAbs:
segment.point1 = readFloatPoint();
/* fall through */
case PathSegCurveToCubicSmoothRel:
case PathSegCurveToCubicSmoothAbs:
segment.point2 = readFloatPoint();
/* fall through */
case PathSegMoveToRel:
case PathSegMoveToAbs:
case PathSegLineToRel:
case PathSegLineToAbs:
case PathSegCurveToQuadraticSmoothRel:
case PathSegCurveToQuadraticSmoothAbs:
segment.targetPoint = readFloatPoint();
break;
case PathSegLineToHorizontalRel:
case PathSegLineToHorizontalAbs:
segment.targetPoint.setX(readFloat());
break;
case PathSegLineToVerticalRel:
case PathSegLineToVerticalAbs:
segment.targetPoint.setY(readFloat());
break;
case PathSegClosePath:
break;
case PathSegCurveToQuadraticRel:
case PathSegCurveToQuadraticAbs:
segment.point1 = readFloatPoint();
segment.targetPoint = readFloatPoint();
break;
case PathSegArcRel:
case PathSegArcAbs: {
segment.arcRadii() = readFloatPoint();
segment.setArcAngle(readFloat());
segment.arcLarge = readFlag();
segment.arcSweep = readFlag();
segment.targetPoint = readFloatPoint();
break;
}
default:
ASSERT_NOT_REACHED();
}
return segment;
}
示例3: getTransformTranslate
/** ------------------------------------------------------------------------ **
* \internal *
* \brief Get a Translate Transform *
* *
* \param pDecISF structure used to decode the ISF file. *
* *
* \returns the error code given while processing *
** ------------------------------------------------------------------------ **/
int getTransformTranslate (decodeISF_t * pDecISF)
{
int err = OK;
transform_t * pTransform;
/**
* This tag consists of 2 values describing a translate transform matrix.\n
* Those two values are coded in the stream as floats (IEEE 754)\n
* We have in order:
* - dx
* - dy
*
* The transform matrix is :\n
* \f[
* \mbox{T} = \left( \begin{array}{ccc} 0 & 0 & \mbox{dx} \\ 0 & 0 & \mbox{dy} \\ 0 & 0 & 1\\ \end{array} \right)
* \f]
*
* In fact the transform matrix shouldn't be like that cause that
* transformation don't translate.\n
* Anyway, it seems to work this way with the .Net 3.0 framework ...
* The transform matrix should be :\n
* \f[
* \mbox{T} = \left( \begin{array}{ccc} \mbox{1} & 0 & \mbox{dx} \\ 0 & \mbox{1} & \mbox{dy} \\ 0 & 0 & 1\\ \end{array} \right)
* \f]
*/
/* Check whether we should add a transform or use the default one */
if (pDecISF->lastTransform != &(pDecISF->transforms) )
{
err = createTransform(&pTransform);
if (err != OK)
return err;
} else {
pTransform = *(pDecISF->lastTransform);
}
err = readFloat (pDecISF, &pTransform->m13);
if (err != OK) return err;
err = readFloat (pDecISF, &pTransform->m23);
if (err != OK) return err;
LOG(stdout,"(TRANSFORM_TRANSLATE) m13 = %f\n", pTransform->m13);
LOG(stdout,"(TRANSFORM_TRANSLATE) m23 = %f\n", pTransform->m23);
/* Insert the current Transform */
*(pDecISF->lastTransform) = pTransform;
pDecISF->lastTransform = &(pTransform->next);
return err;
}
示例4: readHotstartFile
void readHotstartFile(void)
//
// Input: none
// Output: none
// Purpose: reads initial state of all nodes and links from hotstart file.
//
{
int i, j;
long pos, size;
float x;
// --- check that file has correct size
pos = ftell(Fhotstart1.file);
fseek(Fhotstart1.file, 0L, SEEK_END);
size = ( ftell(Fhotstart1.file) - pos ) / sizeof(float);
if ( size < Nobjects[NODE] * (2 + 2*Nobjects[POLLUT]) +
Nobjects[LINK] * (3 + Nobjects[POLLUT]) )
{
report_writeErrorMsg(ERR_HOTSTART_FILE_READ, "");
return;
}
fseek(Fhotstart1.file, pos, SEEK_SET);
// --- read node states
for (i = 0; i < Nobjects[NODE]; i++)
{
if ( !readFloat(&x) ) return;
Node[i].newDepth = x;
if ( !readFloat(&x) ) return;
Node[i].newLatFlow = x;
for (j = 0; j < Nobjects[POLLUT]; j++)
{
if ( !readFloat(&x) ) return;
Node[i].newQual[j] = x;
}
// --- read in zero here for back compatibility
for (j = 0; j < Nobjects[POLLUT]; j++)
{
if ( !readFloat(&x) ) return;
}
}
// --- read link states
for (i = 0; i < Nobjects[LINK]; i++)
{
if ( !readFloat(&x) ) return;
Link[i].newFlow = x;
if ( !readFloat(&x) ) return;
Link[i].newDepth = x;
if ( !readFloat(&x) ) return;
Link[i].setting = x;
for (j = 0; j < Nobjects[POLLUT]; j++)
{
if ( !readFloat(&x) ) return;
Link[i].newQual[j] = x;
}
}
}
示例5: assert
void Noise::parse(vector<string> args) {
assert(args.size() < 3, "-noise takes zero, one, or two arguments\n");
float maxVal = 1;
float minVal = 0;
if (args.size() == 1) {
maxVal = readFloat(args[0]);
} else if (args.size() == 2) {
minVal = readFloat(args[0]);
maxVal = readFloat(args[1]);
}
apply(stack(0), minVal, maxVal);
}
示例6: assert
void Quantize::parse(vector<string> args) {
assert(args.size() <= 1, "-quantize takes zero or one arguments\n");
if (args.size()) apply(stack(0), readFloat(args[0]));
else apply(stack(0), 1);
}
示例7: writeOpcode
float
RemotePluginClient::getParameterDefault(int p)
{
writeOpcode(m_controlRequestFd, RemotePluginGetParameterDefault);
writeInt(m_controlRequestFd, p);
return readFloat(m_controlResponseFd);
}
示例8: while
WalkingEngineKick::Value* WalkingEngineKick::readValue(char*& buf)
{
while(*buf == ' ' || *buf == '\t')
++buf;
switch(*buf)
{
case '(':
{
++buf;
Value* result = readPlusFormula(buf);
while(*buf == ' ' || *buf == '\t')
++buf;
if(*buf != ')')
throw ParseException("expected ')'");
++buf;
return result;
}
case '$':
{
++buf;
unsigned int i = readUInt(buf);
return new ParameterValue(i, *this);
}
default:
{
float f = readFloat(buf);
return new ConstantValue(f, *this);
}
}
}
示例9: assert
bool BranchState::readFloat( Token::Argument& argument )
{
assert( argument.type() == Token::Argument::FLOAT_REGISTER );
if( argument.content() == Token::Argument::REGISTER )
{
return readFloat( argument.regNumber(), argument.fields() );
}
else if( argument.content() == Token::Argument::ALIAS )
{
std::map< std::string, State >::iterator i = m_floats.find( argument.alias() );
// has this alias been written already?
if( i == m_floats.end() )
return false;
// make sure no uninitialized portion of the alias is read
if( argument.fields() & (~(i->second.fields())) )
return false;
// update dependency information
updateDependency( argument, i->second, Alias::FLOAT, i->first, true );
}
else return false;
return true;
}
示例10: readInt
bool CCBReader::readSequences()
{
auto& sequences = _animationManager->getSequences();
int numSeqs = readInt(false);
for (int i = 0; i < numSeqs; i++)
{
CCBSequence *seq = new (std::nothrow) CCBSequence();
seq->autorelease();
seq->setDuration(readFloat());
seq->setName(readCachedString().c_str());
seq->setSequenceId(readInt(false));
seq->setChainedSequenceId(readInt(true));
if(!readCallbackKeyframesForSeq(seq)) return false;
if(!readSoundKeyframesForSeq(seq)) return false;
sequences.pushBack(seq);
}
_animationManager->setAutoPlaySequenceId(readInt(true));
return true;
}
示例11: nextToken
double TokenStream::readRational() {
Token t;
double val=readFloat();
if (!isEOF()) {
nextToken(t);
if (t.type == TT_SYMBOL && t.sval[0] == '/') {
double div=readFloat();
val /= div;
} else {
pushBack();
}
}
return val;
}
示例12: acoshf_cmd
static TACommandVerdict acoshf_cmd(TAThread thread,TAInputStream stream)
{
float x, res;
// Prepare
x = readFloat(&stream);
errno = 0;
START_TARGET_OPERATION(thread);
// Execute
res = acoshf(x);
END_TARGET_OPERATION(thread);
// Response
writeFloat(thread, res);
writeInt(thread, errno);
sendResponse(thread);
return taDefaultVerdict;
}
示例13: Exception
void MD5Model::readFrameEl(std::ifstream &fin, Anim &anim) {
// numAnimatedComponents has to have been set before frame element
if (0 == anim.numAnimatedComponents)
throw Exception("MD5Model::readFrameEl(): numAnimatedComponents must be set before 'frame' block");
// read frame index
int frameIndex = readInt(fin);
if (frameIndex < 0 || frameIndex >= anim.numFrames)
throw Exception("MD5Model::readFrameEl(): invalid frame index");
// get reference to frame and set number of animated components
Frame &frame = anim.frames[frameIndex];
frame.animatedComponents.resize(anim.numAnimatedComponents);
TOKEN t = getNextToken(fin);
// expect an opening brace { to begin block
if (t != TOKEN_LBRACE)
throw Exception("MD5Model::readFrameEl(): expected { to follow frame index");
for (int i = 0; i < anim.numAnimatedComponents; i++)
frame.animatedComponents[i] = readFloat(fin); // 刚好读取frame中的位置数加上方位数总flaot数
t = getNextToken(fin);
// expect a closing brace } to end block
if (t != TOKEN_RBRACE)
throw Exception("MD5Model::readFrameEl(): expected }");
}
示例14: readDouble
bool GTM::readTrackPoints( double& latitude, double& longitude,
GIntBig& datetime,
unsigned char& start, float& altitude)
{
/* Point to the actual trackpoint offset */
if ( VSIFSeekL(pGTMFile, actualTrackpointOffset, SEEK_SET) != 0)
return false;
/* Read latitude */
latitude = readDouble(pGTMFile);
/* Read longitude */
longitude = readDouble(pGTMFile);
/* Read trackpoint date */
datetime = readInt(pGTMFile);
if (datetime != 0)
datetime += GTM_EPOCH;
/* Read start flag */
if ( !readFile( &start, 1, 1 ) )
return false;
/* Read altitude */
altitude = readFloat(pGTMFile);
++trackpointFetched;
if (trackpointFetched < ntcks)
{
actualTrackpointOffset += 8 + 8 + 4 + 1 + 4;
}
return true;
}
示例15: diffuseColor
Material* SceneParser::parsePhongMaterial() {
char token[MAX_PARSER_TOKEN_LENGTH];
Vec3f diffuseColor(1, 1, 1);
Vec3f specularColor(0, 0, 0);
float exponent = 1;
getToken(token); assert(!strcmp(token, "{"));
while (1) {
getToken(token);
if (!strcmp(token, "diffuseColor")) {
diffuseColor = readVec3f();
}
else if (!strcmp(token, "specularColor")) {
specularColor = readVec3f();
}
else if (!strcmp(token, "exponent")) {
exponent = readFloat();
}
else {
assert(!strcmp(token, "}"));
break;
}
}
Material *answer = new PhongMaterial(diffuseColor, specularColor, exponent);
return answer;
}