Loading...
Logo
Processing Forum
New-ish to Processing, hoping someone can help out or point me in the right direction for a project i'm working on.

I have some 3d models I've made and can be exported as .obj's, dae's , stl, etc. 

What I'd like to do is use Processing to load one or more 3d models and have it float around and seemingly bounce of the 
edges of a monitor  / rectangle, etc, and continue to do so.  Kind of how a DVD player logo will do but the x, y, and z coordinates change as well as the position.  

Any help would be great.  thanks.


Replies(4)

You can start by looking at the Processing examples. There are several sketches showing "balls" (actually simple circles) bouncing on the sketch bounds. (In the Motion section).
Another task is to locate a library able to load the model in one of the formats you can generate. I know there are several, but I never tried them.
Hint: take a look at the Related Posts links that Zoho kindly generated on the right of this thread...


look at this....



Copy code
  1. float CameraX;
  2. float CameraY;
  3. PVector ball = new PVector(330, 330, 0);
  4. PVector ballAdd = new PVector(.3, .4, -.3);
  5. PVector borderFirst   = new PVector(100, 100, -400);
  6. PVector borderSecond  = new PVector(600, 400, 0);
  7. void setup()
  8. {
  9.   size( 800, 800, P3D );
  10.   CameraX = width / 2.0;
  11.   CameraY = 50;
  12.   noCursor();
  13. } // setup
  14. void draw()
  15. {
  16.   background(0);
  17.   stroke(111, 110, 110);
  18.   fill(111, 110, 110);
  19.   // ================================================== 
  20.   // camera
  21.   camera(
  22.   CameraX, CameraY, 700,
  23.   width/2.0, height/2.0, 0,
  24.   0, 1, 0);
  25.   // ==================================================
  26.   //
  27.   pushMatrix();
  28.   strokeWeight(5);
  29.   noStroke();
  30.   lights();
  31.   translate(ball.x, ball.y, ball.z);
  32.   sphere(28);
  33.   popMatrix();
  34.   //
  35.   ball.x+=ballAdd.x;
  36.   ball.y+=ballAdd.y;
  37.   ball.z+=ballAdd.z;
  38.   //
  39.   if (ball.x>borderSecond.x)
  40.     ballAdd.x=-abs(ballAdd.x);
  41.   if (ball.x<borderFirst.x)
  42.     ballAdd.x=abs(ballAdd.x);   
  43.   if (ball.y>borderSecond.y)
  44.     ballAdd.y=-abs(ballAdd.y);
  45.   if (ball.y<borderFirst.y)
  46.     ballAdd.y=abs(ballAdd.y);
  47.   if (ball.z<borderFirst.z)
  48.     ballAdd.z=abs(ballAdd.z);
  49.   if (ball.z>borderSecond.z)
  50.     ballAdd.z=-abs(ballAdd.z);   
  51.   //
  52.   stroke(255);
  53.   strokeWeight(1);
  54.   line (borderSecond.x, borderSecond.y, borderSecond.z, borderSecond.x, borderFirst.y, borderSecond.z);
  55.   line (borderFirst.x, borderSecond.y, borderSecond.z, borderSecond.x, borderSecond.y, borderSecond.z);
  56.   line (400, 400, -400, 400, 100, -400);
  57.   line (100, 400, -400, 400, 400, -400);   
  58.   //
  59. } // draw
  60. void keyPressed() {
  61.   if (key == CODED) {
  62.     if (keyCode == UP) {
  63.       CameraY-=10;
  64.     }
  65.     else if (keyCode == DOWN) {
  66.       CameraY+=10;
  67.     }
  68.     else if (keyCode == RIGHT) {
  69.       CameraX+=10;
  70.     }
  71.     else if (keyCode == LEFT) {
  72.       CameraX-=10;
  73.     }
  74.     else {
  75.       // nothing
  76.     }
  77.   }
  78.   else { 
  79.     // not key == CODED
  80.     //
  81.   }
  82. }
  83. //

this is great, thanks Chrisir.