zoukankan
html css js c++ java
Writing REYES
#include
<
queue
>
class
BaseQueue
{
public
:
virtual
void
push(
void
*
newItem )
=
0
;
}
;
class
e_Object
{
public
:
//
attributes:
float
max_displace;
}
;
class
GeoPrim
{
public
:
virtual
void
bound()
=
0
;
virtual
bool
on_screen()
=
0
;
virtual
bool
projectable()
=
0
;
virtual
void
project()
=
0
;
virtual
bool
on_bucket()
=
0
;
virtual
bool
diceable()
=
0
;
virtual
void
dice()
=
0
;
virtual
void
split( BaseQueue
*
queue )
=
0
;
public
:
e_Object
*
obj;
Bound6f box;
}
;
class
RasterObject
{
public
:
bool
is_grid();
public
:
GeoPrim
*
object
;
//
the geometric primitive
int
flags;
//
the object flags
float
zmin;
//
the minimum z coordinate of the object (used for occlusion culling)
}
;
class
ShadingGrid :
public
RasterObject
{
public
:
void
shade();
void
sample();
public
:
float
*
vertices;
//
array of vertices
int
*
bounds;
//
the bound of the primitive (4 numbers per primitive)
float
*
sizes;
//
the size of the primitive (only makes sense for points)
float
umin, umax, vmin, vmax;
//
the parametric range
int
udiv, vdiv;
//
the number of division
int
numVertices;
//
the number of vertices
int
flags;
//
the primitive flags
}
;
class
GeoPrimQueue :
public
BaseQueue
{
public
:
//
implemented for BaseQueue
void
push(
void
*
newItem )
{
gp_queue.push( (GeoPrim
*
) newItem );
}
GeoPrim
*
get
()
{
GeoPrim
*
gprim
=
NULL;
if
(
!
gp_queue.empty() )
{
gprim
=
gp_queue.front();
gp_queue.pop();
}
return
gprim;
}
private
:
std::queue
<
GeoPrim
*
>
gp_queue;
}
;
//
priority queue
class
RasterObjectQueue :
public
BaseQueue
{
public
:
RasterObjectQueue(
int
ss
=
100
)
{
stepSize
=
ss;
maxItems
=
stepSize;
numItems
=
1
;
allItems
=
new
RasterObject
*
[maxItems];
}
~
RasterObjectQueue()
{
delete [] allItems;
}
//
implemented for BaseQueue
void
push(
void
*
newItem )
{
insert( (RasterObject
*
) newItem );
}
void
insert( RasterObject
*
cObject )
{
int
i,j;
//
expand the buffer
if
(numItems
>=
maxItems)
{
RasterObject
**
newItems;
maxItems
+=
stepSize;
newItems
=
new
RasterObject
*
[maxItems
+
1
];
memcpy( newItems, allItems, numItems
*
sizeof
(RasterObject
*
) );
delete [] allItems;
allItems
=
newItems;
stepSize
*=
2
;
}
//
insert the item
i
=
numItems
++
;
j
=
i
>>
1
;
while
((i
>
1
)
&&
(cObject
->
zmin
<
allItems[j]
->
zmin))
{
allItems[i]
=
allItems[j];
i
=
j;
j
=
i
>>
1
;
}
allItems[i]
=
cObject;
}
RasterObject
*
get
()
{
int
i
=
1
, j;
RasterObject
*
lItem,
*
cItem;
if
(numItems
<=
1
)
{
cItem
=
NULL;
}
else
{
cItem
=
allItems[
1
];
numItems
--
;
lItem
=
allItems[numItems];
while
(i
<=
numItems
/
2
)
{
j
=
2
*
i;
if
(j
>=
numItems)
break
;
if
((j
<
(numItems
-
1
))
&&
(allItems[j]
->
zmin
>
allItems[j
+
1
]
->
zmin))
j
++
;
if
(allItems[j]
->
zmin
>
lItem
->
zmin)
break
;
allItems[i]
=
allItems[j];
i
=
j;
}
allItems[i]
=
lItem;
}
return
cItem;
}
RasterObject
**
allItems;
//
array of the heap
int
numItems, maxItems, stepSize;
//
misc junk
}
;
class
Reyes
{
public
:
void
render();
}
;
void
Reyes::render()
{
GeoPrimQueue gp_queue;
GeoPrim
*
gprim
=
NULL;
while
( (gprim
=
gp_queue.
get
())
!=
NULL )
{
//
bound in camera space
//
(including displacement and motion blur)
gprim
->
bound();
//
frustum culling and backface culling
if
( gprim
->
on_screen() )
{
//
the bound can be transformed into screen space
if
( gprim
->
projectable() )
{
//
transform the bound into screen space
//
(including depth of field)
//
sort the gprim into buckets which its bound covers
gprim
->
project();
}
else
{
//
too large, divide and conquer
//
add back to the queue
gprim
->
split(
&
gp_queue );
}
}
delete gprim;
}
}
void
Bucket::render()
{
RasterObjectQueue gp_queue;
RasterObject
*
gprim
=
NULL;
while
( (gprim
=
gp_queue.
get
())
!=
NULL )
{
//
bound in camera space
//
(including displacement and motion blur)
gprim
->
bound();
//
frustum culling and backface culling
//
occlusion culling
//
transform the bound into screen space
//
(including depth of field)
if
( gprim
->
on_bucket() )
{
//
is a grid, draw it
if
( gprim
->
is_grid() )
{
ShadingGrid
*
grid
=
(ShadingGrid
*
) gprim;
//
evaluate
//
displacement shader
//
surface shader
//
light shader
//
atmosphere shader
grid
->
shade();
//
stitch cracks between micropolygon grids
//
bust into individual micropolygons
//
bound each micropolygon
//
frustum culling and backface culling
//
occlusion culling
//
determine which pixels the micropolygons
//
cover and stochastic sampling in pixels
grid
->
sample();
}
else
{
//
small enough to dice
if
( gprim
->
diceable() )
{
//
dice into grids
gprim
->
dice();
}
else
{
//
too large, divide and conquer
//
add back to the queue
gprim
->
split(
&
gp_queue );
}
}
}
}
//
reconstruct the image portion of this bucket
}
查看全文
相关阅读:
VScode出现无法打开“X”: 找不到文件(file:///XXXX) 的解决办法
Re:0通过服务器自建内网穿透远程桌面(10分钟可完成)
(补题 POJ 3013) Big Christmas Tree
(补题 cf 1140)Detective Book
(2019.9.5~2019.9.11)补题汇总(字符串相关)
最小生成树(克鲁斯卡尔算法)
最短路问题
字符串匹配(部分整理)
Linux内核分析——第八周学习笔记
《Linux内核设计与实现》第四章读书笔记
原文地址:https://www.cnblogs.com/len3d/p/1197217.html
最新文章
express 快速教程
一个简单的 MVVM 实现
jQuery 插件基础
在requirejs中使用qunit
CSS3 动画实现 animation 和 transition 比较
简单的 Promise 实现
关于 JavaScript prototype __proto__ 一点总结
JavaScript 为什么要通过原型 prototype 调用函数, 而不是直接调用?
python笔记27(CRM4)
python笔记26(爬虫进阶)
热门文章
python笔记26(selenuim和phantonJs)
python笔记25(爬虫基础)
python笔记24(CRM3)
python笔记23(CRM2)
python笔记22(CRM1)
Python笔记19(Django中auth模块的用法)
Python笔记19(Django中form与model form的用法)
Python笔记19(Django中admin的简单用法)
(补题 CF 250A)Paper Work
(补题 HDU 1068 )Girls and Boys(二分图最大匹配)
Copyright © 2011-2022 走看看