these are codes i have written so far...but i wanna be able to use the 3d shuttle image (3ds format) and make it orbit the earth. I tried to use the mri3ds library but was unseccessful. do you have any idea ?
public class Shuttle{
// class variables
PImage _img;
private float xpos,ypos,zpos;
private float theta,gamma;
// constructor
public Shuttle(float x,float y, float z,
PImage i){
i know i should not be using PImage because it doesnt retrieve the image as 3D
xpos = x;
ypos = y;
zpos = z;
_img = i;
}
public void update(){
theta += 0.05;
gamma += 0.01;
xpos = 80* cos(theta);
ypos = 80* sin (gamma) * cos(theta);
zpos = 80* cos(gamma);
}
public void draw() {
pushMatrix();
popMatrix();
}
}
the codes below are the main class
import mri.*;
import shapes3d.*;
//import guicomponents.*;
//import processing.opengl.*;
Ellipsoid Earth,sun,mars,stars;
Shuttle shuttle;
PImage myshuttle;
void setup()
{
size(1400,1200,P3D);
myshuttle = loadImage ("SpaceShuttleOrbiter.3ds");
// create a new instance of the shuttle class
shuttle = new Shuttle (200,0,-10,myshuttle);
// create sun
sun = new Ellipsoid(this,50,20);
sun.setTexture("sun.jpg");
sun.setRadius(100);
sun.moveTo(new PVector(700,400,-600));
sun.drawMode(Shape3D.TEXTURE);
// create mars
mars = new Ellipsoid(this,30,30);
mars.setTexture("mars.jpg");
mars.setRadius(60);
mars.moveTo(100,0,1000);
mars.drawMode(Shape3D.TEXTURE);
// create Earth
Earth = new Ellipsoid(this,30,30);
Earth.setTexture("Earthmap.jpg");
Earth.setRadius(69);
Earth.moveTo(-300,0,500);
Earth.drawMode(Shape3D.TEXTURE);
// create stars background
stars = new Ellipsoid(this,10,10);
stars.setTexture("3dstars.jpg",5,5);
stars.setRadius(2000);
stars.drawMode(Shape3D.TEXTURE);
// add child shape to sun
sun.addShape(Earth);
sun.addShape(mars);
frameRate(3);
}
void draw()
{
stars.rotateBy(0,radians(0.3),0);
Earth.rotateBy(0,radians(1),0);
sun.rotateBy(0,radians(1),0);
mars.rotateBy(0,radians(1),0);
background(0);
sun.draw();
stars.draw();
shuttle.update();
}