所以,我现在正在研究引擎问题:



关键是,它应该生成它们的16x16平台。

这是创建多维数据集的代码:

 private void render(){



        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT|GL11.GL_DEPTH_BUFFER_BIT);
        for(int x=0; x<16; x++){
            for(int z=0; z<16; z++) {


                b.renderBlock(x, 0, z, texture);

            }
        }

        glMatrixMode( GL_MODELVIEW );
        GL11.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
        GL11.glEnable(GL_CULL_FACE);
        GL11.glLoadIdentity();

    }


这应该渲染16x16平台的块

Block.java(b.renderblock)

package net.themorfeus.awesum.adventure.game;

import org.lwjgl.opengl.GL11;
import org.newdawn.slick.opengl.Texture;

public class Block {

    private float rquad = 0f;

    public void renderBlock(int posx, int posy, int posz, Texture t) {
        t.bind();
        //GL11.glLoadIdentity();                          // Reset The Current Modelview Matrix
        GL11.glTranslatef(posx,posy,posz);             // Move Right 1.5 Units And Into The Screen 6.0
        GL11.glRotatef(rquad,0.0f,0.0f,1.0f);               // Rotate The Quad On The X axis ( NEW )
        GL11.glColor3f(1.0f,1.0f,1.0f);                 // Set The Color To Blue One Time Only
        GL11.glBegin(GL11.GL_QUADS);                  // Draw A Quad
      //GL11.glColor3f(0.5f, 0.4f, 0.4f);             // Set The Color To Green
        GL11.glTexCoord2f(0,0);
        GL11.glVertex3f( 1f, 1f,-1f);         // Top Right Of The Quad (Top)
        GL11.glTexCoord2f(1,0);
        GL11.glVertex3f(-1f, 1f,-1f);         // Top Left Of The Quad (Top)
        GL11.glTexCoord2f(1,1);
        GL11.glVertex3f(-1f, 1f, 1f);         // Bottom Left Of The Quad (Top)
        GL11.glTexCoord2f(0,1);
        GL11.glVertex3f( 1f, 1f, 1f);         // Bottom Right Of The Quad (Top)

        //GL11.glColor3f(1.2f,0.5f,0.9f);             // Set The Color To Orange
        GL11.glTexCoord2f(0,0);
        GL11.glVertex3f( 1f,-1f, 1f);         // Top Right Of The Quad (Bottom)
        GL11.glTexCoord2f(0,1);
        GL11.glVertex3f(-1f,-1f, 1f);         // Top Left Of The Quad (Bottom)
        GL11.glTexCoord2f(1,1);
        GL11.glVertex3f(-1f,-1f,-1f);         // Bottom Left Of The Quad (Bottom)
        GL11.glTexCoord2f(1,0);
        GL11.glVertex3f( 1f,-1f,-1f);         // Bottom Right Of The Quad (Bottom)

        //GL11.glColor3f(1.0f,0.0f,0.0f);             // Set The Color To Red
        GL11.glTexCoord2f(0,0);
        GL11.glVertex3f( 1f, 1f, 1f);         // Top Right Of The Quad (Front)
        GL11.glTexCoord2f(1,0);
        GL11.glVertex3f(-1f, 1f, 1f);         // Top Left Of The Quad (Front)
        GL11.glTexCoord2f(1,1);
        GL11.glVertex3f(-1f,-1f, 1f);         // Bottom Left Of The Quad (Front)
        GL11.glTexCoord2f(0,1);
        GL11.glVertex3f( 1f,-1f, 1f);         // Bottom Right Of The Quad (Front)

        //GL11.glColor3f(1f,0.5f,0.0f);             // Set The Color To Yellow
        GL11.glTexCoord2f(0,0);
        GL11.glVertex3f( 1f,-1f,-1f);         // Bottom Left Of The Quad (Back)
        GL11.glTexCoord2f(1,0);
        GL11.glVertex3f(-1f,-1f,-1f);         // Bottom Right Of The Quad (Back)
        GL11.glTexCoord2f(1,1);
        GL11.glVertex3f(-1f, 1f,-1f);         // Top Right Of The Quad (Back)
        GL11.glTexCoord2f(0,1);
        GL11.glVertex3f( 1f, 1f,-1f);         // Top Left Of The Quad (Back)

        //GL11.glColor3f(0.0f,0.0f,0.3f);             // Set The Color To Blue
        GL11.glTexCoord2f(0,1);
        GL11.glVertex3f(-1f, 1f, 1f);         // Top Right Of The Quad (Left)
        GL11.glTexCoord2f(1,1);
        GL11.glVertex3f(-1f, 1f,-1f);         // Top Left Of The Quad (Left)
        GL11.glTexCoord2f(1,0);
        GL11.glVertex3f(-1f,-1f,-1f);         // Bottom Left Of The Quad (Left)
        GL11.glTexCoord2f(0,0);
        GL11.glVertex3f(-1f,-1f, 1f);         // Bottom Right Of The Quad (Left)

        //GL11.glColor3f(0.5f,0.0f,0.5f);             // Set The Color To Violet
        GL11.glTexCoord2f(0,0);
        GL11.glVertex3f( 1f, 1f,-1f);         // Top Right Of The Quad (Right)
        GL11.glTexCoord2f(1,0);
        GL11.glVertex3f( 1f, 1f, 1f);         // Top Left Of The Quad (Right)
        GL11.glTexCoord2f(1,1);
        GL11.glVertex3f( 1f,-1f, 1f);         // Bottom Left Of The Quad (Right)
        GL11.glTexCoord2f(0,1);
        GL11.glVertex3f( 1f,-1f,-1f);         // Bottom Right Of The Quad (Right)
        GL11.glEnd();
        //rquad+=0.0000001f;

    }




}


它基本上呈现块四边形。

最佳答案

您应该用glPushMatrix-glPopMatrix对围绕绘图/翻译。

关于java - OpenGL移动四边形,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9957105/

10-13 00:02