Rotating object centering

edited November 2017 in Questions about Code

Hi, I use a sample code for object loading and rotation. I would like to:

1) Rotate the object around it's centroind. Now is the object placed with some offsett above the center of rotation. It can be done in Processing code or in obj creator?

The code for drawing is here:

background(0,0,0);

  // Set a new co-ordinate space
  pushMatrix();

  // Simple 3 point lighting for dramatic effect.
  // Slightly red light in upper right, slightly blue light in upper left, and white light from behind.
  pointLight(255, 200, 200,  400, 400,  500);
  pointLight(200, 200, 255, -400, 400,  500);
  pointLight(255, 255, 255,    0,   0, -500);

  // Move bunny from 0,0 in upper left corner to roughly center of screen.
  translate(300, 380, 0);

  // Rotate shapes around the X/Y/Z axis (values in radians, 0..Pi*2)
  rotateZ(radians(roll));
  rotateX(radians(pitch));
  rotateY(radians(yaw));

  pushMatrix();
  noStroke();
  model.draw();
  popMatrix();
  popMatrix();
  //print("draw");

2) Load other object than bunny.obj. But, when I download and use any .obj sample, it can't be loaded. Where is the problem? The code is:``

      OBJModel model;
      size(640, 480, OPENGL);
      frameRate(30);
      model = new OBJModel(this);
      model.load("bunny.obj");
      model.scale(20);

and saito obj loader is used. Can you recommend me any other method?

Can you help me please?

The full code is here: https://files.fm/u/6uq5n95y

Tagged:

Answers

Sign In or Register to comment.