一,配置环境
1.需要的jar包
jar包的下载地址在这里
二,代码
1,GlPoint类
/**
* 自定义的点类,存储x和y值
* @author mcl
*
*/
public class GlPoint {
float x = 0.00f;
float y = 0.00f;
public GlPoint() {
}
public GlPoint(float x, float y) {
this.x = x;
this.y = y;
}
public float getX() {
return x;
}
public void setX(float x) {
this.x = x;
}
public float getY() {
return y;
}
public void setY(float y) {
this.y = y;
}
}
2,TreeAnimation类
import javax.swing.JFrame;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.awt.GLCanvas;
/**
* 实现GLEventListener接口
* @author mcl
*
*/
public class TreeAnimation implements GLEventListener{
static final String START_POINT_X = "START_POINT_X";
static final String START_POINT_Y = "START_POINT_Y";
static final String END_POINT_X = "END_POINT_X";
static final String END_POINT_Y = "END_POINT_Y";
double partition = 10.0;
JSONArray jsonArray = new JSONArray();
JSONArray jsonArray1 = new JSONArray();
JSONArray jsonArray2 = new JSONArray();
JSONArray jsonArray3 = new JSONArray();
JSONArray jsonArray4 = new JSONArray();
JSONArray jsonArray5 = new JSONArray();
JSONArray jsonArray6 = new JSONArray();
JSONArray jsonArray7 = new JSONArray();
@Ove