import processing.opengl.*; import javax.media.opengl.*; import javax.media.opengl.glu.*; import javax.vecmath.Vector3f; import com.bulletphysics.dynamics.RigidBody; import BPSGR.*; PFont font; int n_viewpoint = 1; BPSGR demo; void setup() { size(800, 600, OPENGL); font=createFont("FFScala", 32); PGraphicsOpenGL pgl = (PGraphicsOpenGL) g; // g may change GL gl = pgl.beginGL(); // always use the GL object returned by beginGL demo = new BPSGR(this, gl); pgl.endGL(); demo.initPhysics(); // // 中央に箱集合を設置 // demo.putBoxArray( 集合体の座標最下段中央底面の中心座標(0,0,0), 箱の数:縦横奥行(3,20,3), 箱の重さ(0.1kg), 箱の大きさ(1辺の長さ)2; demo.putBoxArray( 0, 0, 0, 3, 20, 3, 0.1 ,2); // 初期始点向かって手前に、質量が大きい立方体の箱集合を作成 // demo.putBoxArray( 集合体の座標最下段中央底面の中心座標(0,0,0), 箱の数:縦横奥行(3,20,3), 箱の重さ(0.1kg), 箱の大きさ(1辺の長さ)2; demo.putBoxArray( 0, 0, 50, 4, 5, 4, 5 ,5); // 初期始点右側に直方体集合を設置 // demo.putBoxArrayEx( 集合体の座標最下段中央底面の中心座標(50,0,0), 箱の数:縦横奥行(1,16,1), 箱の重さ(0.5kg), 箱の大きさ(3辺の長さ); demo.putBoxArrayEx( 50, 0, 0, 1, 16, 1, 0.5, new Vector3f(2,8,2)); // 初期始点、左側広報に、シリンダ4つ+箱で作ったテーブルを作成 // その上に箱集合を作成 // シリンダを設置 // demo.putBoxArrayEx( 集合体の座標最下段中央底面の中心座標(50,0,0), 箱の数:縦横奥行(1,16,1), 箱の重さ(0.5kg), 箱の大きさ(3辺の長さ); demo.AddCylinder( 10f, new Vector3f(-25,10,-25), new Vector3f(0,1,0), 0, 2f,10f); demo.AddCylinder( 10f, new Vector3f(-40,10,-25), new Vector3f(0,1,0), 0, 2f,10f); demo.AddCylinder( 10f, new Vector3f(-25,10,-40), new Vector3f(0,1,0), 0, 2f,10f); demo.AddCylinder( 10f, new Vector3f(-40,10,-40), new Vector3f(0,1,0), 0, 2f,10f); demo.AddBox(5f, new Vector3f(-32, 20.5, -32), new Vector3f(0, 1, 0), radians(0), new Vector3f(20, 1, 20)); demo.putBoxArray( -32, 21, -32, 2, 5, 2, 0.5 ,4); // // 中央箱集合の頭上に空間に箱を1個設置(重力で下に落ちます) // demo.AddBox(箱の重さ 25kg, 箱の置く位置(0,150,0) 回転ベクトル(このベクトルを中心に物体を回転),回転量(0), 箱の3辺の長さ); demo.AddBox(25f, new Vector3f(0, 150, 0), new Vector3f(1, 1, 0), radians(45), new Vector3f(10, 10, 10)); } float[] pms = new float[10]; int n_pms = 0; Vector3f cameraPosition = new Vector3f(0f, 100f, 150f); Vector3f cameraTargetPosition = new Vector3f(0f, 0f, 0f); // look at void draw() { background(208); GLU glu = new GLU(); float ms = millis(); if (demo.dynamicsWorld != null) { demo.dynamicsWorld.stepSimulation(ms / 1000000f); // demo.dynamicsWorld.stepSimulation(ms / 1f); } PGraphicsOpenGL pgl = (PGraphicsOpenGL) g; // g may change GL gl = pgl.beginGL(); // always use the GL object returned by beginGL BPSGR.setPerspective(gl, width, height); glu.gluLookAt(cameraPosition.x,cameraPosition.y,cameraPosition.z , cameraTargetPosition.x, cameraTargetPosition.y, cameraTargetPosition.z , 0, 1, 0); gl.glPushMatrix(); demo.render(); gl.glPopMatrix(); pgl.endGL(); //--------------display fps --------- // println(millis()); textFont(font,30.0); stroke(1,0,0); fill(200,0,0); int i; if(n_pms==10) { for(i=0; i