kevlur

Members
  • Content count

    182
  • Joined

  • Last visited

Community Reputation

124 Neutral

About kevlur

  • Rank
    Member
  1. This should be of help for you: http://www.flipcode.com/articles/article_frustumculling.shtml
  2. Hi all, there are lots of book out there on AI for games; which is the best one that goes from beginning level to expert level, and which has C++ source example? Thanks in advance Kev
  3. quadtree questions

    I think AI and physics(gravity, speed...) should be apply to all the dynamic objects every frame, isn't it? So for AI and physics is impossible to cull any objects...
  4. quadtree questions

    Thanks for the explanation :) i thought about other things... The quadtree can be used either for collision detection, isn't it? But i cant use quadtree to cull objects for AI, for movements or for physics, cause , for example, if i cant see some enemy characters on the screen, i need always to move them, and to apply physics and AI to them, isn't it? So i can cull objects for the rendering and the collision detection, but i cant do it for physics, movement, and AI, is this right?
  5. quadtree questions

    to mrmrcoleman: yes im using it to cull the terrain chunks and the objects that are not in the same tree-node where the frustum bounding box is in. _Are there know problems in using the same quadtree for either objects and terrain? to ScootA: the idea to start checking the position of a dynamic object from its node parent is good:) i think the only thing that have to be added is the parent ID in the child node, isn't it? _Should i render only the node where is the frustum bounding box inside, or either the nearest nodes? Thanks for the help
  6. Hi all, im trying to implement a quadtree to manage the rendering of my objects, so can someone tell me if these thoughts that i have about it are right or wrong? 1. CreateQuadtree() (In the initialization of the program) create the quadtree with a default depth, and allocate the memory for all the nodes(all the nodes are empty now). 2. InitQuadtree()(Ever in the initialization of the program) load all the objects and all the terrain quads in the proper nodes.(Is it right to use the quadtree to manage either the terrain quads and the objects?) 3. Due to the fact that i have static and dynamic objects to take care of, i thought: i have already the static objects(like terrain quads, tree, buildings) in the proper nodes after the InitQuadtree() so i will not bother about their position (or should i do?), but i will track the position of the dynamic objects in the main loop (UpdateQuadtree()). (Will the processing of UpdateQuadtree() in the main loop slow down the frame rate too much?Is there another solution for the dynamic objects?) 4. Now is time to render: Should i render only the node inside of which is the frustum bounding box? or should i render either the nearest nodes? Thank you for any helps :) Kev
  7. Thanks very much Yann for the info :)
  8. Thanks for the info, but in that article the author calculate the frustum bounding sphere, and i need the frustum bounding box. How can i get the min and max points of the frustum bounding box? Thanks again
  9. Hi all, once i have the normal and the distance of my 6 planes that define the frustum, how can i get the frustum bounding box? Thanks Kev
  10. Frustum culling problem

    Thanks very much for the info:)
  11. Hi all, I've tried to implement frustum culling, but im having problem with the far plane of the frustum. As explained in http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf and on the website www.toymaker.info im doing like this(using C++ and Direct3D): struct TFrustumPlane /*Struct that define a frustum plane*/ { D3DXVECTOR3 m_normal; float m_distance; inline void Normalise() { float denom = 1 / sqrt((m_normal.x*m_normal.x) + (m_normal.y*m_normal.y) + (m_normal.z*m_normal.z)); m_normal.x = m_normal.x * denom; m_normal.y = m_normal.y * denom; m_normal.z = m_normal.z * denom; m_distance = m_distance * denom; } inline float DistanceToPoint(D3DXVECTOR3 &v) { return D3DXVec3Dot(&m_normal, &v) + m_distance; } }; TFrustumPlane m_frustumPlanes[6]; /* the 6 frustum planes */ void ExtractPlanes(void) /* Function that extract the 6 planes */ { /* and store each of them in */ D3DXMATRIXA16 matComb; /* a TFrustumPlane */ D3DXMatrixMultiply(&matComb, &viewMatrix, &projectionMatrix); // Left clipping plane m_frustumPlanes[0].m_normal.x = matComb._14 + matComb._11; m_frustumPlanes[0].m_normal.y = matComb._24 + matComb._21; m_frustumPlanes[0].m_normal.z = matComb._34 + matComb._31; m_frustumPlanes[0].m_distance = matComb._44 + matComb._41; // Right clipping plane m_frustumPlanes[1].m_normal.x = matComb._14 - matComb._11; m_frustumPlanes[1].m_normal.y = matComb._24 - matComb._21; m_frustumPlanes[1].m_normal.z = matComb._34 - matComb._31; m_frustumPlanes[1].m_distance = matComb._44 - matComb._41; // Top clipping plane m_frustumPlanes[2].m_normal.x = matComb._14 - matComb._12; m_frustumPlanes[2].m_normal.y = matComb._24 - matComb._22; m_frustumPlanes[2].m_normal.z = matComb._34 - matComb._32; m_frustumPlanes[2].m_distance = matComb._44 - matComb._42; // Bottom clipping plane m_frustumPlanes[3].m_normal.x = matComb._14 + matComb._12; m_frustumPlanes[3].m_normal.y = matComb._24 + matComb._22; m_frustumPlanes[3].m_normal.z = matComb._34 + matComb._32; m_frustumPlanes[3].m_distance = matComb._44 + matComb._42; // Near clipping plane m_frustumPlanes[4].m_normal.x = matComb._13; m_frustumPlanes[4].m_normal.y = matComb._23; m_frustumPlanes[4].m_normal.z = matComb._33; m_frustumPlanes[4].m_distance = matComb._43; // Far clipping plane m_frustumPlanes[5].m_normal.x = matComb._14 - matComb._13; m_frustumPlanes[5].m_normal.y = matComb._24 - matComb._23; m_frustumPlanes[5].m_normal.z = matComb._34 - matComb._33; m_frustumPlanes[5].m_distance = matComb._44 - matComb._43; m_frustumPlanes[0].Normalise(); m_frustumPlanes[1].Normalise(); m_frustumPlanes[2].Normalise(); m_frustumPlanes[3].Normalise(); m_frustumPlanes[4].Normalise(); m_frustumPlanes[5].Normalise(); } WORD cullAABB(const D3DXVECTOR3 &aabbMin, /* Test one AABB against the */ const D3DXVECTOR3 &aabbMax) /* frustum */ { bool intersect = FALSE; WORD result=0; D3DXVECTOR3 minExtreme,maxExtreme; for (WORD i=0;i<5;i++) { if (m_frustumPlanes[i].m_normal.x >= 0) { minExtreme.x = aabbMin.x; maxExtreme.x = aabbMax.x; } else { minExtreme.x = aabbMax.x; maxExtreme.x = aabbMin.x; } if (m_frustumPlanes[i].m_normal.y >= 0) { minExtreme.y = aabbMin.y; maxExtreme.y = aabbMax.y; } else { minExtreme.y = aabbMax.y; maxExtreme.y = aabbMin.y; } if (m_frustumPlanes[i].m_normal.z >= 0) { minExtreme.z = aabbMin.z; maxExtreme.z = aabbMax.z; } else { minExtreme.z = aabbMax.z; maxExtreme.z = aabbMin.z; } if((m_frustumPlanes[i].DistanceToPoint(minExtreme) < 0) && (m_frustumPlanes[i].DistanceToPoint(maxExtreme) < 0)) return 0; } return 1; } void FrustumCulling(void) /* Frustum culling :-) */ { int i = 0; D3DXVECTOR3 Min, Max; int inside = 0; ExtractPlanesD3D(); for(i = 0; i < NUMOBJ; i++) { OBJ[i].GetBoxMinMax(&Min, &Max); inside = cullAABB(Min, Max); if(inside) OBJ[i].InsideFrustum = 1; else OBJ[i].InsideFrustum = 0; } } This is the code i use and it works fine for all the clipping planes except for the far one; i know that it doesnt work with the far clipping plane cause ive put a rendered objects counter in the render() loop and even if i go far away from the objects (so far that they arent visible cause they are more far than the value i have set in D3DXMatrixPerspectiveFovLH for the far plane) and i look in direction of them, they are counted as rendered objects. For all the others 5 planes it works fine. Is there something wrong in the code where i extract the far plane normal and distance from the ViewProjection matrix? Is there something wrong in the function that test the AABB against a plane? Is there another way to get the far clipping plane normal and distance? Maybe extracting them from the others planes? What have i to do to know where is the problem? I am really stuck with this. I do appreciate whatever helps. Thanks in advance Kev
  12. Hi all, i've checked with DirectX Caps Viewer my video card(NVIDIA GeForce4 420 Go, with 32Mb) for vertex and pixel shaders version: VertexShaderVersion 1.1 MaxVertexShaderConst 96 PixelShaderVersion 0.0 PixelShader1xMaxValue 0 What can i do with this card? i think i cant use pixel shader, but what about vertex shader? it says Vertex Shader version 1.1, what can i do with this? So,can i use vertex shader in my D3D app? Until which level can i use vertex shader? What are the limitation if it is 1.1 and not 3.0? Really there isnt any pixel shader in my card? :( Thanks Kev
  13. Hi all, when i have a dialog box open, how can i get its current position? i need to know the min(x,y) and max(x,y) of the dialog box to test if the mouse cursor is over it. Thanks in advance Kev
  14. Thank you very much, but how can i obtain the 6 planes of the frustum? i remember something about getting them from a matrix...view matrix?...or projection matrix? Thanks again