We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › How to draw a 3D car, tranlating along the road
Page Index Toggle Pages: 1
How to draw a 3D car, tranlating along the road? (Read 1851 times)
How to draw a 3D car, tranlating along the road?
Dec 15th, 2005, 5:36pm
 
Hi

whats the best way to draw a basic car (box's? vertexs?) with rotating wheels to move along a road? this all has to be in 3D ?
Re: How to draw a 3D car, tranlating along the roa
Reply #1 - Dec 15th, 2005, 7:32pm
 
This is a complex question. There many way to do it and it would be related to your goals.

If you need schematic representation, you could use a set of boxes and cylinders that you could move using popMatrix() and popMatrix(). http://processing.org/learning/examples/pushpop.html

If you need physic simulation like in this example: http://odejava.org/jws/jws-org.odejava.xith3d.test.CarExample.jnlp
See: http://processing.org/discourse/yabb_beta/YaBB.cgi?board=os_libraries_tools;action=display;num=1123794422
http://odejava.org/tiki-index.php

If you want to design a streamlined car, you could build something to represent complex surfaces width bezierPoint(). http://processing.org/reference/bezierPoint_.html Bézier was engineer for Renault and worked on curved lines to help draftmen working on round surfaces for cars.

If you prefer, you could import a préexisting model done in other software via the OBJLoader librairie. http://processing.org/discourse/yabb_beta/YaBB.cgi?board=os_libraries_tools;action=display;num=1114999115
Re: How to draw a 3D car, tranlating along the roa
Reply #2 - Dec 15th, 2005, 8:09pm
 
Is a set of boxes the best way ? eg to make a bonnet ? or is there a better way to draw a basic car? its only a schematic represetation... nothing special

eg.. it doesnt work doing it like this ?

void drawCar(){
//Car One

 pushMatrix();
 rotateY(-.9);
 translate(190, 400, za);
 drawBonnet();
 stroke(0);
 fill(255);
 box(40,30,40);
 popMatrix();  
 
}

void drawBonnet(){

 pushMatrix();
 rotateY(-.9);
 translate(270,350, zc);
 stroke(0);
 fill(255);
 box(30,15,20);
 popMatrix();
 
}

void drawTruck(){

 pushMatrix();
 rotateY(-.9);
 translate(305, 415, zb);
 stroke(0);
 fill(0, 126, 255);
 box(20);
 popMatrix();
 

any ideas why ?
Re: How to draw a 3D car, tranlating along the roa
Reply #3 - Dec 18th, 2005, 11:44pm
 
Code:

import processing.opengl.*;
void setup(){
size(400,200,OPENGL);
}

void draw(){
background(255);

//MoveAlongPath or General Transformations
pushMatrix();

translate(width/2,height/2,-100);
rotateX(mouseX/(float)width*2*PI);
rotateY(mouseY/(float)height*2*PI);

drawCar();

popMatrix();

}

void drawCar(){


float d = noise((frameCount+100)/100f)*50;
float w = noise((frameCount+200)/100f)*150;
float h = noise((frameCount+320)/100f)*300;
float k = noise((frameCount+520)/100f)*50;

fill(#776656);
pushMatrix();
translate(0,0,0);
box(w,h,d);
popMatrix();

pushMatrix();
translate(0,-h*0.16666f,-d);
box(w*0.85f,h*0.3333f,d);
popMatrix();


fill(#998878);
pushMatrix();
translate(w/2f,-h/2*0.75f,k);
rotateX(frameCount/10f);
box(w/10f,k,k);
popMatrix();

pushMatrix();
translate(w/2f,h/2*0.75f,k);
rotateX(frameCount/10f);
box(w/10f,k,k);
popMatrix();

pushMatrix();
translate(-w/2f,-h/2*0.75f,k);
rotateX(frameCount/10f);
box(w/10f,k,k);
popMatrix();

pushMatrix();
translate(-w/2f,h/2*0.75f,k);
rotateX(frameCount/10f);
box(w/10f,k,k);
popMatrix();

}


I'm not sure it's the kind of car I would drive.
Page Index Toggle Pages: 1