IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

OpenSceneGraph Discussion :

[osgBullet] Problème de compilation sur une démo


Sujet :

OpenSceneGraph

  1. #1
    Membre actif
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    502
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 502
    Points : 227
    Points
    227
    Par défaut [osgBullet] Problème de compilation sur une démo
    salut,

    j'ai un petit probleme de compilation :

    j'ai ajouté le moteur physique bullet (wrapper osgbullet) avec osg :

    je developpe sous linux kubuntu 9.10 , g++ 4.4.1, osg 2.8.2, bullet 2.74

    j'ai voulu faire un test sur une demo :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    /* 
     * File:   test.cpp
     * Author: david
     * 
     * Created on 2 avril 2010, 01:21
     */
    /*************** <auto-copyright.pl BEGIN do not edit this line> **************
     *
     * osgBullet is (C) Copyright 2009 by Kenneth Mark Bryden
     *
     * This library is free software; you can redistribute it and/or
     * modify it under the terms of the GNU Lesser General Public
     * License version 2.1 as published by the Free Software Foundation.
     *
     * This library is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     * Library General Public License for more details.
     *
     * You should have received a copy of the GNU Lesser General Public
     * License along with this library; if not, write to the
     * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     * Boston, MA 02111-1307, USA.
     *
     *************** <auto-copyright.pl END do not edit this line> ***************/
     
     
    #include <osgViewer/Viewer>
    #include <osg/MatrixTransform>
    #include <osg/ShapeDrawable>
    #include <osg/Geode>
     
    #include <osgbBullet/MotionState.h>
    #include <osgbBullet/CollisionShapes.h>
    #include <osgbBullet/Utils.h>
     
    #include <btBulletDynamicsCommon.h>
     
    #include <string>
    #include <osg/io_utils>
    #include <osgDB/ReadFile>
    #include <osg/Node>
     
     
    osg::MatrixTransform*
    makeDie( btDynamicsWorld* bw )
    {
        osg::MatrixTransform* root = new osg::MatrixTransform;
     
        osg::Node* node = osgDB::readNodeFile("nathan.osg");
     
        btCollisionShape* cs = osgbBullet::btBoxCollisionShapeFromOSG( node );
        osgbBullet::MotionState* motion = new osgbBullet::MotionState();
        motion->setTransform( root );
        btScalar mass( 1. );
        btVector3 inertia( 0, 0, 0 );
        cs->calculateLocalInertia( mass, inertia );
        btRigidBody::btRigidBodyConstructionInfo rb( mass, motion, cs, inertia );
        btRigidBody* body = new btRigidBody( rb );
        //body->setActivationState( DISABLE_DEACTIVATION );
        bw->addRigidBody( body );
     
        return( root );
    }
     
     
    btDynamicsWorld*
    initPhysics()
    {
        btDefaultCollisionConfiguration * collisionConfiguration = new btDefaultCollisionConfiguration();
        btCollisionDispatcher * dispatcher = new btCollisionDispatcher( collisionConfiguration );
        btConstraintSolver * solver = new btSequentialImpulseConstraintSolver;
     
        btVector3 worldAabbMin( -10000, -10000, -10000 );
        btVector3 worldAabbMax( 10000, 10000, 10000 );
        btBroadphaseInterface * inter = new btAxisSweep3( worldAabbMin, worldAabbMax, 1000 );
     
        btDynamicsWorld * dynamicsWorld = new btDiscreteDynamicsWorld( dispatcher, inter, solver, collisionConfiguration );
     
        dynamicsWorld->setGravity( btVector3( 0, 0, 9.8 ) );
     
        return( dynamicsWorld );
    }
     
     
     
    class ShakeManipulator : public osgGA::GUIEventHandler
    {
    public:
        ShakeManipulator( osgbBullet::MotionState* motion )
          : _motion( motion )
        {}
     
        bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& )
        {
            switch( ea.getEventType() )
            {
                case osgGA::GUIEventAdapter::KEYUP:
                {
                    if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Space)
                    {
                        btTransform trans; trans.setIdentity();
                        _motion->setWorldTransform( trans );
     
                        return true;
                    }
     
                    return false;
                }
     
                case osgGA::GUIEventAdapter::PUSH:
                {
                    _lastX = ea.getXnormalized();
                    _lastY = ea.getYnormalized();
     
                    btTransform world;
                    _motion->getWorldTransform( world );
                    btVector3 o = world.getOrigin();
                    o[ 2 ] = 0.25;
                    world.setOrigin( o );
                    _motion->setWorldTransform( world );
     
                    return true;
                }
                case osgGA::GUIEventAdapter::DRAG:
                {
                    btVector3 move;
                    move[ 0 ] = _lastX - ea.getXnormalized();
                    move[ 1 ] = ea.getYnormalized() - _lastY;
                    move[ 2 ] = 0.;
                    move *= 10.;
                    btTransform moveTrans; moveTrans.setIdentity();
                    moveTrans.setOrigin( move );
                    btTransform world;
                    _motion->getWorldTransform( world );
                    btTransform netTrans = moveTrans * world;
                    btVector3 o = netTrans.getOrigin();
                    o[ 2 ] = 0.;
                    netTrans.setOrigin( o );
     
                    _motion->setWorldTransform( netTrans );
     
                    _lastX = ea.getXnormalized();
                    _lastY = ea.getYnormalized();
     
                    return true;
                }
                default:
                break;
            }
            return false;
        }
     
    protected:
        osgbBullet::MotionState* _motion;
        float _lastX, _lastY;
    };
     
     
     
     
     
    osg::Geode* osgBox( const osg::Vec3& center, const osg::Vec3& halfLengths )
    {
        osg::Vec3 l( halfLengths * 2. );
        osg::Box* box = new osg::Box( center, l.x(), l.y(), l.z() );
        osg::ShapeDrawable* shape = new osg::ShapeDrawable( box );
        shape->setColor( osg::Vec4( 1., 1., 1., 1. ) );
        osg::Geode* geode = new osg::Geode();
        geode->addDrawable( shape );
        return( geode );
    }
     
     
     
    int
    main( int argc,
          char ** argv )
    {
        btDynamicsWorld* bulletWorld = initPhysics();
        osg::Group* root = new osg::Group;
     
        root->addChild( makeDie( bulletWorld ) );
        root->addChild( makeDie( bulletWorld ) );
     
     
        /* BEGIN: Create environment boxes */
        float xDim( 10. );
        float yDim( 10. );
        float zDim( 6. );
        float thick( .1 );
     
        osg::MatrixTransform* shakeBox = new osg::MatrixTransform;
        btCompoundShape* cs = new btCompoundShape;
        { // floor -Z (far back of the shake cube)
            osg::Vec3 halfLengths( xDim*.5, yDim*.5, thick*.5 );
            osg::Vec3 center( 0., 0., zDim*.5 );
            shakeBox->addChild( osgBox( center, halfLengths ) );
            btBoxShape* box = new btBoxShape( osgbBullet::asBtVector3( halfLengths ) );
            btTransform trans; trans.setIdentity();
            trans.setOrigin( osgbBullet::asBtVector3( center ) );
            cs->addChildShape( trans, box );
        }
        { // top +Z (invisible, to allow user to see through; no OSG analogue
            osg::Vec3 halfLengths( xDim*.5, yDim*.5, thick*.5 );
            osg::Vec3 center( 0., 0., -zDim*.5 );
            //shakeBox->addChild( osgBox( center, halfLengths ) );
            btBoxShape* box = new btBoxShape( osgbBullet::asBtVector3( halfLengths ) );
            btTransform trans; trans.setIdentity();
            trans.setOrigin( osgbBullet::asBtVector3( center ) );
            cs->addChildShape( trans, box );
        }
        { // left -X
            osg::Vec3 halfLengths( thick*.5, yDim*.5, zDim*.5 );
            osg::Vec3 center( -xDim*.5, 0., 0. );
            shakeBox->addChild( osgBox( center, halfLengths ) );
            btBoxShape* box = new btBoxShape( osgbBullet::asBtVector3( halfLengths ) );
            btTransform trans; trans.setIdentity();
            trans.setOrigin( osgbBullet::asBtVector3( center ) );
            cs->addChildShape( trans, box );
        }
        { // right +X
            osg::Vec3 halfLengths( thick*.5, yDim*.5, zDim*.5 );
            osg::Vec3 center( xDim*.5, 0., 0. );
            shakeBox->addChild( osgBox( center, halfLengths ) );
            btBoxShape* box = new btBoxShape( osgbBullet::asBtVector3( halfLengths ) );
            btTransform trans; trans.setIdentity();
            trans.setOrigin( osgbBullet::asBtVector3( center ) );
            cs->addChildShape( trans, box );
        }
        { // bottom of window -Y
            osg::Vec3 halfLengths( xDim*.5, thick*.5, zDim*.5 );
            osg::Vec3 center( 0., -yDim*.5, 0. );
            shakeBox->addChild( osgBox( center, halfLengths ) );
            btBoxShape* box = new btBoxShape( osgbBullet::asBtVector3( halfLengths ) );
            btTransform trans; trans.setIdentity();
            trans.setOrigin( osgbBullet::asBtVector3( center ) );
            cs->addChildShape( trans, box );
        }
        { // bottom of window -Y
            osg::Vec3 halfLengths( xDim*.5, thick*.5, zDim*.5 );
            osg::Vec3 center( 0., yDim*.5, 0. );
            shakeBox->addChild( osgBox( center, halfLengths ) );
            btBoxShape* box = new btBoxShape( osgbBullet::asBtVector3( halfLengths ) );
            btTransform trans; trans.setIdentity();
            trans.setOrigin( osgbBullet::asBtVector3( center ) );
            cs->addChildShape( trans, box );
        }
        /* END: Create environment boxes */
     
     
        osgbBullet::MotionState * shakeMotion = new osgbBullet::MotionState();
        shakeMotion->setTransform( shakeBox );
        btScalar mass( 0.0 );
        btVector3 inertia( 0, 0, 0 );
        btRigidBody::btRigidBodyConstructionInfo rb( mass, shakeMotion, cs, inertia );
        btRigidBody* shakeBody = new btRigidBody( rb );
        shakeBody->setCollisionFlags( shakeBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT );
        shakeBody->setActivationState( DISABLE_DEACTIVATION );
        bulletWorld->addRigidBody( shakeBody );
     
        root->addChild( shakeBox );
     
        osgViewer::Viewer viewer;
        viewer.setUpViewInWindow( 150, 150, 400, 400 );
        viewer.setSceneData( root );
        viewer.getCamera()->setViewMatrixAsLookAt(
            osg::Vec3( 0, 0, -20 ), osg::Vec3( 0, 0, 0 ), osg::Vec3( 0, 1, 0 ) );
        viewer.getCamera()->setProjectionMatrixAsPerspective( 40., 1., 1., 50. );
        viewer.addEventHandler( new ShakeManipulator( shakeMotion ) );
     
        viewer.realize();
        double prevSimTime = 0.;
        while( !viewer.done() )
        {
            const double currSimTime = viewer.getFrameStamp()->getSimulationTime();
            double elapsed( currSimTime - prevSimTime );
            if( viewer.getFrameStamp()->getFrameNumber() < 3 )
                elapsed = 1./60.;
            //osg::notify( osg::ALWAYS ) << elapsed / 3. << ", " << 1./180. << std::endl;
            bulletWorld->stepSimulation( elapsed, 4, elapsed/4. );
            prevSimTime = currSimTime;
            viewer.frame();
        }
     
        return( 0 );
    }
    voici l'erreur lors de la compilation :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    /usr/bin/make -f nbproject/Makefile-Release.mk SUBPROJECTS= .build-conf
    make[1]: entrant dans le répertoire « /home/modde/NetbeanProjets/testosgbullet »
    /usr/bin/make  -f nbproject/Makefile-Release.mk dist/Release/GNU-Linux-x86/testosgbullet
    make[2]: entrant dans le répertoire « /home/modde/NetbeanProjets/testosgbullet »
    mkdir -p build/Release/GNU-Linux-x86
    rm -f build/Release/GNU-Linux-x86/test.o.d
    g++    -c -O2 -I/usr/local/include/osgDB -I/usr/local/include/osgGA -I/usr/local/include/osg -I/usr/local/include/bullet -I/usr/local/include/osgViewer -I/usr/local/include/osgbBullet -I/usr/local/include/bullet/BulletDynamics -I/usr/local/include/bullet/LinearMath -MMD -MP -MF build/Release/GNU-Linux-x86/test.o.d -o build/Release/GNU-Linux-x86/test.o test.cpp
                     from /usr/local/include/osgDB/DotOsgWrapper:21,
                     from /usr/local/include/osgDB/Registry:25,
                     from /usr/local/include/osgDB/ReadFile:24,
                     from test.cpp:41:
    In file included from /usr/local/include/osgDB/Output:20,
    /usr/local/include/osgDB/fstream:32: error: invalid use of incomplete type ‘struct std::fstream’
    /usr/include/c++/4.4/iosfwd:87: error: declaration of ‘struct std::fstream’
    /usr/local/include/osgDB/fstream:44: error: invalid use of incomplete type ‘struct std::ifstream’
    /usr/include/c++/4.4/iosfwd:81: error: declaration of ‘struct std::ifstream’
    /usr/local/include/osgDB/fstream:56: error: invalid use of incomplete type ‘struct std::ofstream’
    /usr/include/c++/4.4/iosfwd:84: error: declaration of ‘struct std::ofstream’
    make[2]: *** [build/Release/GNU-Linux-x86/test.o] Erreur 1
    make[2]: quittant le répertoire « /home/modde/NetbeanProjets/testosgbullet »
    make[1]: *** [.build-conf] Erreur 2
    make[1]: quittant le répertoire « /home/modde/NetbeanProjets/testosgbullet »
    make: *** [.build-impl] Erreur 2
    BUILD FAILED (exit value 2, total time: 5s)
    merci !

  2. #2
    Membre actif
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    502
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 502
    Points : 227
    Points
    227
    Par défaut
    j'ai resolu le probleme : je pense que les version linux sous kde pose des probleme a certaines compilations .

    j'ai réinstallé ubuntu donc "gnome" compilé le programme et tout fonctionne correctement, aucun bug.

    http://www.hostingpics.net/viewer.ph...970Capture.png

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 7
    Dernier message: 12/11/2006, 12h49
  2. Problème de select sur une date (DATETIME....)
    Par zeldoi5 dans le forum Langage SQL
    Réponses: 7
    Dernier message: 16/05/2005, 11h19
  3. probléme de cadre sur une image qui me sert de lien
    Par thomas_chamas dans le forum Balisage (X)HTML et validation W3C
    Réponses: 4
    Dernier message: 26/11/2004, 17h36
  4. Problème de chaine sur une page HTML
    Par Kerod dans le forum Général JavaScript
    Réponses: 8
    Dernier message: 23/11/2004, 16h23
  5. [Eclipse][Java]Problème de compilation sur CTRL+S
    Par ZeKiD dans le forum Eclipse Java
    Réponses: 5
    Dernier message: 27/05/2004, 11h49

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo