// ------ heightfield ------
static Vec3 hfield_vertex(float u, float v, float h, float xsz,
- float ysz, float height)
+ float ysz, float height)
{
float x = u * xsz - xsz / 2.0;
float y = h * height;
}
void gen_heightfield(Mesh *mesh, float xsz, float ysz, float height, int usub,
- int vsub, float (*calc_height)(float u, float v, void *ptr), void *ptr)
+ int vsub, float (*calc_height)(float u, float v, void *ptr), void *ptr)
{
- /*
+ /*
usub and vsub is the number of subdivision at each axis
- (heightfield = grid)
+ (heightfield = grid)
*/
if(usub < 1)
usub = 1;
slopes in x, z, axis */
Vec3 tangent = hfield_vertex(u + du, v, calc_height(u + du, v, ptr),
- xsz, ysz, height) - vtx;
+ xsz, ysz, height) - vtx;
Vec3 bitangent = hfield_vertex(u, v + dv, calc_height(u, v + dv, ptr),
- xsz, ysz, height) - vtx;
+ xsz, ysz, height) - vtx;
Vec3 normal = normalize(cross(bitangent, tangent));
}
/*
- indices:
+ indices:
*/
uint16_t *iptr = &mesh->indices[0];