Generation aléatoire de terrain cubique ??

Résolu/Fermé
huzok Messages postés 12 Date d'inscription samedi 12 août 2017 Statut Membre Dernière intervention 10 février 2018 - 19 août 2017 à 14:50
yg_be Messages postés 22717 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 22 avril 2024 - 19 août 2017 à 20:08
Salut !

j'ai pour projet de recréer minecraft.

le probleme est que je ne sais creer de terrain cubique aléatoire.

Quelqu'un peut m'aider ?


je met ma classe main ici :

import org.lwjgl.util.vector.Vector3f;

import fr.indiev.MineCraft.render.Camera;
import fr.indiev.MineCraft.render.DisplayManager;
import static org.lwjgl.opengl.GL11.*;

public class Main {

boolean running = false;

Camera cam;

public Main() {
DisplayManager.create(1920, 1080, "Minecraft 2.0");
cam = new Camera(new Vector3f(0, 0, 0));
cam.setPerspectiveProjection(70f, 0.1f, 1000.0f);
}

public void start() {
running = true;
loop();
}

public void stop() {
running = false;
}

public void exit() {
DisplayManager.dispose();
System.exit(0);
}

public void loop() {
while(running) {
if (DisplayManager.isClosed()) stop();
DisplayManager.update();
render();
}
exit();
}

public void render() {
cam.getPerspectiveProjection();
}

public static void main(String[] args) {
Main main = new Main();
main.start();
}

}


ma classe pour la fenêtre la :

public class DisplayManager {
public static void create(int width, int height, String title) {
try {
Display.setDisplayMode(new DisplayMode(width, height));
Display.setTitle(title);

Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
}
}

public static void update() {
Display.update();
}

public static void clearBuffers() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

public static boolean isClosed() {
return Display.isCloseRequested();
}

public static void dispose() {
Display.destroy();
}
}


Et ma cam ici

public class Camera {
private float fov;
private float zNear;
private float zFar;

private Vector3f position;

public Camera(Vector3f position) {
this.position= position;
}

public Camera setPerspectiveProjection(float fov, float zNear, float zFar) {
this.fov = fov;
this.zNear = zNear;
this.zFar = zFar;

return this;
}

public void getPerspectiveProjection() {
glEnable(GL_PROJECTION);
glLoadIdentity();
GLU.gluPerspective(fov, (float)Display.getWidth() / (float)Display.getHeight(), zNear, zFar);
glEnable(GL_MODELVIEW);
}

public Vector3f getPosition() {
return position;
}

public void setPosition(Vector3f position) {
this.position = position;
}

}
A voir également:

1 réponse

yg_be Messages postés 22717 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 22 avril 2024 1 476
19 août 2017 à 16:52
peux-tu créer un terrain cubique non aléatoire?
es-tu bloqué par le fait qu'il est aléatoire?
0
huzok Messages postés 12 Date d'inscription samedi 12 août 2017 Statut Membre Dernière intervention 10 février 2018
19 août 2017 à 16:57
Non le fait qu'il soit aléatoire est secondaire. Je ne sais pas créer de terrain du tout ...
0
yg_be Messages postés 22717 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 22 avril 2024 1 476 > huzok Messages postés 12 Date d'inscription samedi 12 août 2017 Statut Membre Dernière intervention 10 février 2018
19 août 2017 à 17:34
as-tu décidé comment représenter ton terrain?
0
huzok Messages postés 12 Date d'inscription samedi 12 août 2017 Statut Membre Dernière intervention 10 février 2018
19 août 2017 à 18:07
c'est a dire representer ?? heightmap ?? je suis vraiment novice
0
yg_be Messages postés 22717 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 22 avril 2024 1 476 > huzok Messages postés 12 Date d'inscription samedi 12 août 2017 Statut Membre Dernière intervention 10 février 2018
19 août 2017 à 18:18
ton programme va travailler avec des données. ton terrain sera enregistré dans des variables.
as-tu décidé sous quelle forme tu vas enregistrer ton terrain dans ces variables?
0
huzok Messages postés 12 Date d'inscription samedi 12 août 2017 Statut Membre Dernière intervention 10 février 2018
Modifié le 19 août 2017 à 18:21
non . C'est ouf quand je vous parle je me rend compte de mon niveau bien nul xD
0