We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
Answers
Please Format your code. Edit your post (gear on top right side of any of your posts), select your code and hit ctrl+o. Leave an empty line above and below your block of code. Details here: https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text
For the second question, you can check previous relevant posts: https://forum.processing.org/two/search?Search=OBJModel
Kf