本文整理汇总了C++中FileIO::readLine方法的典型用法代码示例。如果您正苦于以下问题:C++ FileIO::readLine方法的具体用法?C++ FileIO::readLine怎么用?C++ FileIO::readLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileIO
的用法示例。
在下文中一共展示了FileIO::readLine方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getShadingInfo
/**
* getShadingInfo
* Obtains the user information necessary to perform shading on the
* scene.
* Preconditions:
* The file to read from.
* The array to store the information.
* Postconditions:
* The array is filled:
* 0-2 - Light position.
* 3-5 - Ambient Light Color
* 6 - Linear attenuation
* 7 - Shininess
*/
void Picture::getShadingInfo( char* fileName, double s_array[] )
{
FileIO* inputFile = new FileIO(fileName, 1); //for reading
//eye vertex
string line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
s_array[0] = atof(line.c_str());
line = inputFile->readLine();
s_array[1] = atof(line.c_str());
line = inputFile->readLine();
s_array[2] = atof(line.c_str());
line = inputFile->readLine();
line = inputFile->readLine();
s_array[3] = atof(line.c_str());
line = inputFile->readLine();
s_array[4] = atof(line.c_str());
line = inputFile->readLine();
s_array[5] = atof(line.c_str());
line = inputFile->readLine();
line = inputFile->readLine();
s_array[6] = atof(line.c_str());
line = inputFile->readLine();
line = inputFile->readLine();
s_array[7] = atof( line.c_str() );
delete inputFile;
}
示例2: getPerspectiveTransform
Matrix* Picture::getPerspectiveTransform(char* fileName, int width, int height)
{
FileIO* inputFile = new FileIO(fileName, 1); //for reading
//fov
string line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double fov = atof(line.c_str());
double angle = 3.1415927*fov/180.0; //get the angle in radians
double xmax = tan(angle/2); //the width of the camera is determined by its fov
double ymax = xmax*(height)/(width); //the height of the camera is determined by the aspect ratio of the panel upon which the image will be rendered
//zmax
line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double zmax = atof(line.c_str());
//zmin
line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double zmin = atof(line.c_str());
Matrix* pn = AffineTransforms::perspectiveNorm(xmax, ymax, zmax, zmin);
delete inputFile;
return pn;
}
示例3: buildInstanceObject
InstanceObject* Picture::buildInstanceObject(char* fileName, BasicObject* obj)
{
InstanceObject* io = new InstanceObject(obj);
FileIO* inputFile = new FileIO(fileName, 1); //for reading
//scale transformation
string line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double sx = atof(line.c_str());
line = inputFile->readLine();
double sy = atof(line.c_str());
line = inputFile->readLine();
double sz = atof(line.c_str());
Matrix* scale = AffineTransforms::scale(sx, sy, sz);
//rotation transformations
line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double rx = atof(line.c_str());
Matrix* rotX = AffineTransforms::rotateX(rx);
line = inputFile->readLine();
double ry = atof(line.c_str());
Matrix* rotY = AffineTransforms::rotateY(ry);
line = inputFile->readLine();
double rz = atof(line.c_str());
Matrix* rotZ = AffineTransforms::rotateZ(rz);
//translation transformation
line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double tx = atof(line.c_str());
line = inputFile->readLine();
double ty = atof(line.c_str());
line = inputFile->readLine();
double tz = atof(line.c_str());
Matrix* translate = AffineTransforms::translate(tx, ty, tz);
//standard TRS form
io->buildTransform(scale); //deletes the matrix when done
io->buildTransform(rotX);
io->buildTransform(rotY);
io->buildTransform(rotZ);
io->buildTransform(translate);
delete inputFile;
return io;
}
示例4: getZValues
/**
* getZValues
* Obtain the values for fov and zmax/zmin.
* Preconditions:
* The filename to read from.
* The array to store the information.
* Postconditions:
* The array is filled:
* 0 - fov
* 1 - zmax
* 2 - zmin
*/
void Picture::getZValues( char* fileName, double zs[] )
{
FileIO* inputFile = new FileIO(fileName, 1); //for reading
//eye vertex
string line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
zs[0] = atof(line.c_str());
line = inputFile->readLine();
line = inputFile->readLine();
zs[1] = atof(line.c_str());
line = inputFile->readLine();
line = inputFile->readLine();
zs[2] = atof(line.c_str());
delete inputFile;
}
示例5: buildCamera
/**
* buildCamera
* Obtain user information needed to create the camera.
* Preconditions:
* The filename to be read from.
* The vertex for the eye point.
* Postconditions:
* Returns a Matrix pointer that holds the camera's info.
* Modifies the eye point vertex to the eye point.
*/
Matrix* Picture::buildCamera(char* fileName, Vertex* eye, Vertex* at)
{
FileIO* inputFile = new FileIO(fileName, 1); //for reading
//eye vertex
string line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double ex = atof(line.c_str());
line = inputFile->readLine();
double ey = atof(line.c_str());
line = inputFile->readLine();
double ez = atof(line.c_str());
eye->setX( ex );
eye->setY( ey );
eye->setZ( ez );
//at vertex
line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double ax = atof(line.c_str());
line = inputFile->readLine();
double ay = atof(line.c_str());
line = inputFile->readLine();
double az = atof(line.c_str());
at->setX( ax );
at->setY( ay );
at->setZ( az );
//up vector
line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double ux = atof(line.c_str());
line = inputFile->readLine();
double uy = atof(line.c_str());
line = inputFile->readLine();
double uz = atof(line.c_str());
Vector* up = new Vector(ux, uy, uz);
Matrix* camera = AffineTransforms::buildCamera( eye, at, up );
delete up;
delete inputFile;
return camera;
}
示例6: getCameraTransform
Matrix* Picture::getCameraTransform(char* fileName)
{
FileIO* inputFile = new FileIO(fileName, 1); //for reading
//eye point
string line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double ex = atof(line.c_str());
line = inputFile->readLine();
double ey = atof(line.c_str());
line = inputFile->readLine();
double ez = atof(line.c_str());
//at point
line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double ax = atof(line.c_str());
line = inputFile->readLine();
double ay = atof(line.c_str());
line = inputFile->readLine();
double az = atof(line.c_str());
//up vector
line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double ux = atof(line.c_str());
line = inputFile->readLine();
double uy = atof(line.c_str());
line = inputFile->readLine();
double uz = atof(line.c_str());
Vertex* eye = new Vertex(ex, ey, ez);
Vertex* at = new Vertex(ax, ay, az);
Vector* up = new Vector(ux, uy, uz);
Matrix* camera = AffineTransforms::cameraTransform(eye, at, up);
delete eye;
delete at;
delete up;
delete inputFile;
return camera;
}
示例7: getShaderInfo
void Picture::getShaderInfo(Vertex *eye, Color *ambient, Light *light, double *attenuation)
{
double x, y, z;
Vertex *lightPOS;
FileIO* file = new FileIO("camera.txt", 1);
string line;
line = file->readLine();
line = file->readLine();
eye->setX(atof(line.c_str()));
line = file->readLine();
eye->setY(atof(line.c_str()));
line = file->readLine();
eye->setZ(atof(line.c_str()));
delete file;
file = new FileIO("shade.txt", 1);
line = file->readLine();
line = file->readLine();
x = atof(line.c_str());
line = file->readLine();
y = atof(line.c_str());
line = file->readLine();
z = atof(line.c_str());
lightPOS = new Vertex(x, y, z);
light->setLocation(lightPOS);
line = file->readLine();
line = file->readLine();
ambient->setRed(atof(line.c_str()));
line = file->readLine();
ambient->setGreen(atof(line.c_str()));
line = file->readLine();
ambient->setBlue(atof(line.c_str()));
line = file->readLine();
line = file->readLine();
*attenuation = atof(line.c_str());
delete file;
}
示例8: FileIO
Vector *Picture::readCamera(double *eX, double *eY, double *eZ, double *aX, double *aY, double *aZ)
{
Vector *vUp;
FileIO* inputFile = new FileIO("camera.txt", 1);
//eye points
string line = inputFile->readLine();
line = inputFile->readLine();
*eX = atof(line.c_str());
line = inputFile->readLine();
*eY = atof(line.c_str());
line = inputFile->readLine();
*eZ = atof(line.c_str());
//at points
line = inputFile->readLine();
line = inputFile->readLine();
*aX = atof(line.c_str());
line = inputFile->readLine();
*aY = atof(line.c_str());
line = inputFile->readLine();
*aZ = atof(line.c_str());
//vUp
double x, y, z;
line = inputFile->readLine();
line = inputFile->readLine();
x = atof(line.c_str());
line = inputFile->readLine();
y = atof(line.c_str());
line = inputFile->readLine();
z = atof(line.c_str());
vUp = new Vector(x, y, z);
return vUp;
}
示例9: readFOV
void Picture::readFOV(double *zMax, double *zMin, double *fov)
{
FileIO *inputFile = new FileIO("fov.txt", 1);
string line = inputFile->readLine();
line = inputFile->readLine();
*fov = atof(line.c_str());
line = inputFile->readLine();
line = inputFile->readLine();
*zMax = atof(line.c_str());
line = inputFile->readLine();
line = inputFile->readLine();
*zMin = atof(line.c_str());
}
示例10: buildInstanceObject
/**
* Reads a file to build an InstanceObject object.
* Written by Dr. Boshart
* Modified by Thomas Shaffer
*/
InstanceObject* Picture::buildInstanceObject(char* fileName, BasicObject* obj)
{
InstanceObject* io = new InstanceObject(obj);
FileIO* inputFile = new FileIO(fileName, 1); //for reading
char* f1 = (char*)malloc(255*sizeof(char));
char* f2 = (char*)malloc(255*sizeof(char));
//scale transformation
string line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double sx = atof(line.c_str());
line = inputFile->readLine();
double sy = atof(line.c_str());
line = inputFile->readLine();
double sz = atof(line.c_str());
Matrix* scale = AffineTransforms::scale(sx, sy, sz);
//rotation transformations
line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double rx = atof(line.c_str());
Matrix* rotX = AffineTransforms::rotateX(rx);
line = inputFile->readLine();
double ry = atof(line.c_str());
Matrix* rotY = AffineTransforms::rotateY(ry);
line = inputFile->readLine();
double rz = atof(line.c_str());
Matrix* rotZ = AffineTransforms::rotateZ(rz);
//translation transformation
line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double tx = atof(line.c_str());
line = inputFile->readLine();
double ty = atof(line.c_str());
line = inputFile->readLine();
double tz = atof(line.c_str());
Matrix* translate = AffineTransforms::translate(tx, ty, tz);
//standard TRS form
io->buildTransform(scale); //deletes the matrix when done
io->buildTransform(rotX);
io->buildTransform(rotY);
io->buildTransform(rotZ);
io->buildTransform(translate);
// Material
line = inputFile->readLine();
line = inputFile->readLine();
double red = atof(line.c_str());
line = inputFile->readLine();
double green = atof(line.c_str());
line = inputFile->readLine();
double blue = atof(line.c_str());
Color* color = new Color( red, green, blue );
io->setColor( color );
// Texture
string t_string = string("texture");
line = inputFile->readLine();
//if ( strcmp( line.c_str(), t_string.c_str() ) ) {
line = inputFile->readLine();
const char* file = line.c_str();
strcpy( f1, file );
line = inputFile->readLine();
const char* file2 = line.c_str();
strcpy( f2, file2 );
line = inputFile->readLine();
int width = atoi( line.c_str() );
line = inputFile->readLine();
int height = atoi( line.c_str() );
Texture *tex = new Texture( f1, width, height );
Texture *norm = new Texture( f2, width, height );
io->setTexture( tex );
io->setNormal( norm );
//}
delete inputFile;
return io;
}
示例11: buildInstanceObject
InstanceObject* Picture::buildInstanceObject(char* fileName, BasicObject* obj)
{
InstanceObject* io = new InstanceObject(obj);
FileIO* inputFile = new FileIO(fileName, 1); //for reading
//scale transformation
string line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double sx = atof(line.c_str());
line = inputFile->readLine();
double sy = atof(line.c_str());
line = inputFile->readLine();
double sz = atof(line.c_str());
Matrix* scale = AffineTransforms::scale(sx, sy, sz);
//rotation transformations
line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double rx = atof(line.c_str());
Matrix* rotX = AffineTransforms::rotateX(rx);
line = inputFile->readLine();
double ry = atof(line.c_str());
Matrix* rotY = AffineTransforms::rotateY(ry);
line = inputFile->readLine();
double rz = atof(line.c_str());
Matrix* rotZ = AffineTransforms::rotateZ(rz);
//translation transformation
line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double tx = atof(line.c_str());
line = inputFile->readLine();
double ty = atof(line.c_str());
line = inputFile->readLine();
double tz = atof(line.c_str());
Matrix* translate = AffineTransforms::translate(tx, ty, tz);
//material
line = inputFile->readLine(); //skip this line
line = inputFile->readLine();
double mr = atof(line.c_str());
line = inputFile->readLine();
double mg = atof(line.c_str());
line = inputFile->readLine();
double mb = atof(line.c_str());
Color* mat = new Color(mr, mg, mb);
io->setDiffuseMaterial(mat);
//standard TRS form
io->buildTransform(scale); //deletes the matrix when done
io->buildTransform(rotX);
io->buildTransform(rotY);
io->buildTransform(rotZ);
io->buildTransform(translate);
//Get shininess
FileIO* shaderFile = new FileIO("shade.txt", 1);
line = shaderFile->readLine();
line = shaderFile->readLine();
line = shaderFile->readLine();
line = shaderFile->readLine();
line = shaderFile->readLine();
line = shaderFile->readLine();
line = shaderFile->readLine();
line = shaderFile->readLine();
line = shaderFile->readLine();
line = shaderFile->readLine();
line = shaderFile->readLine();
line = shaderFile->readLine();
io->setShininess(atof(line.c_str()));
delete shaderFile;
delete inputFile;
return io;
}