More actions
imported>ppparkje No edit summary |
imported>ppparkje No edit summary |
||
| Line 12: | Line 12: | ||
m_cam = world.getCamera(); | m_cam = world.getCamera(); | ||
// | // light mass | ||
world.setAmbientLight(0xff, 0xff, 0xff); | world.setAmbientLight(0xff, 0xff, 0xff); | ||
float[] coordinates = { | // making background plane | ||
float[] coordinates = { // position of vertices | |||
0.0f, 0.0f, 0.0f, | 0.0f, 0.0f, 0.0f, | ||
m_width, 0.0f, 0.0f, | m_width, 0.0f, 0.0f, | ||
| Line 22: | Line 23: | ||
}; | }; | ||
float[] uvs = { | float[] uvs = { // how uv mapped? | ||
0.0f, 0.0f, | 0.0f, 0.0f, | ||
1.0f, 0.0f, | 1.0f, 0.0f, | ||
| Line 29: | Line 30: | ||
}; | }; | ||
int[] indices = { | int[] indices = { // index of each coordinate | ||
0, 2, 1, | 0, 2, 1, | ||
1, 2, 3 | 1, 2, 3 | ||
}; | }; | ||
// make plane | |||
Object3D plane = new Object3D(coordinates, uvs, indices, RMObject2D.getTextureIDByColor(Color.white)); | |||
Object3D plane = new Object3D(coordinates, uvs, indices, | |||
plane.build(); | plane.build(); | ||
Util.LOGD("center: " + plane.getTransformedCenter()); | Util.LOGD("center: " + plane.getTransformedCenter()); | ||
| Line 48: | Line 47: | ||
box.addToWorld(world); | box.addToWorld(world); | ||
// FOV settings | |||
m_cam.setFOVLimits(0.1f, 2.0f); | m_cam.setFOVLimits(0.1f, 2.0f); | ||
m_cam.setFOV(0.1f); | m_cam.setFOV(0.1f); | ||
m_cam.setPosition(m_width/2, m_height/2, (float) -(m_width/2/Math.tan(m_cam.getFOV()/ | |||
// set up camera | |||
// z = (width/2) / tan(fov/2) | |||
m_cam.setPosition(m_width/2, m_height/2, (float) -(m_width/2/Math.tan(m_cam.getFOV()/2.0f))); | |||
m_cam.lookAt(plane.getTransformedCenter()); | m_cam.lookAt(plane.getTransformedCenter()); | ||
fixCubePosition(); | fixCubePosition(); | ||
// configuration to view far object | |||
Config.farPlane = Math.abs(m_cam.getPosition().z) + 1000f; | Config.farPlane = Math.abs(m_cam.getPosition().z) + 1000f; | ||
} | } | ||
// make framebuffer | |||
if(buffer != null) | if(buffer != null) | ||
buffer.dispose(); | buffer.dispose(); | ||
Revision as of 01:19, 28 July 2012
Orthogonal projection coordinate system 만들기
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();
// light mass
world.setAmbientLight(0xff, 0xff, 0xff);
// making background plane
float[] coordinates = { // position of vertices
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 = { // how uv mapped?
0.0f, 0.0f,
1.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f
};
int[] indices = { // index of each coordinate
0, 2, 1,
1, 2, 3
};
// make plane
Object3D plane = new Object3D(coordinates, uvs, indices, RMObject2D.getTextureIDByColor(Color.white));
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);
// FOV settings
m_cam.setFOVLimits(0.1f, 2.0f);
m_cam.setFOV(0.1f);
// set up camera
// z = (width/2) / tan(fov/2)
m_cam.setPosition(m_width/2, m_height/2, (float) -(m_width/2/Math.tan(m_cam.getFOV()/2.0f)));
m_cam.lookAt(plane.getTransformedCenter());
fixCubePosition();
// configuration to view far object
Config.farPlane = Math.abs(m_cam.getPosition().z) + 1000f;
}
// make framebuffer
if(buffer != null)
buffer.dispose();
buffer = new FrameBuffer(m_width, m_height, FrameBuffer.SAMPLINGMODE_NORMAL);
}