On Fri, Nov 13, 2009 at 6:30 PM, Aarto Matti <[email protected]> wrote:
> Hello,
>
> I would like to access C API fucntion clutter_box2d_get_actor() from C++
> code, how can I do it?
>
> --
> Aarto
>
To be more concrete, how can I access Box2D API from C++? It would be enough
to access b2Body *body and b2Shape *shape private members of
ClutterBox2DActor class. What I'm trying to achieve is to set to actors a
fixed mass that doesn't depend on their size. By default mass is calculated
as:
shapeDef.SetAsBox (width * 0.5 * SCALE_FACTOR,
height * 0.5 * SCALE_FACTOR,
b2Vec2 (width * 0.5 * SCALE_FACTOR,
height * 0.5 * SCALE_FACTOR), 0);
shapeDef.density = 10.0f;
shapeDef.friction = 0.2f;
box2d_actor->shape = box2d_actor->body->CreateShape (&shapeDef)
I believe I could do it explicitly like this:
Glib::RefPtr<Clutter::Box2D::Box2D> box2d = Clutter::Box2D::Box2D::create();
Glib::RefPtr<Clutter::Rectangle> actor = Clutter::Rectangle::create();
actor->set_size(100, 100);
box2d->add_actor(actor);
Glib::RefPtr<Clutter::Box2DActor> actor_box2d = box2d->get_actor(actor);
actor_box2d->body->massData.mass = 2.0f;
Because clutter-box2dmm is incomplete I see now way of doing this.
--
Aarto
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list