<commit_before>#include <stdio.h>
//C++ source file - Open Producer - Copyright (C) 2002 <NAME>
//Distributed under the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE (LGPL)
//as published by the Free Software Foundation.

// Simple example of use of Producer::RenderSurface
// The myGraphics class is a simple sample of how one would implement
// graphics drawing with Producer::RenderSurface

#include <Producer/Camera>
#include <Producer/CameraConfig>
#include <Producer/InputArea>
#include <Producer/KeyboardMouse>

#include <osg/Timer>

#include <osgUtil/Optimizer>
#include <osgUtil/UpdateVisitor>

#include <osgDB/ReadFile>

#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgGA/KeySwitchCameraManipulator>
#include <osgGA/StateSetManipulator>

#include <osgProducer/CameraGroup>
#include <osgProducer/SceneHandler>
#include <osgProducer/KeyboardMouseCallback>
#include <osgProducer/ActionAdapter>

#include <list>


int main( int argc, char **argv )
{

    // threading model.
    Producer::CameraGroup::ThreadingModel threadingModel = Producer::CameraGroup::SingleThreaded;
    threadingModel = Producer::CameraGroup::ThreadPerCamera;

    // configuration file.
    std::string configFile;
    //configFile = "twoWindows.cfg";

    // set up the database files to read.
    std::vector<std::string> filenameList;
    if (argc>1) filenameList.push_back(argv[1]);
    else filenameList.push_back("cow.osg");



    // create the camera group.
    osgProducer::CameraGroup *cg = configFile.empty() ?
         (new osgProducer::CameraGroup()):
         (new osgProducer::CameraGroup(configFile));

    // set up the maximum number of graphics contexts, before loading the scene graph
    // to ensure that texture objects and display buffers are configured to the correct size.
    osg::DisplaySettings::instance()->setMaxNumberOfGraphicsContexts( cg->getNumberOfCameras() );


    // read the scene.
    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(filenameList);
    if (!loadedModel) return 1;

    osgUtil::Optimizer optimizer;
    optimizer.optimize(loadedModel.get());


    // set up the keyboard and mouse handling.
    Producer::InputArea *ia = cg->getCameraConfig()->getInputArea();
    Producer::KeyboardMouse *kbm = ia ?
                                   (new Producer::KeyboardMouse(ia)) : 
                                   (new Producer::KeyboardMouse(cg->getCamera(0)->getRenderSurface()));

    // set up the time and frame counter.
    unsigned int frameNumber = 0;
    osg::Timer timer;
    osg::Timer_t start_tick = timer.tick();

    // set the keyboard mouse callback to catch the events from the windows.
    bool done = false;
    osgProducer::KeyboardMouseCallback kbmcb(done);
    kbmcb.setStartTick(start_tick);
    
    // register the callback with the keyboard mouse manger.
    kbm->setCallback( &kbmcb );
    //kbm->allowContinuousMouseMotionUpdate(true);
    kbm->startThread();



    // set the globa state
    osg::ref_ptr<osg::StateSet> globalStateSet = new osg::StateSet;
    globalStateSet->setGlobalDefaults();
    cg->setGlobalStateSet(globalStateSet.get());
    
    
    // add either a headlight or sun light to the scene.
    osg::LightSource* lightsource = new osg::LightSource;
    osg::Light* light = new osg::Light;
    lightsource->setLight(light);
    lightsource->setReferenceFrame(osg::LightSource::RELATIVE_TO_ABSOLUTE); // headlight.
    lightsource->setLocalStateSetModes(osg::StateAttribute::ON);

    lightsource->addChild(loadedModel.get());
    
    
    // set the scene to render
//    cg->setSceneData(scene.get());
    cg->setSceneData(lightsource);

    // set up the pthread stack size to large enough to run into problems.
    cg->setStackSize( 20*1024*1024);

    // create the windows and run the threads.
    cg->realize(threadingModel);

    osg::ref_ptr<osg::FrameStamp> frameStamp = cg->getFrameStamp();

    osgUtil::UpdateVisitor update;
    update.setFrameStamp(frameStamp.get());



    // create a camera to use with the manipulators.
    osg::ref_ptr<osg::Camera> old_style_osg_camera = new osg::Camera;

    osg::ref_ptr<osgGA::TrackballManipulator> trackballManipulator = new osgGA::TrackballManipulator;
    trackballManipulator->setCamera(old_style_osg_camera.get());
    trackballManipulator->setNode(loadedModel.get());

    osg::ref_ptr<osgGA::FlightManipulator> flightManipulator = new osgGA::FlightManipulator;
    flightManipulator->setCamera(old_style_osg_camera.get());
    flightManipulator->setNode(loadedModel.get());

    osg::ref_ptr<osgGA::DriveManipulator> driveManipulator = new osgGA::DriveManipulator;
    driveManipulator->setCamera(old_style_osg_camera.get());
    driveManipulator->setNode(loadedModel.get());


    osg::ref_ptr<osgGA::KeySwitchCameraManipulator> keyswitchManipulator = new osgGA::KeySwitchCameraManipulator;
    keyswitchManipulator->addNumberedCameraManipulator(trackballManipulator.get());
    keyswitchManipulator->addNumberedCameraManipulator(flightManipulator.get());
    keyswitchManipulator->addNumberedCameraManipulator(driveManipulator.get());


    osg::ref_ptr<osgGA::StateSetManipulator> statesetManipulator = new osgGA::StateSetManipulator;
    statesetManipulator->setStateSet(globalStateSet.get());

    // create an event handler list, we'll dispatch our event to these..
    typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlerList;
    EventHandlerList eventHandlerList;
    eventHandlerList.push_back(keyswitchManipulator.get());
    eventHandlerList.push_back(statesetManipulator.get());

    // create a dummy action adapter right now.
    osgProducer::ActionAdapter actionAdapter;

    osg::ref_ptr<osgProducer::EventAdapter> init_event = new osgProducer::EventAdapter;<commit_msg>Clean up to the osgproducer demo.<commit_after>#include <stdio.h>
//C++ source file - Open Producer - Copyright (C) 2002 <NAME>
//Distributed under the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE (LGPL)
//as published by the Free Software Foundation.

// Simple example of use of Producer::RenderSurface
// The myGraphics class is a simple sample of how one would implement
// graphics drawing with Producer::RenderSurface

#include <Producer/Camera>
#include <Producer/CameraConfig>
#include <Producer/InputArea>
#include <Producer/KeyboardMouse>

#include <osg/Timer>

#include <osgUtil/Optimizer>
#include <osgUtil/UpdateVisitor>

#include <osgDB/ReadFile>

#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgGA/KeySwitchCameraManipulator>
#include <osgGA/StateSetManipulator>

#include <osgProducer/CameraGroup>
#include <osgProducer/SceneHandler>
#include <osgProducer/KeyboardMouseCallback>
#include <osgProducer/ActionAdapter>

#include <list>


int main( int argc, char **argv )
{

    // threading model.
    Producer::CameraGroup::ThreadingModel threadingModel = Producer::CameraGroup::SingleThreaded;
    threadingModel = Producer::CameraGroup::ThreadPerCamera;

    // configuration file.
    std::string configFile;
    //configFile = "twoWindows.cfg";

    // set up the database files to read.
    std::vector<std::string> filenameList;
    if (argc>1) filenameList.push_back(argv[1]);
    else filenameList.push_back("cow.osg");



    // create the camera group.
    osgProducer::CameraGroup *cg = configFile.empty() ?
         (new osgProducer::CameraGroup()):
         (new osgProducer::CameraGroup(configFile));

    // set up the maximum number of graphics contexts, before loading the scene graph
    // to ensure that texture objects and display buffers are configured to the correct size.
    osg::DisplaySettings::instance()->setMaxNumberOfGraphicsContexts( cg->getNumberOfCameras() );


    // read the scene.
    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(filenameList);
    if (!loadedModel) return 1;

    osgUtil::Optimizer optimizer;
    optimizer.optimize(loadedModel.get());


    // set up the keyboard and mouse handling.
    Producer::InputArea *ia = cg->getCameraConfig()->getInputArea();
    Producer::KeyboardMouse *kbm = ia ?
                                   (new Producer::KeyboardMouse(ia)) : 
                                   (new Producer::KeyboardMouse(cg->getCamera(0)->getRenderSurface()));

    // set up the time and frame counter.
    unsigned int frameNumber = 0;
    osg::Timer timer;
    osg::Timer_t start_tick = timer.tick();

    // set the keyboard mouse callback to catch the events from the windows.
    bool done = false;
    osgProducer::KeyboardMouseCallback kbmcb(done);
    kbmcb.setStartTick(start_tick);
    
    // register the callback with the keyboard mouse manger.
    kbm->setCallback( &kbmcb );
    //kbm->allowContinuousMouseMotionUpdate(true);
    kbm->startThread();



    // set the globa state
    osg::ref_ptr<osg::StateSet> globalStateSet = new osg::StateSet;
    globalStateSet->setGlobalDefaults();
    cg->setGlobalStateSet(globalStateSet.get());
    
    
    // add either a headlight or sun light to the scene.
    osg::LightSource* lightsource = new osg::LightSource;
    osg::Light* light = new osg::Light;
    lightsource->setLight(light);
    lightsource->setReferenceFrame(osg::LightSource::RELATIVE_TO_ABSOLUTE); // headlight.
    lightsource->setLocalStateSetModes(osg::StateAttribute::ON);

    lightsource->addChild(loadedModel.get());
    
    
    // set the scene to render
//    cg->setSceneData(scene.get());
    cg->setSceneData(lightsource);

    // set up the pthread stack size to large enough to run into problems.
    cg->setStackSize( 20*1024*1024);

    // create the windows and run the threads.
    cg->realize(threadingModel);

    osg::ref_ptr<osg::FrameStamp> frameStamp = cg->getFrameStamp();

    osgUtil::UpdateVisitor update;
    update.setFrameStamp(frameStamp.get());



    // create a camera to use with the manipulators.
    osg::ref_ptr<osg::Camera> old_style_osg_camera = new osg::Camera;

    osg::ref_ptr<osgGA::KeySwitchCameraManipulator> keyswitchManipulator = new osgGA::KeySwitchCameraManipulator;
    keyswitchManipulator->addNumberedCameraManipulator(new osgGA::TrackballManipulator);
    keyswitchManipulator->addNumberedCameraManipulator(new osgGA::FlightManipulator);
    keyswitchManipulator->addNumberedCameraManipulator(new osgGA::DriveManipulator);
    
    keyswitchManipulator->setCamera(old_style_osg_camera.get());
    keyswitchManipulator->setNode(loadedModel.get());


    osg::ref_ptr<osgGA::StateSetManipulator> statesetManipulator = new osgGA::StateSetManipulator;
    statesetManipulator->setStateSet(globalStateSet.get());

    // create an event handler list, we'll dispatch our event to these..
    typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlerList;
    EventHandlerList eventHandlerList;
    eventHandlerList.push_back(keyswitchManipulator.get());
    eventHandlerList.push_back(statesetManipulator.get());

    // create a dummy action adapter right now.
    osgProducer::ActionAdapter actionAdapter;

    osg::ref_ptr<osgProducer::EventAdapter> init_event = new osgProducer::EventAdapter;
{'fraction_non_alphanumeric': 0.11235152272930249, 'fraction_numerical': 0.0033937661873716172, 'mean_word_length': 4.345107398568019, 'pattern_counts': {'":': 0, '<': 66, '<?xml version=': 0, '>': 124, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6524403', 'n_tokens_mistral': 3525, 'n_tokens_neox': 3403, 'n_words': 751}