depthtest only one side

Started by
12 comments, last by daniel_i_l 18 years ago
I made sure that the tiles are rendered in the proper order and gave all the root nodes a std vector of trees. But I have a problem with the Multitexturing (detail texture), before I rendered the terrain first with the multitexture and then did the trees, but now I'm drawing the trees for each tile after that tile so I always have to turn the multitexture of and then on again, I'm not sure how to do that - Here is the main render function that turns on the MT and then draws the terrain, and then the trees:
void CBspTree :: RenderMap(){   if(!p_HeightMap) return;           number_of_parts=0;   Frustum.CalculateFrustum();   glLoadIdentity();   Camera.Look();    glActiveTextureARB(GL_TEXTURE0_ARB);    glEnable(GL_TEXTURE_2D);    glBindTexture(GL_TEXTURE_2D, g_Texture[0]);    if(g_bDetail)    {        glActiveTextureARB(GL_TEXTURE1_ARB);        glEnable(GL_TEXTURE_2D);                glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);        glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2);        glBindTexture(GL_TEXTURE_2D, g_Texture[1]);            glMatrixMode(GL_TEXTURE);            glLoadIdentity();            glScalef((float)g_DetailScale, (float)g_DetailScale, 1);        glMatrixMode(GL_MODELVIEW);    }    Render(map);  //render the map + trees           // Turn the second multitexture pass off    glActiveTextureARB(GL_TEXTURE1_ARB);    glDisable(GL_TEXTURE_2D);    // Turn the first multitexture pass off    glActiveTextureARB(GL_TEXTURE0_ARB);            glDisable(GL_TEXTURE_2D);} 


and here's the Render(map):
void CBspTree :: Render(BSP* node){  //if((node->is_leaf) && (Frustum.BoxInFrustum( node->centerX, node->centerY, node->centerZ, 32, 50, 32 )) )  if(node->is_leaf)   {      glColor3f(1,1,1);            if(Frustum.BoxInFrustum( SCALE_SIDE*node->centerX, node->centerY, SCALE_SIDE*node->centerZ, node->height/2, (SCALE_SIDE*node->width)/2, (SCALE_SIDE*node->depth)/2))     {              RenderHeightMap(p_HeightMap, (int)(node->centerX - node->width/2), (int)(node->centerZ - node->depth/2),                                    (int)(node->centerX + node->width/2), (int)(node->centerZ + node->depth/2) );       number_of_parts++;       //draw trees with tree texture       sort(node->MyTrees.begin(), node->MyTrees.end());       for(int i=0; i<node->MyTrees.size(); i++)       {        node->MyTrees.rotation = Camera.BillBoard(node->MyTrees.position);        node->MyTrees.Render();       }     }   }  else   {    if(Frustum.BoxInFrustum( SCALE_SIDE*node->p_sec1->centerX, node->p_sec1->centerY, SCALE_SIDE*node->p_sec1->centerZ, node->p_sec1->height/2, (SCALE_SIDE*node->p_sec1->width)/2, (SCALE_SIDE*node->p_sec1->depth)/2))      Render(node->p_sec1);     if(Frustum.BoxInFrustum( SCALE_SIDE*node->p_sec2->centerX, node->p_sec2->centerY, SCALE_SIDE*node->p_sec2->centerZ, node->p_sec2->height/2, (SCALE_SIDE*node->p_sec2->width)/2, (SCALE_SIDE*node->p_sec2->depth)/2))      Render(node->p_sec2);     if(Frustum.BoxInFrustum( SCALE_SIDE*node->p_sec3->centerX, node->p_sec3->centerY, SCALE_SIDE*node->p_sec3->centerZ, node->p_sec3->height/2, (SCALE_SIDE*node->p_sec3->width)/2, (SCALE_SIDE*node->p_sec3->depth)/2))      Render(node->p_sec3);     if(Frustum.BoxInFrustum( SCALE_SIDE*node->p_sec4->centerX, node->p_sec4->centerY, SCALE_SIDE*node->p_sec4->centerZ, node->p_sec4->height/2, (SCALE_SIDE*node->p_sec4->width)/2, (SCALE_SIDE*node->p_sec4->depth)/2))      Render(node->p_sec4);    }}

I did this and the terrain didn't show up at all, amd some of the trees were textured with the ground? How do I solve this problem? (and alternate between multitexture and regular, as a think that thats the problem)
Thanks.
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
Advertisement
Quote:Original post by daniel_i_l
Thanks, and about the sorting you proposed - if I'm rendering the terrain as a quadtree were the rendering function is a recusive function that splits into 4 and does the render function on each part (which are split into 4) untill the function gets a "leaf" node which it renders. So to do the sorting would it work if every time I split a node into 4, I pass the new nodes to the render function in front to back order?
Thanks.



sure, what can probably do is program your quad transversal to check what side of the current tree node the camera is on, then transverse the children nodes in different order depending on that
and heres a cool idea, if the camera is totally outside of the region a node covers, then all of its children nodes can be transversed in the same ordering as it, without having to do the camera direction check for them as well -big saving
Thanks, and what about the multitexture problem, how do I fix that?
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
anyone?
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky

This topic is closed to new replies.

Advertisement