Game Development Reference
In-Depth Information
Figure 10.13. Approximating cylinders with prisms of varying number of sides.
s t r u c t
V e r t e x
{
V e c t o r 3
po s ;
V e c t o r 3
n o r m a l ;
} ;
s t r u c t
T r i a n g l e
{
i n t
v e r t e x I n d e x [ 3 ] ;
V e c t o r 3
n o r m a l ;
} ;
s t r u c t
{
T r i a n g l e M e s h
i n t
v e r t e x C o u n t ;
V e r t e x
v e r t e x L i s t ;
i n t
t r i a n g l e C o u n t ;
T r i a n g l e
t r i a n g l e L i s t ;
v o i d
c o m p u t e V e r t e x N o r m a l s ( )
{
/ /
F i r s t
c l e a r
o u t
t h e
v e r t e x
n o r m a l s
f o r
( i n t
i
=
0
;
i < v e r t e x C o u n t
;
++ i )
{
v e r t e x L i s t [ i ] . n o r m a l . z e r o ( ) ;
}
/ / Now add
i n
t h e
f a c e
n o r m a l s
i n t o
t h e
/ /
n o r m a l s
o f
t h e
a d j a c e n t
v e r t i c e s
f o r
( i n t
i
=
0
;
i < t r i a n g l e C o u n t
;
++ i )
{
 
Search WWH ::




Custom Search