Début due code de génération d'un "bruit de Perlin".

This commit is contained in:
Yoann 2011-09-29 22:48:03 +02:00
parent bc57c974f7
commit 471ccdb30f
2 changed files with 24 additions and 2 deletions

22
roam.c
View File

@ -1,6 +1,5 @@
#include "roam.h"
#include <stdio.h>
#include <stdlib.h>
/* Implémentation de ROAM
* http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.22.1811&rep=rep1&type=pdf
*
@ -35,6 +34,25 @@
*
*/
/* Permet de récupérer la taille de la base du triangle (hypoténuse).*/
// TODO Optimisze la fonction pour éviter la racine carée.
int getFirstTriangleSize(Triangle* t) {
return sqrt(((t->vRight->x - t->vLeft->x)^2) + ((t->vRight->y - t->vLeft->y)^2));
}
short** PerlinNoise(Triangle* t) {
short **values;
int triangleSize = getFirstTriangleSize(t);
int i;
values = (short**) malloc(sizeof(short*)*triangleSize);
for(i=0; i<triangleSize;i++)
values[i] = (short*) malloc(sizeof(short)*triangleSize);
// TODO Yoann : tout le reste.
return values;
}
int get_z(int x, int y) {
x = x; /* Unused */
y = y; /* Unused */

4
roam.h
View File

@ -1,3 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedef struct Vertex {
int x;
int y;