salut,

j'ai pas mal de difficulté avec les callback ,

voici le code principale du callback :




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
/* 
 * File:   updateCollision.h
 * Author: modde
 *
 * Created on 16 février 2010, 23:48
 */
 
#ifndef _UPDATECOLLISION_H
#define    _UPDATECOLLISION_H
 
#include <osg/NodeCallback>
#include <osg/Geode>
#include "camera.h"
 
 
class updateCollision : public osg::NodeCallback {
public:
    updateCollision( Camera * cam, osg::Geode geode, osg::BoundingBox &bb);
 
    Camera * camera;
    osg::BoundingBox & bbhouse;
    osg::ref_ptr<osg::Geode> personnage;
 
    void operator()( osg::Node* node, osg::NodeVisitor* nv ){
 
        if((personnage.get().getBoundingBox().intersect(bbhouse))&&camera->moveForward()){
 
            camera->stopMoveForward();
        }
        if((personnage.get().getBoundingBox().intersect(bbhouse))&&camera->moveBack()){
            camera->stopMoveback();
        }
 
        if((personnage.get()->getBoundingBox().intersect(bbhouse))&&camera->moveRight()){
            camera->stopMoveRight();
        }
 
        if((personnage.get().getBoundingBox().intersect(bbhouse))&&camera->moveleft()){
            camera->stopMoveLeft();
        }
    }
};
 
#endif    /* _UPDATECOLLISION_H */
le fichier cpp :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
#include "updateCollision.h"
 
updateCollision::updateCollision(Camera* cam, osg::Geode geode, osg::BoundingBox &bb) {
    camera = cam;
    personnage =geode;
    bbhouse =bb;
 
}
j'ai l'erreur suivante :
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
updateCollision.h: In member function ‘virtual void updateCollision::operator()(osg::Node*, osg::NodeVisitor*)’:
In file included from updateCollision.cpp:8:
updateCollision.h:26: error: request for member ‘getBoundingBox’ in ‘((updateCollision*)this)->updateCollision::personnage.osg::ref_ptr<T>::get [with T = osg::Geode]()’, which is of non-class type ‘osg::Geode*’
updateCollision.h:30: error: request for member ‘getBoundingBox’ in ‘((updateCollision*)this)->updateCollision::personnage.osg::ref_ptr<T>::get [with T = osg::Geode]()’, which is of non-class type ‘osg::Geode*’
updateCollision.h:34: error: no match foroperator&&’ in ‘((const osg::BoundingBox*)((updateCollision*)this)->updateCollision::personnage.osg::ref_ptr<T>::get [with T = osg::Geode]()->osg::Geode::getBoundingBox())->osg::BoundingBoxImpl<VT>::intersect [with VT = osg::Vec3f](((const osg::BoundingBoxImpl<osg::Vec3f>&)((const osg::BoundingBoxImpl<osg::Vec3f>*)((updateCollision*)this)->updateCollision::bbhouse))) && ((updateCollision*)this)->updateCollision::camera->Camera::moveRight()’
updateCollision.h:34: note: candidates are: operator&&(bool, bool) <built-in>
updateCollision.h:38: error: request for member ‘getBoundingBox’ in ‘((updateCollision*)this)->updateCollision::personnage.osg::ref_ptr<T>::get [with T = osg::Geode]()’, which is of non-class type ‘osg::Geode*’
updateCollision.cpp: In constructor ‘updateCollision::updateCollision(Camera*, osg::Geode, osg::BoundingBox&)’:
updateCollision.cpp:10: error: uninitialized reference member ‘updateCollision::bbhouse’
updateCollision.cpp:12: error: no match foroperator=’ in ‘((updateCollision*)this)->updateCollision::personnage = geode’
/usr/local/include/osg/ref_ptr:35: note: candidates are: osg::ref_ptr<T>& osg::ref_ptr<T>::operator=(const osg::ref_ptr<T>&) [with T = osg::Geode]
/usr/local/include/osg/ref_ptr:47: note:                 osg::ref_ptr<T>& osg::ref_ptr<T>::operator=(T*) [with T = osg::Geode]
make[2]: *** [build/Debug/GNU-Linux-x86/updateCollision.o] Erreur 1
make[2]: quittant le répertoire « /home/modde/NetBeansProjects/Camera »
make[1]: *** [.build-conf] Erreur 2
make[1]: quittant le répertoire « /home/modde/NetBeansProjects/Camera »
make: *** [.build-impl] Erreur 2
BUILD FAILED (exit value 2, total time: 2s)
merci !