Hello there i was playing in Processing2 and found a example that would look very cool with one of my friends objects files but i dont see a tutorial about merging code because the other code or example i would have to merge would have to be the one that allows me to import a object file into Processing2 and altho it looks simple i got several errors when i try to run and then when it did ran after i changed things around i got the normal example to run but the obj imported did not show up but i can tell that it is in there because the example was running a little laggy then before i started to mergea little pointer would go along way fellows.
now i included below the normal example found in Processing, what im asking if someone can tell me where i should be copying and pasting the example that lets me import object files which i think is under OBJloader?
import saito.objloader.*;
OBJModel model ;
float rotX, rotY;
void setup()
{
size(800, 600, P3D);
frameRate(30);
model = new OBJModel(this, "dma.obj", "absolute", TRIANGLES);
model.enableDebug();
model.scale(20);
model.translateToCenter();
stroke(255);
noStroke();
}
void draw()
{
background(129);
lights();
pushMatrix();
translate(width/2, height/2, 0);
rotateX(rotY);
rotateY(rotX);
model.draw();
popMatrix();
}
and here is the other one i would like to merge this top one to the one in the bottom
void setup()
{
size(1800, 900, P3D);
cursor(CROSS);
terrain = new Terrain(this, 60, terrainSize, horizon);
terrain.usePerlinNoiseMap(0, 40, 0.15f, 0.15f);
terrain.setTexture("grass2.jpg", 4);
terrain.tag = "Ground";
terrain.tagNo = -1;
terrain.drawMode(S3D.TEXTURE);
skybox = new Box(this, 1000, 500, 1000);
skybox.setTexture("back.jpg", Box.FRONT);
skybox.setTexture("front.jpg", Box.BACK);
skybox.setTexture("left.jpg", Box.LEFT);
skybox.setTexture("right.jpg", Box.RIGHT);
skybox.setTexture("sky.jpg", Box.TOP);
skybox.visible(false, Box.BOTTOM);
skybox.drawMode(S3D.TEXTURE);
skybox.tag = "Skybox";
skybox.tagNo = -1;
nbrDroids = 16;
droids = new Cone[nbrDroids];
droidDirs = new PVector[nbrDroids];
for (int i = 0; i < nbrDroids; i++)
{
droids[i] = new Cone(this, 10);
droids[i].setSize(5, 5, -20);
droids[i].moveTo(getRandomPosOnTerrain(terrain, terrainSize, 50));
droids[i].tagNo = 100;
droids[i].fill(color(random(128, 255), random(128, 255), random(128, 255)));
droids[i].drawMode(S3D.SOLID);
droidDirs[i] = getRandomVelocity(random(15, 25));
terrain.addShape(droids[i]);
}
obelisk = new Ellipsoid(this, 4, 20);
obelisk.setRadius(5, 30, 5);
obelisk.moveTo(getRandomPosOnTerrain(terrain, terrainSize, 28));
obelisk.fill(color(0, 255, 0));
obelisk.tag = "Globe";
obelisk.tagNo = 1;
obelisk.setTexture(textures[1]);
obelisk.drawMode(S3D.TEXTURE);
tube = new Tube(this, 10, 30);
tube.setSize(3, 10, 6, 6, 20);
tube.moveTo(getRandomPosOnTerrain(terrain, terrainSize, 15.5));
tube.tagNo = 0;
tube.setTexture(textures[1]);
tube.drawMode(S3D.TEXTURE);
tube.fill(color(255, 0, 0), Tube.S_CAP);
tube.fill(color(0, 255, 0), Tube.E_CAP);
tube.drawMode(S3D.SOLID, Tube.BOTH_CAP);
camSpeed = 0;
cam = new TerrainCam(this);
cam.adjustToTerrain(terrain, Terrain.WRAP, camHoversAt);
cam.camera();
cam.speed(camSpeed);
cam.forward.set(cam.lookDir());
terrain.cam = cam; // Tell the terrain what camera to use
time = millis();
}
and this is the loop
void draw()
{
background(0);
// Get elapsed time
long t = millis() - time;
time = millis();
update(t/1000.0); // Update shapes on terrain
if (mousePressed) // Update camera speed and direction
processMousePressed();
if (keyPressed)
processKeyPressed(t);
if (clicked) // Clicked on artefact?
processMouseClick();
cam.move(t/250.0); //1000
// Calculate amount of movement based on velocity and time
// Adjust the cameras position so we are over the terrain
// at the given height.
cam.adjustToTerrain(terrain, Terrain.WRAP, camHoversAt);
// Set the camera view before drawing
cam.camera();
obelisk.draw();
tube.draw();
terrain.draw();
// Get rid of directional lights so skybox is evenly lit.
skybox.moveTo(cam.eye().x, 0, cam.eye().z);
skybox.draw();
}