Sign in to follow this  
carl granberg

Role playing code

Recommended Posts

There is some code experts from jim adams's book Programming Role playing games
if(Size > m_MaxSize && Num > m_MaxPolygons) {
for(i=0;i<(unsigned long)((m_TreeType==QUADTREE)?4:8);i++) {
XOff = (((i % 2) < 1) ? -1.0f : 1.0f) * (Size / 4.0f);
ZOff = (((i % 4) < 2) ? -1.0f : 1.0f) * (Size / 4.0f);
YOff = (((i % 8) < 4) ? -1.0f : 1.0f) * (Size / 4.0f);

// See if any polygons in new node bounding box
if(CountPolygons(XPos+XOff,YPos+YOff,ZPos+ZOff,Size/2.0f)) {

Node->Nodes[i] = new sNode(); // Create new child node

// Sort the polygons with the new child node
SortNode(Node->Nodes[i],XPos+XOff,YPos+YOff,ZPos+ZOff,Size/2.0f);
}
}
does someone undertstand why we caculate the Xoff and Yoff and ZOff as this way,try to explain that code very detail don't use the depth math than I can undertstand !

Share this post


Link to post
Share on other sites
Evil Steve    2017
Please don't [url="http://www.gamedev.net/topic/602715-role-games-code/page__p__4814737#entry4814737"]Cross Post[/url] on these forums.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this