⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baseshapes.cpp

📁 file code.zip are used to implement ray tracing technology.
💻 CPP
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -