摘要: 代码地址:https://github.com/sdlwlxf1/tinyEngine 终于实现了自己的软渲染器,图形学的学习暂时告一段落。代码参考知乎上的韦易笑大神的回答,自己加入了很多功能包括: 将原来的Gouraud着色改为phong着色 加入一个平行光和4个点光源,物体材质 背面剔除 利用l 阅读全文
posted @ 2017-03-12 23:57 sdlwlxf 阅读(4012) 评论(2) 推荐(3) 编辑
摘要: 构造函数和析构函数中的虚函数 在执行基类构造函数时,对象的派生类部分是未初始化的。实际上,此时对象还不是一个派生类对象。 为 了适应这种不完整,编译器将对象的类型视为在构造或析构期间发生了变化。在基类构造函数或析构函数中,将派生类对象当作基类类型对象对待。 如果在构造函数或析构函数中调用虚函数,则运 阅读全文
posted @ 2016-03-29 21:42 sdlwlxf 阅读(763) 评论(0) 推荐(0) 编辑
摘要: 看了云风关于protected的思考,自己也总结了下。 C++的访问权限有三个 private、protected、public。 如果不包括继承的话,比较好理解,可以分为类外和类内两部分。类外不能访问private,可以访问public。 这里注意访问限制是相对于类的,而不是对象。下面这个例子可以 阅读全文
posted @ 2016-03-29 20:53 sdlwlxf 阅读(983) 评论(1) 推荐(0) 编辑
摘要: 堆排序整理如下,函数中有重复代码,为了避免多一次函数调用。 重点是堆的下滤操作 阅读全文
posted @ 2016-03-27 19:55 sdlwlxf 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 把二元查找树转变成排序的双向链表题目:输入一棵二元查找树,将该转换成个排 序的双向链表。要求不能创建任何新的结点,只调整指针向。 10 / \ 6 14 / \ / \ 4 8 12 8转换成双向链表4=6=8=10=12=14=16 利用中序遍历来解决比较简单,这里我主要提供一种非递归版本来解决这 阅读全文
posted @ 2016-02-28 16:32 sdlwlxf 阅读(190) 评论(0) 推荐(0) 编辑
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. Subscribe to see which companies asked this question 阅读全文
posted @ 2016-02-28 14:23 sdlwlxf 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, flatten it to a linked list in-place. For example,Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 \ 3 \ 4 阅读全文
posted @ 2016-02-28 13:04 sdlwlxf 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only 阅读全文
posted @ 2016-02-27 21:22 sdlwlxf 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. F 阅读全文
posted @ 2016-02-27 20:40 sdlwlxf 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 最近在开发一款类似消消乐的三消游戏,在碰到实现斜方向下落的时候卡住了很长时间。好几天没有思路,原本的思路是一次性预判多个宝石的一连串运动路径,运用缓动运动队列来实现宝石运动路径,例如 下落->滑落->下落。用这种方式虽然会提高性能,但发现总是无法预判所有宝石运动路径,可能性太多了,比如某一个宝石的下 阅读全文
posted @ 2016-02-20 17:21 sdlwlxf 阅读(3007) 评论(0) 推荐(0) 编辑