How to apply CLOD to terrain

How do we apply LOD algorithms to terrain pages ? im asking this because the TerrainPage class isnt derived

from the TriMesh class .



thanks

Well, in the end TerrainPage consist other terrainpages and at the leafs it is TerrainBlocks again (which are TriMeshs).

All you would have to do is to traverse the TerrainPage-Tree and replace the TerrainBlocks by ClodObjects of the TerrainBlocks. Hi think I tried this once but afaik it looked quite ugly, especially at the edges of the terrainblocks. Actually I'm not sure if I really did it riight, so give it a try. (And tell about the result)



Keep on rocking

thanks

Ill give it a try .

rocha here is a method that returns clod of a terrain page but it has two problems

1- in the "not complete" section i didnt know exactly how to create a clod mesh from the terrain block and

2- the resulting terrain page doesnt act exactly  as a terrain page for example it doesnt have height information and

must be set






    TerrainPage getTerrainPageCLOD(TerrainPage tp) {

        TerrainPage clodPage = new TerrainPage();
        clodPage.setModelBound(tp.getWorldBound());
        clodPage.setSize(tp.getSize());
        clodPage.setSize(tp.getSize());
        clodPage.setStepScale(tp.getLocalScale());
        for (int i = 0; i < tp.getSize(); i++) {
            for (int j = 0; j < tp.getSize(); j++) {
                clodPage.setHeightMapValue(i, j, tp.getHeight(i, j));
            }
        }


        for (int i = 0; i < tp.getQuantity(); i++) {
            int size123 = tp.getSize();
            int quarterSize = size123 >> 2;

            if (tp.getChild(i).getClass() == new TerrainPage().getClass()) {
                TerrainPage temp = getTerrainPageCLOD((TerrainPage) tp.getChild(i));

                switch (i) {
                    case 0:
                        Vector2f offset = new Vector2f();
                        offset.x = tp.getLocalTranslation().getX();
                        offset.y = tp.getLocalTranslation().getY();


                        Vector3f origin1 = new Vector3f(-quarterSize * tp.getStepScale().x, 0,
                                -quarterSize * tp.getStepScale().z);


                        temp.setLocalTranslation(origin1);


                        break;
                    case 1:

                        Vector3f origin2 = new Vector3f(-quarterSize * tp.getStepScale().x, 0,
                                quarterSize * tp.getStepScale().z);

                        temp.setLocalTranslation(origin2);
                        break;
                    case 2:

                        Vector3f origin3 = new Vector3f(quarterSize * tp.getStepScale().x, 0,
                                -quarterSize * tp.getStepScale().z);

                        temp.setLocalTranslation(origin3);
                        break;
                    case 3:
                        Vector3f origin4 = new Vector3f(quarterSize * tp.getStepScale().x, 0,
                                quarterSize * tp.getStepScale().z);

                        temp.setLocalTranslation(origin4);
                        break;
                }

                // ==========================================================================
                clodPage.attachChild(temp);

            } else if (tp.getChild(0).getClass() == new TerrainBlock().getClass()) {  
                
                //===================== not complete
                AreaClodMesh acm = new AreaClodMesh("acm" + Math.random(), (TriMesh) (tp.getChild(i)), null);
                acm.setTrisPerPixel(0.02f);
                acm.setModelBound(new BoundingBox());
                acm.setLocalTranslation((tp.getChild(i)).getLocalTranslation());
                acm.updateModelBound();                            
                //=====================
                clodPage.attachChild(acm);
            }
        }
        return clodPage;

    }




a better aproach would be take the TerrainPage class source and make clod meshes directly there .