U E D R , A S I H C RSS

Code/RPGMaker (rev. 1.10)

Code/RPG Maker

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);

                        // 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);
        }


FillBox class

package cau.rpg.maker.object;

import java.awt.Color;

import javax.vecmath.Vector2f;

import com.threed.jpct.Object3D;

public class RMFillBox extends RMObject2D {

        public RMFillBox(float x1, float y1, float x2, float y2, Color color)
        {
                init(x1, y1, x2, y2, color);
        }

        public RMFillBox(Vector2f vStart, Vector2f vEnd, Color color)
        {
                init(vStart.x, vStart.y, vEnd.x, vEnd.y, color);
        }

        private void init(float x1, float y1, float x2, float y2, Color color)
        {
                if(x1 >= x2 || y1 >= y2)
                        return;

                float z = -10f;

                float[] coords = {
                        x1, y1, z,              // up left
                        x1, y2, z,              // bottom left
                        x2, y1, z,              // up right
                        x2, y2, z               // bottom right corner
                };

                float[] uvs = {
                        0f, 0f,
                        0f, 1f,
                        1f, 0f,
                        1f, 1f
                };

                int[] indices = {
                        0, 1, 2,
                        2, 1, 3
                };

                m_polygon = new Object3D(coords, uvs, indices, getTextureIDByColor(color));
        }
}


2D line class

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:57
Processing time 0.0189 sec