Sign in to follow this  
carl granberg

Developing a advanced 3D game engine

Recommended Posts

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[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);
}
}

// 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);
}
}
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?

Share this post


Link to post
Share on other sites
landlocked    103
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
landlocked    103
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?

Share this post


Link to post
Share on other sites
jyk    2094
Looks like this is a [url=http://www.gamedev.net/topic/602715-role-games-code/]cross-post[/url].

@The OP: I provided an answer in your other thread.

Share this post


Link to post
Share on other sites
Dwarf King    2126
[quote name='granberg' timestamp='1306174948' post='4814690']
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!
[/quote]

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this