コード例 #1
0
ファイル: Clouds.cpp プロジェクト: Crisium/sigmaosg
int _tmain(int argc, _TCHAR* argv[])
{
    // construct the viewer
    osg::ref_ptr<osgViewer::Viewer> rViewer = new osgViewer::Viewer;

    // set up the camera manipulators.
    {
        osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;

        keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() );
        keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() );
        keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() );
        keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );

        rViewer->setCameraManipulator( keyswitchManipulator.get() );
    }

    // make the viewer create a 800x600 window and position it at 32, 32
    rViewer->setUpViewInWindow( 32, 32, 800, 600 );

	osg::Group* pGroup = new osg::Group;
	pGroup->addChild( createScene() );

    // set the scene-graph data the viewer will render
    rViewer->setSceneData( pGroup );

	rViewer->setCameraManipulator( new osgGA::TrackballManipulator );

	pGroup->addChild( createClouds() );

    // execute main loop
    return rViewer->run();
}
コード例 #2
0
bool ListWeatherCloud::logicClouds(int base_cloudiness_a, long cycle_max_a){
    int cloudiness;
    cycle_max = cycle_max_a + randBetween(-5000,5000); // TODO: needs adjustment
    cloudiness=base_cloudiness_a + randBetween(-40, 40);

    cloud_distance = 800 / cloudiness;

    if (cloud_list.empty()){

        const int half_max_cycle = cycle_max/2;
        createClouds(cloudiness);
        // rain variable: time_of_rain
          // determines after which time of the cycle it should
          // start to rain; no rain if time_of_rain>cycle_max;
          // depends both on cloudiness and some randomness
        time_of_rain = cycle_max * ( 10/cloudiness) + randBetween(0, half_max_cycle);
        // determine if it should be strong rainfall, let it depend on cloudiness and time_of_rain
        if ((cloudiness*time_of_rain/cycle_max>=30)) is_strong_rainfall = true;

		// instantiate RenderDevice Images
		if (!spr_flake) {
			Image *img_rainfall = NULL;
			if (is_snow){
				img_rainfall = render_device->loadImage("images/weather/snow_transparent.png",
					"Couldn't load snow image!", false);
			}
			else{
				img_rainfall = render_device->loadImage("images/weather/rain.png",
					"Couldn't load rain image!", false);
			}
			if (img_rainfall){
				spr_flake = img_rainfall->createSprite();
				img_rainfall->unref();
			}
		}


        cycle_i = 0;
    }
    return true;
}