What you want to do (to start with) is sample the cube from the reflection vector of the surface using the ‘Vertex Reflection’ node. In this example I have also made the alpha be based on an alpha from a texture and set the blend mode to be srcalpha / oneminussourcealpha (so you can configure the alpha from the texture), and also given the windows a ‘blue’ hint in the albedo. It’s nothing amazing, but it’s a decent start for some glass. You will need to set the queue to transparent if you want to use this shader also.
数学的内容基本都在前面图形相关的文里面谈到了,当然碰撞检测以及物理相关都没有涉及(较早的时候有参考过《Real Time Collision Detection》写过一些碰撞检测的代码,但时间太久,换电脑把代码倒腾丢了,具体内容也忘得差不多了,基本上就是OBB,AABB,Capsule,Sphere,Plane,Triangle,Ray,Segment之间的各种关系判定,求解特定交点等等)。
// dfs for (unsignedint i = 0; i < n->children.size(); ++i) { Node* child = n->children[i];
dfs(child); }
n->color = GREEN; };
intmain(int args, char** argv) { int data = 0, req = 0; cin >> data; string s1, s2; // 建树 Node* father = NULL; Node* son = NULL; while (data > 0) { cin >> s1 >> s2; auto it1 = myhash.find(s1); auto it2 = myhash.find(s2);
if (it1 == myhash.end()) { father = new Node(s1); myhash.insert(pair<string, Node*>(s1, father)); } else { father = it1->second; }
if (it2 == myhash.end()) { son = new Node(s2); myhash.insert(pair<string, Node*>(s2, son)); } else { son = it2->second; }
son->parent = father; son->represent = father; // a son has only one father. Not check here. father->children.push_back(son); data--; } // 确定所有人的根(根据题目说明,所有人都有一个公共祖先) while (son->parent) son = son->parent; root = son; // Query collection cin >> req; while (req > 0) { cin >> s1 >> s2;
auto it1 = myhash.find(s1); auto it2 = myhash.find(s2);
假定我们想要移动空间中的某一个点,假如我们想要把位于[x, y, z]的点平移[l,m,n]到达[x', y' z'],也就是[x', y', z'] = [x, y, z] + [l, m, n] => {x' = x + l, y' = y + m, z' = z + n}。我们可以通过一个四维向量和一个4x4的矩阵来进行这一计算:
1 2 3 4 5
//trans | 1000 | | x, y, z, 1 | * | 0100 | = | x + l, y + m, z + n, 1 | | 0010 | | l m n 1 |
现在回顾起来,我对于CPP的偏爱应该是有那么点“斯德哥尔摩综合症”在里面的:我所在本科学校的编程语言教学是直接从CPP上手的,大概学校是考量到了CPP囊括了C的原因。于是我在并未体会到C的简洁优雅的情况下就被动去接触繁复浩杂的CPP(对,我也不是主动去接触CPP的)——在没有一点编程的认知下便开始了“所谓”的OO概念的灌输,结果可想而知:写CPP程序期间各种百思不解,特别是CPP里面资源管理的复杂性使我一败涂地,甚至用不了模板出手。我那可怜的在没有任何框架帮助下的本科小毕设大概也就那么3k行不到就使我有了那种“无力感”——我很清楚的记得最后程序跑起来时给我的那种无法言喻的 “WTF, It works?!” 的感觉。后面我又断断续续的写一些东西,然而无论怎么写,一旦没有了Framework的支撑,我对于代码掌控能力就降了不止一个档次。
struct StatePolicyA { StatePolicyA() { // do save policy A printf("Save states with Policy A\n"); } ~StatePolicyA() { // do restore printf("Restore states with Policy A\n"); } };
struct StatePolicyB { StatePolicyB() { // do save policy B printf("Save states with Policy B\n"); } ~StatePolicyB() { // do restore printf("Restore states with Policy B\n"); } };
struct ModuleB { voidinterface1() { printf("Module B interface 1\n"); } voidinterface2() { printf("Module B interface 2\n"); } };
struct ModuleA { // other functions ModuleB m_moduelB;
C++ templates are essentially language-aware macros. Each instance generates a different refinement of the same code. —— from notes of 'Programming Languages and Translators', Fall 2012, Columbia University.
voidprintCfunc(vvfunc* tb, int index) { if (index < 0 || index >= 4) { printf("Exception : index out of range!\n"); return; } tb[index](); // call func }