gnomemm r1681 - in clutter-box2dmm/trunk/examples: . revolute_joint slides



Author: murrayc
Date: Mon Aug 11 08:31:41 2008
New Revision: 1681
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1681&view=rev

Log:
Commit so I can rename this.

Added:
   clutter-box2dmm/trunk/examples/revolute_joint/
      - copied from r1679, /clutter-box2dmm/trunk/examples/chain/
   clutter-box2dmm/trunk/examples/revolute_joint/gnome_logo.png
      - copied unchanged from r1679, /clutter-box2dmm/trunk/examples/table/gnome_logo.png
   clutter-box2dmm/trunk/examples/revolute_joint/main.cc
      - copied, changed from r1680, /clutter-box2dmm/trunk/examples/chain/main.cc
Modified:
   clutter-box2dmm/trunk/examples/Makefile.am
   clutter-box2dmm/trunk/examples/slides/main.cc

Modified: clutter-box2dmm/trunk/examples/Makefile.am
==============================================================================
--- clutter-box2dmm/trunk/examples/Makefile.am	(original)
+++ clutter-box2dmm/trunk/examples/Makefile.am	Mon Aug 11 08:31:41 2008
@@ -1,3 +1,3 @@
-SUBDIRS = bridge chain pyramid slides table
+SUBDIRS = bridge chain pyramid slides table revolute_joint
 
 

Copied: clutter-box2dmm/trunk/examples/revolute_joint/main.cc (from r1680, /clutter-box2dmm/trunk/examples/chain/main.cc)
==============================================================================
--- /clutter-box2dmm/trunk/examples/chain/main.cc	(original)
+++ clutter-box2dmm/trunk/examples/revolute_joint/main.cc	Mon Aug 11 08:31:41 2008
@@ -2,35 +2,6 @@
 #include <clutter-box2dmm.h>
 #include <iostream>
 
-static void
-add_static_box(const Glib::RefPtr<Clutter::Box2D::Box2D>& box2d,
-                int x, int y, int width, int height)
-{
-  Glib::RefPtr<Clutter::Rectangle> rect = Clutter::Rectangle::create();
-  rect->set_size(width, height);
-  rect->set_position(x, y);
-
-  box2d->add_actor(rect);
-  box2d->set_child_mode(rect, Clutter::Box2D::BOX2D_STATIC);
-}
-
-void
-add_cage(const Glib::RefPtr<Clutter::Box2D::Box2D>& box2d, bool roof)
-{
-  Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::get_default(); //TODO: There could be more than one stage.
-  const int width = stage->get_width();
-  const int height = stage->get_height();
-
-  if(roof)
-    add_static_box(box2d, -100, -100, width + 200, 100);
-  else
-    add_static_box(box2d, -100, -height*(3-1)-100, width + 200, 100);
- 
-  add_static_box(box2d, -100, height, width + 200, 100);
-
-  add_static_box(box2d, -100, -(height*(5-1)) , 100, height * 5);
-  add_static_box(box2d, width, -(height*(5-1)) , 100, height * 5);
-}
 
 
 int main(int argc, char *argv[])
@@ -57,40 +28,27 @@
 
   Glib::RefPtr<Clutter::Box2D::Box2D> box2d = Clutter::Box2D::Box2D::create();
   stage->add_actor(box2d);
-  
-
-  add_cage(box2d, true /* roof */);
-
-  int y = 50;
-  int num_links = stage->get_height() / 20 - 2;
-  if((stage->get_width() / 20) < num_links)
-    num_links = stage->get_width() / 20;
 
+  //Add a actor around which the logo will rotate:
   Glib::RefPtr<Clutter::Rectangle> rect = Clutter::Rectangle::create();
-  rect->set_size(18, 5);
-  rect->set_position(stage->get_width() / 2, y);
   box2d->add_actor(rect);
-
-  box2d->set_child_mode(rect, Clutter::Box2D::BOX2D_STATIC);
-
-  Glib::RefPtr<Clutter::Actor> prev_actor = rect;
-
-  for(int i = 0; i < num_links; ++i)
-  {
-    Glib::RefPtr<Clutter::Rectangle> box = Clutter::Rectangle::create();
-    box->set_size(18, 5);
-    box->set_position(20 + 20 * i, y+=1);
-    box2d->add_actor(box);
-
-    box2d->set_child_manipulatable(box);
-    box2d->set_child_mode(box, Clutter::Box2D::BOX2D_DYNAMIC);
-
-    Clutter::Vertex anchor1( CLUTTER_UNITS_FROM_FLOAT (18), CLUTTER_UNITS_FROM_FLOAT (0.0), 0 );
-    Clutter::Vertex anchor2( CLUTTER_UNITS_FROM_FLOAT (0.0), CLUTTER_UNITS_FROM_FLOAT (0.0), 0);
-    box2d->add_revolute_joint(prev_actor, box, anchor1, anchor2, 0.0);
-   
-    prev_actor = box;
-  }
+  rect->set_size(10, 10);
+  rect->set_position(stage->get_width() / 2, stage->get_height() / 2);
+  box2d->set_child_mode(rect, Clutter::Box2D::BOX2D_STATIC); //It does not move.
+
+  //Add an actor that can rotate around the central actor:
+  Glib::RefPtr<Clutter::Texture> texture = Clutter::Texture::create();
+  texture->set_from_file("gnome_logo.png");
+  box2d->add_actor(texture);
+  texture->set_opacity(1.0 * 255);
+  texture->set_position(50, 50);
+  box2d->set_child_mode(texture, Clutter::Box2D::BOX2D_DYNAMIC); //It moves.
+  box2d->set_child_manipulatable(texture); //It can be moved with the mouse.
+  
+  //Add a joint:
+  Clutter::Vertex anchor1( CLUTTER_UNITS_FROM_FLOAT (rect->get_width()/2), CLUTTER_UNITS_FROM_FLOAT (rect->get_height()/2), 0 );
+  Clutter::Vertex anchor2( CLUTTER_UNITS_FROM_FLOAT (texture->get_width()/2), CLUTTER_UNITS_FROM_FLOAT (texture->get_height()/2), 0);
+  box2d->add_distance_joint(rect, texture, anchor1, anchor2, 100.0);
 
   box2d->set_simulating();
 

Modified: clutter-box2dmm/trunk/examples/slides/main.cc
==============================================================================
--- clutter-box2dmm/trunk/examples/slides/main.cc	(original)
+++ clutter-box2dmm/trunk/examples/slides/main.cc	Mon Aug 11 08:31:41 2008
@@ -52,7 +52,7 @@
 
   Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::get_default();
   stage->set_color( Clutter::Color(0x00, 0x00, 0x00, 0xff) );
-  stage->set_size(800, 600);
+  stage->set_size(500, 500);
   stage->set_title("Clutter::Box2D Example");
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]