public void run() { /** * /////test part//// mPoint testp1 = new mPoint(1,1,3,0.5f); mPoint testp2 = new * mPoint(70,50,20,0.5f); // mMath.LinearInterpolation(testp1,testp2); // * System.out.println(testp1.x+" \n"+testp2.x); * * <p>canvas.drawLine(testp1,testp2); * * <p>// mPoint3 p[] = {new mPoint3(1,2,3),new mPoint3(2,1,3),new mPoint3(3,4,5)}; mPoint p[] = * {new mPoint(70,1,3,1),new mPoint(1,40,3,1),new mPoint(70,60,5,1)}; canvas.fillTriangle(p); */ /** * --the way to create objects in a world mOject obj = new mObject(...); mWorld w = new * mWorld(); w.add(obj); --draw it mCamera cam = new mCamera(...); cam.capture(w); //cam will * refresh the bufferedImage own.repaint(); //will refresh the window with bufferedImage */ mCube cube = new mCube(new mPoint3(0, 90, -80), 100, 100, 100); // mCube cube2 = new mCube(new mPoint3(-300,300,0),500,500,500); mCone cone = new mCone(new mPoint3(0, 50, 0), 80, 200); mObject obj = new mObject(); obj = createRandomSurface(obj, 0, 200, 60, 260); /*obj.shape = new mShape(); obj.pos=new mPoint3(50,0,0); mPoint3[] points={ obj.pos, new mPoint3(50,50,0), new mPoint3(100,0,0), new mPoint3(100,50,0) }; short[][] tripoints = { {0,0}, {3,2}, {1,3} }; short[][] linepoints = new short[2][0]; obj.center = new mVector3(0,0,0); obj.shape.set(points,linepoints,tripoints); obj.refer = new mReferenceTransformation(new mPoint3(obj.pos,obj.center), new mVector3(0,1,0), new mVector3(1,0,0));*/ mGrid grid = new mGrid(100); mWorld w = new mWorld(); w.add(cube); // w.add(cube2); w.add(grid); w.add(cone); w.add(obj); mCamera cam = new mCamera(canvas); cam.capture(w); own.repaint(speed); /* CoordinateTransformation.test(); mTriangle tri = new mTriangle(p); /* for(int i=0;i<20;i++){ cube.rotate((float)Math.PI/40,(float)Math.PI/40,(float)Math.PI/40); cube.move(new mVector3(0,5,0)); try{ this.sleep(90); }catch(InterruptedException e){ System.err.println(e.getMessage()); } canvas.clear(); cam.capture(w); own.repaint(); }//*/ for (int i = 0; i < 10; i++) { cube.rotate(0, (float) Math.PI / 20, (float) Math.PI / 20); // (float)Math.PI/20); cube.move(new mVector3(10, 0, 10)); try { this.sleep(speed); } catch (InterruptedException e) { System.err.println(e.getMessage()); } canvas.clear(); cam.capture(w); own.repaint(speed); // timeout = 60 } // */ for (int i = 0; i < 20; i++) { cube.rotate((float) Math.PI / 40, 0, (float) Math.PI / 40); // (float)Math.PI/20); cube.move(new mVector3(-10, -5, 0)); try { this.sleep(speed); } catch (InterruptedException e) { System.err.println(e.getMessage()); } canvas.clear(); cam.capture(w); own.repaint(speed); } // */ // int time = 0; while (true) { cam.rotate((float) Math.PI / 30, 0, 0); // time++; // float move = 30*(float)Math.sin((float)time/5); // cam.move(new mVector3(move,move,move)); try { this.sleep(speed); } catch (InterruptedException e) { System.err.println(e.getMessage()); } canvas.clear(); cam.capture(w); own.repaint(speed); } // */ }
/** rotateThread constructer initialize the Component mCanvas BufferedImage Graphics */ public rotateThread(Component owner, BufferedImage bufimg) { this.own = owner; this.bufimg = bufimg; canvas = new mCanvas(bufimg.getWidth(), bufimg.getHeight(), own, bufimg); canvas.setCurcolor(mMath.toRGB(255, 255, 255, 0)); }