baseshapes.cpp

来自「file code.zip are used to implement ray 」· C++ 代码 · 共 65 行

CPP
65
字号
#include "BaseShapes.h"#include <float.h>void Cuboid::set(float l, float t, float r, float b, float f, float bk)    { left = l; top = t; right = r; bott = b; front = f; back = bk;}void Cuboid::set(Cuboid& c){    left = c.left;top = c.top; right = c.right; bott = c.bott;    front = c.front; back = c.back;}void Cuboid::print(){    cout << "\n(l,t,r,b,f,bk) = (" << left << "," << top << "," << right << ","    << bott << "," << front << "," << back << ")";}void SphereInfo::set(float x, float y, float z, float rsq){    center.set(x,y,z);    radSq = rsq;}GeomObj::GeomObj() : next(NULL) { name = "N/A"; }GeomObj::GeomObj(string NAME) : next(NULL) { name = NAME; }Shape::Shape() {}void Shape::setMaterial(Material mt) { mtrl = mt; }void Shape::tellMaterialsGL(){    float amb[4], diff[4], spec[4], emiss[4];    //Fill each array for use with openGL 'fv' functions	mtrl.ambient.build4tuple(amb);    mtrl.diffuse.build4tuple(diff);    mtrl.specular.build4tuple(spec);    mtrl.emissive.build4tuple(emiss);    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, amb);    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diff);    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);    glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, emiss);	glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, mtrl.specularExponent);}void Shape::xfrmRay(Ray &genRay, Ray r){    float v[4];    r.getStart().build4tuple(v);    invTransf.applyTransform(v);    genRay.setStart(v[0], v[1], v[2]);    r.getDir().build4tuple(v);    invTransf.applyTransform(v);    genRay.setDir(v[0], v[1], v[2]);    return;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?