资源简介
光线追踪算法应用的一个小场景,图形学的朋友结业作业可以进来看看
代码片段和文件信息
#include
#include
#include “rt.h“
#include “rtlib.h“
object objs [NUM_OBJS];
LIGHT lights [NUM_LIGHTS];
int obj_num = 4;
VEC_PT normalize (VEC_PT vec)
{
/*** find length of vec; scale vec by length; return new vec ***/
double len;
len = sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z);
vec.x = vec.x/len;
vec.y = vec.y/len;
vec.z = vec.z/len;
return vec;
}
double vec_len(VEC_PT vec)
{
double len;
len = sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z);
return len;
}
double dot (VEC_PT v1 VEC_PT v2)
{
/*** return result of dot product formula ***/
double dot_res;
dot_res = v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
return dot_res;
}
VEC_PT substract (VEC_PT vec1 VEC_PT vec2)
{
vec1.x = vec1.x - vec2.x;
vec1.y = vec1.y - vec2.y;
vec1.z = vec1.z - vec2.z;
return vec1;
}
VEC_PT add (VEC_PT vec1 VEC_PT vec2)
{
vec1.x = vec1.x + vec2.x;
vec1.y = vec1.y + vec2.y;
vec1.z = vec1.z + vec2.z;
return vec1;
}
VEC_PT multipy_cons (double cons VEC_PT vec)
{
vec.x = vec.x * cons;
vec.y = vec.y * cons;
vec.z = vec.z * cons;
return vec;
}
COLOR add_color (COLOR c1 COLOR c2)
{
c1.R = c1.R + c2.R;
c1.G = c1.G + c2.G;
c1.B = c1.B + c2.B;
return c1;
}
COLOR cap_color_to_one (COLOR c)
{
if(c.R > 1)
c.R = 1;
if(c.G >1)
c.G = 1;
if(c.B > 1)
c.B = 1;
return c;
}
void define_scene (void)
{
/*** define all objects (location type color) and lights here ***/
objs [0].sph_ctr.x = 0.5;
objs [0].sph_ctr.y = 0.8;
objs [0].sph_ctr.z = 4.0;
objs [0].object_type = SPHERE;
objs [0].sph_radius = 0.5;
objs [0].color.R = 1;
objs [0].color.G = 0;
objs [0].color.B = 0;
objs [1].sph_ctr.x = -0.5;
objs [1].sph_ctr.y = 0.15;
objs [1].sph_ctr.z = 4.2;
objs [1].object_type = SPHERE;
objs [1].sph_radius = 0.6;
objs [1].color.R = 0;
objs [1].color.G = 1;
objs [1].color.B = 0;
objs [2].plane_normal.x = 0;
objs [2].plane_normal.y = 1;
objs [2].plane_normal.z = 0;
objs [2].object_type = PLANE;
objs [2].plane_D = 0.9;
objs [2].color.R = 0.3;
objs [2].color.G = 0.3;
objs [2].color.B = 0.3;
objs [2].color2.R = 1;
objs [2].color2.G = 1;
objs [2].color2.B = 1;
objs [3].box_ll.x = 0.3;
objs [3].box_ll.y = -0.6;
objs [3].box_ll.z = 2.3;
objs [3].box_ur.x = 0.7;
objs [3].box_ur.y = -0.2;
objs [3].box_ur.z = 3.0;
objs [3].object_type = BOX;
objs [3].color.R = 0;
objs [3].color.G = 0;
objs [3].color.B = 1;
lights [0].location.x = -10;
lights [0].location.y = 10;
lights [0].location.z = -5;
lights[0].color.R = 1.0;
lights[0].color.G = 1.0;
lights[0].color.B = 1.0;
lights [1].location.x = 0;
lights [1].location.y = 10;
lights [1].location.z = -10;
lights[1].color.R = 1.0;
lights[1].color.G = 1.0;
lights[1].color.B =
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-04-03 09:10 pj2_normal\
文件 346 2012-02-07 04:23 pj2_normal\Makefile
文件 64935 2012-02-08 10:29 pj2_normal\pj2-f.jpg
文件 2515854 2012-02-07 12:59 pj2_normal\pj2-f.ppm
文件 7539 2012-02-07 12:59 pj2_normal\rt.c
文件 927 2012-02-07 05:43 pj2_normal\rt.h
文件 225 2012-02-07 04:23 pj2_normal\rtlib.h
文件 6312 2012-02-07 04:23 pj2_normal\rtlib.o
- 上一篇:微信公众号扫码自动回复文字和合成海报
- 下一篇:图书管理系统数据库设计报告
相关资源
- MSCOMM32.OCX等控件注册 适用于win7和xp
- dimm 200pin pcb 封装
-
解决The type org.springfr
amework.dao.supp - annotations_KAIST_testset.tar
- BB Black EMMC烧写全记录
- TextCNN在文本分类的应用.pptx
- Intercultural Communication 讲义 .pdf
- An Introduction to Parallel Programming by Pet
- ADMM优化算法讲解
- so-dimm 200pin封装尺寸
- import org.apache.commons.io.IOUtils
- OpenNI_NITE_Installer-win32-0.27
- Unity开发MMO游戏泰斗破坏神教学视频及
- unnamed.txt
- Huffman与Shannon-Fano编码实验报告
- 代码FastRcnn
- 重写Spinner类,实现点击后弹出带有确
- 一份不错的对称分量法教材
- Programming Abstractions in C 的源码
- PersonnelManage.rar
- commons.css
- CMMI3访谈问题库及答案
- LoadRunner视频,LoadRunner学习视频
- HMM学习范例教程(全集)
- KMeans GMM
- NopCommerce用户后台操作手册一
- mask_rcnn训练模型pb文件转pbtxt文件
- KNN手写识别代码
- VC的MSCOMM控件
- S7ImgRD(用手机读卡器给mmc卡解密)
评论
共有 条评论