Changeset 2925 for GTP/trunk


Ignore:
Timestamp:
09/10/08 08:29:37 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp

    r2924 r2925  
    209209        /////////////// 
    210210        //-- We apply the lispsm algorithm in order to calculate an optimal light projection matrix 
    211  
    212  
    213         //////// 
    214211        //-- first find the free parameter values n, and P (the projection center), and the projection depth 
    215212 
    216         const float n = 1e6;//ComputeN(bounds_ls); 
     213        //const float n = 1e6f; 
     214        const float n = ComputeN(bounds_ls); 
    217215 
    218216        cout << "n: " << n << endl; 
     
    230228 
    231229        // the new projection center 
    232         Vector3 projCenter = startPt + Vector3::UNIT_Z() * n; 
     230        Vector3 projCenter = startPt + Vector3::UNIT_Z() * n * 1000; 
    233231 
    234232        cout <<"start: " << startPt << " " << projCenter << " " << Distance(lightSpace * mCamera->GetPosition(), startPt) << endl; 
     
    268266} 
    269267 
    270  
     268#if 0 
    271269Vector3 ShadowMap::GetNearCameraPointE(const VertexArray &pts) const 
    272270{ 
     271        float maxDist = -1e25f; 
     272        Vector3 nearest = Vector3::ZERO(); 
     273 
     274        Matrix4x4 eyeView; 
     275        mCamera->GetModelViewMatrix(eyeView); 
     276 
     277        VertexArray newPts; 
     278        polyhedron->CollectVertices(newPts); 
     279         
     280        //the LVS volume is always in front of the camera 
     281        VertexArray::const_iterator it, it_end = pts.end();      
     282 
     283        for (it = pts.begin(); it != it_end; ++ it) 
     284        { 
     285                Vector3 pt = *it; 
     286                Vector3 ptE = eyeView * pt; 
     287//cout<<"i"<< pt.z; 
     288                if (ptE.z > 0) cerr <<"should not happen " << ptE.z << endl; 
     289                else 
     290                if (ptE.z > maxDist) 
     291                { 
     292                        cout << " d " << ptE.z; 
     293         
     294                        maxDist = ptE.z; 
     295                        nearest = pt; 
     296                } 
     297        } 
     298 
     299        //      Invert(eyeView); return eyeView * nearest; 
     300        return nearest; 
     301} 
     302 
     303#else 
     304 
     305Vector3 ShadowMap::GetNearCameraPointE(const VertexArray &pts) const 
     306{ 
     307        VertexArray newPts; 
     308        polyhedron->CollectVertices(newPts); 
     309 
    273310        Vector3 nearest = Vector3::ZERO(); 
    274311        float minDist = 1e25f; 
     
    276313        const Vector3 camPos = mCamera->GetPosition(); 
    277314 
    278         /*Matrix4x4 inverseCamView; 
    279         mCamera->GetModelViewMatrix(invervseCamView); 
    280         inverseCamView.Invert();*/ 
    281  
    282         VertexArray::const_iterator it, it_end = pts.end(); 
    283  
    284         for (it = pts.begin(); it != it_end; ++ it) 
     315        VertexArray::const_iterator it, it_end = newPts.end(); 
     316 
     317        for (it = newPts.begin(); it != it_end; ++ it) 
    285318        { 
    286319                Vector3 pt = *it; 
     
    298331} 
    299332 
     333#endif 
    300334 
    301335Vector3 ShadowMap::GetProjViewDir(const Matrix4x4 &lightSpace, const VertexArray &pts) const  
     
    376410        //calculate a frame matrix that uses the projViewDir[lightspace] as up vector 
    377411        //look(from position, into the direction of the projected direction, with unchanged up-vector) 
    378         Matrix4x4 frame = LookAt(Vector3::ZERO(), projViewDir, Vector3::UNIT_Y()); 
     412        const Matrix4x4 frame = LookAt(Vector3::ZERO(), projViewDir, Vector3::UNIT_Y()); 
    379413 
    380414        cout << "frame\n " << frame << endl; 
     
    386420                CalcLispSMTransform(lightView * lightProj, extremalPoints, frustumPoints); 
    387421 
    388         Vector3 mydummy = Vector3::UNIT_Z(); 
    389  
    390         cout << "yoyo: " << Normalize(lightView * lightProj * mydummy) << endl; 
     422        Vector3 mydummy = projViewDir;//Vector3::UNIT_Z(); 
     423        //cout << "transformed unit z vector: " << Normalize(lightView * lightProj * mydummy) << endl; 
     424        cout << "transformed unit z vector: " << Normalize(frame * mydummy) << endl; 
     425 
    391426        lightProj = lightProj * matLispSM; 
    392427 
     
    537572        ////////////// 
    538573        //-- compute texture matrix 
     574 
    539575        static Matrix4x4 biasMatrix(0.5f, 0.0f, 0.0f, 0.5f, 
    540576                                                                0.0f, 0.5f, 0.0f, 0.5f, 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2914 r2925  
    7070int renderMode = RenderTraverser::CHCPLUSPLUS; 
    7171// eye near plane distance 
    72 float nearDist = 0.2f;  
     72float nearDist = 2.0f;  
    7373/// the field of view 
    7474float fov = 50.0f; 
Note: See TracChangeset for help on using the changeset viewer.