thanks a lot…
I try do what do you tell me but when i run my code, the program fall in segmentation fault. This is my code:
#include <pandaFramework.h>
#include <pandaSystem.h>
#include <genericAsyncTask.h>
#include <collisionNode.h>
PandaFramework framework;
class MyObject : public CollisionNode {
int a;
static TypeHandle _type_handle;
public:
MyObject(string str, int a) : CollisionNode(str) {
NodePath model = framework.get_window(0)->load_model(framework.get_models(), "smiley");
model.set_pos(0, 0, 0);
model.reparent_to(NodePath(this));
this->a = a;
}
int& get_a() {
return a;
}
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
CollisionNode::init_type();
register_type(_type_handle, "MyObject", CollisionNode::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {
init_type();
return get_class_type();
}
};
TypeHandle MyObject::_type_handle;
int main(int argc, char** argv) {
framework.open_framework(argc, argv);
WindowFramework *window = framework.open_window();
NodePath path = NodePath(new MyObject("myObject", 0));
path.set_pos(0, 10, 0);
path.reparent_to(window->get_render());
window->get_camera_group().look_at(path);
framework.main_loop();
framework.close_framework();
return 0;
}
the problem is when i write:
model.reparent_to(NodePath(this));
but i don’t know how reparent model to myObject in MyObject’s constructor…
Can you help me??