当前位置: 首页 > wzjs >正文

网站开发费用报价表百度企业公司网站建设

网站开发费用报价表百度,企业公司网站建设,建筑工程网络计划称为,视频制作公司拍摄Camera类 我们之前学了很多的图形学知识和相关的程序,现在我们停下脚步,来好好整理一下我们学习的内容,我们将之前的视口代码和渲染代码合并到一个新的单类camera.h,这个类主要负责两项任务: 构建并发射光线到世界中 …
Camera类

我们之前学了很多的图形学知识和相关的程序,现在我们停下脚步,来好好整理一下我们学习的内容,我们将之前的视口代码和渲染代码合并到一个新的单类camera.h,这个类主要负责两项任务:

  • 构建并发射光线到世界中

  • 使用光线的信息来构建渲染图像

这次的重构,我们收集以下几个功能:

  • ray_color()

  • 图像设置

  • 相机设置

  • 渲染

新的相机类将包含两个公有方法:initialize()render() 以及两个私有辅助方法 get_ray()ray_color()

相机类的设计应该遵循尽可能的简单的方式,让我们在后续使用时操作尽可能的简单,使用默认构造函数,且避免复杂的初始化过程。同时允许用户通过直接赋值改变公共变量,避免复杂的setter方法。并且在渲染函数开始时,自动的调用initialize()操作,避免用户操作的复杂性。

现在我们先搭建其camera类的框架:

​
#ifndef RENDER_C___CAMERA_H
#define RENDER_C___CAMERA_H
#include "hittable.h"
class camera{
public://这里设置公有的属性void render(const hittable& world){}
private://这里放置私有的属性void initialize(){ }color ray_color(const ray&r,const hittable& world) const{}  
};
#endif //RENDER_C___CAMERA_H

然后一一将我们的方法和属性完善首先是将main中的上色部分ray_color移动到里面

class camera {...private:...color ray_color(const ray& r, const hittable& world) const {hit_record rec;
​if (world.hit(r, interval(0, infinity), rec)) {return 0.5 * (rec.normal + color(1,1,1));}
​vec3 unit_direction = unit_vector(r.direction());auto a = 0.5*(unit_direction.y() + 1.0);return (1.0-a)*color(1.0, 1.0, 1.0) + a*color(0.5, 0.7, 1.0);}
};
#endif

然后还有剩下的相机的建立和图像的设置也移动到里面:

#ifndef RENDER_C___CAMERA_H
#define RENDER_C___CAMERA_H
​
#include "hittable.h"
​
class camera{
public:double aspect_radio = 1.0;      //图像的宽高比int    image_width = 100;       //图像宽度的像素数
​void render(const hittable& world){initialize();
​std::cout << "P3\n" << image_width << " " << image_height << "\n255\n";for(int j=0;j<image_height;j++){std::clog << "\rScanlines remaining: " << (image_height - j) << ' ' << std::flush;for(int i=0;i<image_width;i++){auto pixel_center = pixel00_loc + (i*pixel_delta_u) + (j*pixel_delta_v);auto ray_direction = pixel_center - camera_center;ray r(camera_center,ray_direction);
​color pixel_color = ray_color(r,world);write_color(std::cout,pixel_color);}}std::clog << "\rDone.                   \n";}
​
private:int image_height;       //渲染图像的高度point3 camera_center;   //相机的中心point3 pixel00_loc;     //像素(0,0)的位置vec3 pixel_delta_u;     //向右的偏移值vec3 pixel_delta_v;     //向下的偏移值
​void initialize(){image_height = int(image_width/aspect_radio);image_height = (image_height < 1) ? 1 : image_height;
​camera_center = point3 (0,0,0);
​//确认视窗的设置auto focal_length = 1.0;    //焦距设置auto viewport_height = 2.0;auto viewport_width = viewport_height*(double (image_width)/image_height);
​//视图边缘的向量计算auto viewport_u = vec3(viewport_width,0,0);auto viewport_v = vec3(0,-viewport_height,0);//计算视图的像素间的水平竖直增量pixel_delta_u = viewport_u/image_width;pixel_delta_v = viewport_v/image_height;//计算左上角第一个像素中心的坐标auto viewport_upper_left = camera_center - vec3(0,0,focal_length) - viewport_v/2 - viewport_u/2;pixel00_loc = viewport_upper_left + 0.5*(pixel_delta_u+pixel_delta_v);}
​color ray_color(ray & r,const hittable& world){hit_record rec;if(world.hit(r,interval(0,infinity),rec)){return 0.5*(rec.normal + color(1,1,1));}
​vec3 unit_direction = unit_vector(r.direction());auto a = 0.5*(unit_direction.y()+1.0);return (1.0 - a)*color(1.0,1.0,1.0) + a*color(0.5,0.7,1.0);}
};
​
#endif //RENDER_C___CAMERA_H

我们使用新的类来实现对main函数的简化:

#include "rtweekend.h"
​
#include "camera.h"
#include "hittable.h"
#include "hittable_list.h"
#include "sphere.h"
​
int main(){hittable_list world;world.add(make_shared<sphere>(point3(0,0,-1),0.5));world.add(make_shared<sphere>(point3(0,-100.5,-1),100));
​camera cam;
​cam.aspect_radio = 16.0/9.0;cam.image_width = 800;
​cam.render(world);
}

这样的操作极大的简化了后续我们的图形的渲染,你看这是渲染出来的放大版:

image.png

那么这一章就到此为止啦

http://www.dtcms.com/wzjs/419103.html

相关文章:

  • 网站建设费用明细报告长沙互联网网站建设
  • linux做网站好互联网营销怎么做
  • 哪里有免费网站空间申请抖音seo软件
  • 上海平台网站建设公司浏览器搜索引擎大全
  • 宁波方太集团网站建设湖南网络推广机构
  • 中国网站设计模板湖南seo优化哪家好
  • 网络营销是什么系福州seo代理计费
  • 网站做推广页需要什么软件有哪些网站管理和维护的主要工作有哪些
  • uc投放广告网站要自己做吗培训总结怎么写
  • 怎么做垂直自营网站人民日报今日头条新闻
  • b站视频播放量网站湖南网站营销seo方案
  • 通信建设工程项目经理查询网站外贸独立站推广
  • 网站项目评价西安网站seo公司
  • 做视频网站审核编辑有假么百度竞价推广登录
  • 网站数据库维护都是做什么南京百度推广
  • 外围网站代理怎么做无代码网站开发平台
  • 中国建设银行龙网站首页长春seo顾问
  • iis 网站拒绝显示此网页中国制造网
  • wordpress图片站免费关键词排名优化
  • 深圳公司网站搭建公司孔宇seo
  • 北京移动端网站百度收录提交申请网站
  • 游戏网站建设一条龙网站设计报价方案
  • 如何在网站发广告百度认证平台官网
  • 网站建设服务英文西安网站外包
  • 西安行业网站建设属于免费的网络营销方式
  • 宠物网站设计模板北京网站建设公司案例
  • 大学学风建设网站西安百度推广外包
  • 珠海建设局网站首页优化营商环境条例心得体会
  • 青岛做网站的公司seo是什么
  • 常州网站运营公司百度收录提交