Hi!

I have used the example of osgterrain but, even if the skirt is not visualized anymore,
now my terrain is flat (as in the attached figure).
besides the colors should be used with the gradations, from the tallest altitude to the lowest.
how can I get these results?


Thanks
Aurora


Robert Osfield ha scritto:
Hi Aurora,

You code is going off on the wrong track.  Don't use ShapeDrawable
here at all, don't try returning a osg::Geode.  You should be
returning the osgTerrain::Terrain, this is the node you should be
concentrating.  Please look at the osgterrain example.

Robert.

On Feb 20, 2008 12:48 PM, aurora restivo <[EMAIL PROTECTED]> wrote:
Hi Robert,

I send you the code with the new changes... unfortunately the result
doesn't change...
the plan around the terrain has not disappeared.

the object terrainTechnique that you have recommended me is necessary to
color the terrain?

Thanks
Aurora



Robert Osfield ha scritto:
Hi Aurora,

To assign the no data value do:

   hfLayer->setValidDataOperator(new osgTerrain::NoDataValue(0.0f));

Also you shouldn't need a ShapeDrawable when you are using
osgTerrain::Terrain, but you will need to assign a TerrainTechnique
that will be used to render the terrain.  See osgterrain example.

Robert.

On Feb 20, 2008 10:51 AM, aurora restivo <[EMAIL PROTECTED]> wrote:

Hi!

I apologize but I have not understood well.
I have need to draw the ground that is in the file terrain.jpg without
the plan that is visualized around.
I don't understand as I must use the NoDataValue.

Besides I also have problems to color the terrain.
My objective is to draw a terrain with a casting of washes.

Can you recommend me a book where to find a good documentation for my
specific problem?

Thanks
Aurora Restivo.

<<inline: out.JPG>>

#pragma once

#include <osgTerrain/Terrain>
#include <osgTerrain/GeometryTechnique>

#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgGA/KeySwitchMatrixManipulator>
#include <osgGA/StateSetManipulator>
#include <osgGA/AnimationPathManipulator>
#include <osgGA/TerrainManipulator>

class Morfologia
{
public:
        Morfologia(void);
        ~Morfologia(void);

        osgTerrain::Terrain* drawMorfologia();
};


#include ".\morfologia.h"
#include ".\gestionematrix.h"

#include <iostream>
#include <cstdlib>

#include <osg/Vec3d>
#include <osg/Texture2D>
#include <osgDB/ReadFile>


#include <osgTerrain/Locator>
#include <osgTerrain/Terrain>
#include <osgTerrain/ValidDataOperator>
#include <osgTerrain/Layer>
#include <osgTerrain/GeometryTechnique>

#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgGA/KeySwitchMatrixManipulator>
#include <osgGA/StateSetManipulator>
#include <osgGA/AnimationPathManipulator>
#include <osgGA/TerrainManipulator>


        Morfologia::Morfologia(void)
        {
        }

        Morfologia::~Morfologia(void)
        {
        }


        osgTerrain::Terrain* Morfologia::drawMorfologia()
        {
                GestioneMatrix* g=new GestioneMatrix();
                
                int** m= g->leggiFile("morf0.txt");
                
                int** nicchia=g->leggiFile("nicchia0.txt");

                int max= g->cercaMax(m);
                int min= g->cercaMin(m);
                
                osg::HeightField* hF = new osg::HeightField();
                hF->allocate(296,410);
                
                for(int i=0; i< 410; i++)
                {
                        for(int j=0; j<296 ;j++)
                        {
                                if(m[i][j]!=0)
                                        hF->setHeight(j,i, 
m[i][j]+nicchia[i][j]);
                        }
                }

                hF->setXInterval(41.0);
                hF->setYInterval(29.6);
                
                osg::Quat* quat=  new osg::Quat(0,0,180,45);
                hF->setRotation(*quat); 
                

                osgTerrain::Terrain* terrainNode= new osgTerrain::Terrain();
                osgTerrain::HeightFieldLayer* hFLayer= new 
osgTerrain::HeightFieldLayer();
                hFLayer->setHeightField(hF);
                
                
                //LOCATOR
                double x = 0.0;
                double y = 0.0;
                double w = 1.0;
                double h = 1.0;

                osgTerrain::Locator* locator = new osgTerrain::Locator;
                
locator->setCoordinateSystemType(osgTerrain::Locator::GEOCENTRIC);
                locator->setTransformAsExtents(x, y, w, h);
                
                hFLayer->setLocator(locator);
                //fine locator

                //GESTIONE DEGLI '0'
                osgTerrain::ValidDataOperator* dataO= new 
osgTerrain::NoDataValue(0.0f);
                hFLayer->setValidDataOperator(dataO);
                //FINE GESTIONE DEGLI '0'
                
                terrainNode->setElevationLayer(hFLayer);
                
                //COLORI
                osg::ref_ptr<osg::TransferFunction1D> tf = new 
osg::TransferFunction1D;
            
            tf->setInputRange(min, max);
            
            tf->allocate(6);
            tf->setValue(0, osg::Vec4(1.0,1.0,1.0,1.0));
            tf->setValue(1, osg::Vec4(1.0,0.0,1.0,1.0));
            tf->setValue(2, osg::Vec4(1.0,0.0,0.0,1.0));
            tf->setValue(3, osg::Vec4(1.0,1.0,0.0,1.0));
            tf->setValue(4, osg::Vec4(0.0,1.0,1.0,1.0));
            tf->setValue(5, osg::Vec4(0.0,1.0,0.0,1.0));
                        
            terrainNode->setColorTransferFunction(0, tf.get());//ATTENZIONE: 
'0' รจ il numero del layer
                //fine colori

                return terrainNode;
        }
#include ".\morfologia.h"
#include ".\mare.h"
#include ".\colata.h"
#include ".\filterhandler.h"
#include ".\layerhandler.h"

#include <osg/Group>
#include <osgProducer/Viewer>
#include <osgTerrain/GeometryTechnique>

#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>

int main()
{
        Morfologia* morfologia= new Morfologia();
        osgTerrain::Terrain* terrainNode= morfologia->drawMorfologia();
         

        Mare* mare= new Mare();
        osg::Geode* geodeMare= mare->drawMare();

        Colata* colata=new Colata();
        osg::Geode* geodeColata= colata->drawColata();

        osg::Group* root= new osg::Group();
        
        //GEOMETRY TECHNIQUE
        osgTerrain::GeometryTechnique* geometryTechnique = new 
osgTerrain::GeometryTechnique;
        terrainNode->setTerrainTechnique(geometryTechnique);
        //fine technique

        
        root->addChild(terrainNode);


        //VIEWER
        osgViewer::Viewer v;

        v.addEventHandler(new osgViewer::StatsHandler);
        v.addEventHandler(new FilterHandler(geometryTechnique));
    v.addEventHandler(new LayerHandler(terrainNode->getElevationLayer()));
        
        v.setSceneData(root);
        v.realize();
        v.run();
        return 0;
}

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to