Need help in Graphics and import 3D !!!!!!
in
Contributed Library Questions
•
11 months ago
hello, i'm trying to make a program with processing, but i need to replace the object of the pg.graphics, with the obj 3D... And more, with a 3D that i can choose with the SelectInput().
But i modify all this code, who come from an other person, and i don't know how i can change, box() and everything, in a good obj viewer...
>.<
Would you help me just a little bit, that's can be great thank youuuuuuuuu!
the code (i think i make some mistake...):
But i modify all this code, who come from an other person, and i don't know how i can change, box() and everything, in a good obj viewer...
>.<
Would you help me just a little bit, that's can be great thank youuuuuuuuu!
the code (i think i make some mistake...):
- import controlP5.*;
ControlP5 cp5;
import saito.objloader.*;
import java.lang.reflect.*;
ControlWindow controlWindow;
Renderer renderers[];
OBJModel model;
float rotX;
float rotY;
public int DeplacerX = 0;
public int DeplacerY = 0;
public int RotationX = 0;
public int RotationY = 0;
public int RotationZ = 0;
public int Importer = 0;
public int DEMONSTRATION = 0;
public float Echelle = 1.00;
void setup()
{
size(displayHeight, displayHeight, P3D);
background(0);
///DECLARATION MODEL
model = new OBJModel(this, "MTECH.obj", "relative", QUADS);
model.enableDebug();
cp5 = new ControlP5(this);
controlWindow = cp5.addControlWindow("controlP5window", 100, 100, 600, 300)
.hideCoordinates()
.setBackground(color(150))
;
//////ROTATIONS
cp5.addSlider("RotationX")
.setRange(0, 360)
.setPosition(40, 40)
.setSize(200, 30)
.setWindow(controlWindow)
;
cp5.addSlider("RotationY")
.setRange(0, 360)
.setPosition(40, 80)
.setSize(200, 30)
.setWindow(controlWindow)
;
cp5.addSlider("RotationZ")
.setRange(0, 360)
.setPosition(40, 120)
.setSize(200, 30)
.setWindow(controlWindow)
;
//////DEPLACEMENTS
cp5.addSlider("DeplacerX")
.setRange(-100, 100)
.setPosition(300, 40)
.setSize(200, 30)
.setWindow(controlWindow)
;
cp5.addSlider("DeplacerY")
.setRange(-120, 120)
.setPosition(300, 80)
.setSize(200, 30)
.setWindow(controlWindow)
;
/////OPTIONS
cp5.addSlider("Echelle")
.setRange(0, 10)
.setPosition(40, 220)
.setSize(200, 15)
.setWindow(controlWindow)
;
cp5.addButton("Importer")
.setValue(0)
.setPosition(40, 160)
.setSize(100, 20)
.setWindow(controlWindow)
;
cp5.addButton("DEMONSTRATION")
.setValue(0)
.setPosition(40, 190)
.setSize(100, 20)
.setWindow(controlWindow)
;
renderers = new Renderer[4];
renderers[0] = new Renderer(this, width/4, 0, width/2, height/2);
renderers[1] = new Renderer(this, width/2, width/4, width/2, height/2);
renderers[2] = new Renderer(this, width/4, height/2, width/2, height/2);
renderers[3] = new Renderer(this, 0, height/4, width/2, height/2);
// Set views // VIEW ROTATION WARNING
renderers[0].setRotation( 270, 0, 0);
renderers[1].setRotation( 270, 90, 0); // NICKEL A TESTER sur installation (toutes)
renderers[2].setRotation( 90, 180, 0);
renderers[3].setRotation( 90, 90, 0);
}
void draw()
{
for (int i=0;i<renderers.length;i++) {
renderers[i].draw();
}
}
//// IMPORTATEUR
public void Importer(int theValue) {
selectInput("Select a file to process:", "fileselected");
}
void fileSelected(File selection) {
if (selection == null) {
println("Window was closed or the user hit cancel.");
}
else {
println("User selected " + selection.getAbsolutePath());
model = new OBJModel(this, "fileSelected", "relative", QUADS);
model.enableDebug();
//model = ; LAAAAAAAAAA
}
}
///DEMO NEURON
/*public void DEMONSTRATION(int theValue) {
DEMONSTRATION = 1
if (DEMONSTRATION = 1)
{
//NEURON?
}
}
*/
void drawRendererObject(Renderer r) //METTRE 3D A LA PLACE?
{
float fov = PI/4.0;
float cameraZ = (height/2.0) / tan(fov/2.0);
r.graphics().rotateX( map((RotationX+rotX)*5, 0, width, 0, PI) );
r.graphics().rotateY( map((RotationY+rotY)*5, 0, width, 0, PI) );
r.graphics().rotateZ( map(RotationZ*5, 0, width, 0, PI) );
r.graphics().translate(DeplacerX, 0, DeplacerY); // VERIFIER sur installation
r.graphics().scale(Echelle);
r.graphics().lights();
r.graphics().perspective(fov, float(width*100)/float(height*100), cameraZ/100.0, cameraZ*100.0);
//dessin :
//*
r.graphics().fill(255);
r.graphics().strokeWeight(0);
r.graphics().box(60);
r.graphics().translate(0, 60, 0);
r.graphics().fill(#74E9FF);
r.graphics().sphere(30);
r.graphics().sphereDetail(20);
// */
}
void mouseDragged()
{
rotY += (mouseX - pmouseX) ;
rotX -= (mouseY - pmouseY) ;
}
1