Developing a advanced 3D game engine

Started by
6 comments, last by Dwarf King 12 years, 11 months ago
if you read the book programming role playing games,you must remember the function as below:
if(Size > m_MaxSize && Num > m_MaxPolygons) {
for(i=0;i<(unsigned long)((m_TreeType==QUADTREE)?4:8);i++) {
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 = new sNode(); // Create new child node

// Sort the polygons with the new child node
SortNode(Node->Nodes,XPos+XOff,YPos+YOff,ZPos+ZOff,Size/2.0f);
}
}

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

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

// Sort the polygons with the new child node
SortNode(Node->Nodes,XPos+XOff,YPos+YOff,ZPos+ZOff,Size/2.0f);
}
}
Ok so jog your mind what 's mean with thease code?:
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);

please explain thease code to me special on how to caculate the xOff and ZOff and YOff value,tell me where they come?

Advertisement
If you got that from a book it should explain in there. Reread the chapters carefully. It helps me if I take notes as a read to make sure my eyes don't gloss over and I stay alert and focused on what I'm reading.
Always strive to be better than yourself.
can you use the code tags please :)
it makes it easyer to read your post
:) :) :)

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.

Your guys don't know the expalin of thease code is so rude for me,I read that section again again,but no words can give me a way to slove it understand it!so don,t delay my time,just to explain it that is all!
Here's the thing... without the code we can't explain. Software is highly context specific. We're not going to go out to buy the book just to answer your question either. Is there a URL provided in the book that you could use to contact the author?
Always strive to be better than yourself.
Looks like this is a cross-post.

@The OP: I provided an answer in your other thread.
Its a double cross post. He has the same question in two other posts too.

Your guys don't know the expalin of thease code is so rude for me,I read that section again again,but no words can give me a way to slove it understand it!so don,t delay my time,just to explain it that is all!


The way I see it no one in this thread tries to "delay your time". I see nice people trying to help you. Perhaps you should reconsider the way you communicate with the helpful people. After all they are helping you without getting paid for it(and that is a very noble thing to do). Also you should use Landlocked's advice.

"The only thing that interferes with my learning is my education"

Albert Einstein

"It is a miracle that curiosity survives formal education"

Albert Einstein

This topic is closed to new replies.

Advertisement