java
public void onSurfaceChanged(GL10 gl, int width, int height) {
this.m_width = width;
this.m_height = height;
if(buffer == null) {
Util.LOGD("make framebuffer");
world = new World();
m_cam = world.getCamera();
// 빛 강도 설정
world.setAmbientLight(0xff, 0xff, 0xff);
float[] coordinates = {
0.0f, 0.0f, 0.0f,
m_width, 0.0f, 0.0f,
0.0f, m_height, 0.0f,
m_width, m_height, 0.0f
};
float[] uvs = {
0.0f, 0.0f,
1.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f
};
int[] indices = {
0, 2, 1,
1, 2, 3
};
TextureManager.getInstance().addTexture("test", new Texture(256, 256, Color.white));
TextureManager.getInstance().addTexture("test1", new Texture(256, 256, Color.gray));
int tID = TextureManager.getInstance().getTextureID("test");
Object3D plane = new Object3D(coordinates, uvs, indices, tID);
plane.build();
Util.LOGD("center: " + plane.getTransformedCenter());
world.addObject(plane);
RMLine line = new RMLine(new Vector2f(-100, -100), new Vector2f(200, 200), 2, Color.blue);
line.addToWorld(world);
RMFillBox box = new RMFillBox(100, 100, 200, 200, Color.black);
box.addToWorld(world);
m_cam.setFOVLimits(0.1f, 2.0f);
m_cam.setFOV(0.1f);
m_cam.setPosition(m_width/2, m_height/2, (float) -(m_width/2/Math.tan(m_cam.getFOV()/2f)));
m_cam.lookAt(plane.getTransformedCenter());
fixCubePosition();
Config.farPlane = Math.abs(m_cam.getPosition().z) + 1000f;
}
if(buffer != null)
buffer.dispose();
buffer = new FrameBuffer(m_width, m_height, FrameBuffer.SAMPLINGMODE_NORMAL);
}