《Focus On 3D Terrain Programming》中一段代码的注释二
bool CTERRAIN::MakeTerrainFault( int iSize, int iIterations, int iMinDelta, int iMaxDelta, float fFilter )
{
......
.............
for( iCurrentIteration=; iCurrentIteration<iIterations; iCurrentIteration++ )
{
//calculate the height range (linear interpolation from iMaxDelta to iMinDelta) for this fault-pass
iHeight= iMaxDelta - ( ( iMaxDelta-iMinDelta )*iCurrentIteration )/iIterations; //pick two points at random from the entire height map
iRandX1= rand( )%m_iSize;
iRandZ1= rand( )%m_iSize; //check to make sure that the points are not the same
do
{
iRandX2= rand( )%m_iSize;
iRandZ2= rand( )%m_iSize;
} while ( iRandX2==iRandX1 && iRandZ2==iRandZ1 ); //iDirX1, iDirZ1 is a vector going the same direction as the line
iDirX1= iRandX2-iRandX1;
iDirZ1= iRandZ2-iRandZ1; for( z=; z<m_iSize; z++ )
{
for( x=; x<m_iSize; x++ )
{
//iDirX2, iDirZ2 is a vector from iRandX1, iRandZ1 to the current point (in the loop)
iDirX2= x-iRandX1;
iDirZ2= z-iRandZ1; //if the result of ( iDirX2*iDirZ1 - iDirX1*iDirZ2 ) is "up" (above 0),
//then raise this point by iHeight
if( ( iDirX2*iDirZ1 - iDirX1*iDirZ2 )> )
fTempBuffer[( z*m_iSize )+x]+= ( float )iHeight;
}
}
//erode terrain
FilterHeightField( fTempBuffer, fFilter );
}
.......
..............
return true;
}
===================
《Focus On 3D Terrain Programming》中一段代码的注释二的更多相关文章
- 《Focus On 3D Terrain Programming》中一段代码的注释三
取自<Focus On 3D Terrain Programming>中的一段: //--------------------------------------------------- ...
- 《Focus On 3D Terrain Programming》中一段代码的注释一
取自<Focus On 3D Terrain Programming>中的一段: //--------------------------------------------------- ...
- 【鸡渣饲料系列】《Introdution to 3D Game Programming With DirectX11》 代码转移至vs2015
<Introdution to 3D Game Programming With DirectX11>我是从这本书学习的directx,被称为“龙书”dx11版,由于是通过这本书学习的所以 ...
- bootstrap 中这段代码 使bundles 失败
_:-ms-fullscreen, :root input[type="date"], _:-ms-fullscreen, :root input[type="time& ...
- SQL SERVER中如何查找存储过程中一段代码
select b.name ,a.text from syscomments a,sysobjects b where and object_id(b.name)=a.id and b.xtype i ...
- phpstorm 代码注释后,撤销某段代码的注释的,快捷键是什么?
phpstorm 的代码注释有两种风格,一种是双斜杠,另一种是 /* ... */风格,两者的快捷键都是开关式(即按第一次为注释,再按一次为撤销注释),快捷键如下: 1.双斜杠注释 Ctrl + ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第七章:在Direct3D中绘制(二)
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第七章:在Direct3D中绘制(二) 代码工程地址: https:/ ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第六章:在Direct3D中绘制
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第六章:在Direct3D中绘制 代码工程地址: https://gi ...
- Introduction to 3D Game Programming with DirectX 11 翻译--开篇
Direct3D 11简介 Direct3D 11是一个渲染库,用于在Windows平台上使用现代图形硬件编写高性能3D图形应用程序.Direct3D是一个windows底层库,因为它的应用程序编程接 ...
随机推荐
- 安装MVC3后没有dbcontext生成器的解决方案
安装MVC3后,采用DBFIRS的方式,从数据库生成模型,这样生成的类是基于ObjectContext的,无法使用DbContext的一些方法,比如Set.Find.Entry等.需要用ADO.NET ...
- [LeetCode]题解(python):118-Excel Sheet Column Title
题目来源 https://leetcode.com/problems/excel-sheet-column-title/ Given a positive integer, return its co ...
- jQuery获取自身HTML
<html><head> <title>jQuery获取自身HTML</title> <meta http-equiv="Content ...
- mysql中varchar(50)最多能存多少个汉字
首先要确定mysql版本4.0版本以下,varchar(50),指的是50字节,如果存放UTF8汉字时,只能存16个(每个汉字3字节) 5.0版本以上,varchar(50),指的是50字符,无论存放 ...
- LeetCode Perfect Squares
原题链接在这里:https://leetcode.com/problems/perfect-squares/ 题目: Given a positive integer n, find the leas ...
- js基础的总结
js中的每个函数都含有一个内建的arguments数组,能够返回函数接受的所有参数,不管函数有没有定义参数. function add() { var sum = 0; for (var i = 0; ...
- 在定位中,如何清除已经设置好的bottom
这个东西其实很简单,将bottom设auto,便可在设置top的值,那么具体的应用是什么?目前一个是用于全屏,二是用于输入框在手机端的下半屏(被输入发遮挡问题)? 例子如下 css代码: * { ma ...
- JQuery:JQuery设置HTML
JQuery:设置HTML1.Query - 设置内容和属性设置内容 - text().html() 以及 val()我们将使用前一章中的三个相同的方法来设置内容: text() - 设置或返回所选元 ...
- 判断远程图片是否存在【适用于windows服务器】
<?php function file_exists2($url) { if(@file_get_contents($url,0,null,0,1)) return 1; else return ...
- 第四篇 Integration Services:增量加载-Updating Rows
本篇文章是Integration Services系列的第四篇,详细内容请参考原文. 回顾增量加载记住,在SSIS增量加载有三个使用案例:1.New rows-add rows to the dest ...