LibGDX - How do you turn a mesh into a model?

I am having some trouble with my game. I have a mesh being generated with random terrain using simplex noise. The problem is that the texture I am giving the mesh is solid green, so when you are looking at the terrain you cannot see the hills very well.

So what I would like to do is render the mesh as a model so that the lighting that gets applied to my models also gets applied to the terrain. But I have looked online for quite a while now and not found anything regarding this subject.

I do not need a solution to this problem. Even just a direction to point me towards would be extremely helpful. Thank you in advance. :smiley:

Generate normals too. :point:

Thanks for the reply, but how would that help? Maybe a little more imformation could be helpful. :smiley:

You asked merely for ‘direction to be pointed towards’, hence my short reply.

Anyway, lighting is mainly calculated using surface normals. You can’t just send xyz-coords to a GPU and expect them to be shaded. You have to at least provide surface normals. You can use google to check out what surface normals are, how to calculate them, and how to pass them to the GPU.

Im not knowledgable in hardware accelerated graphics, however with my software rendering experience, I can tell you that a surface normal is calculated by


	private Vector calcNormal() {
		Vector normal = new Vector();
		Vector temp0 = new Vector();
		Vector temp1 = new Vector();
		// vertices3D is the array containing the vertices of each polygon/triangle (Vectors)
		temp0.set(vertices3D[1]); // Make actual Vectors from the vertices by doing end vertex minus start vertex
		temp0.subtract(vertices3D[0]); // temp0 is now the vector between the first vertex and the second.
		temp1.set(vertices3D[2]);
		temp1.subtract(vertices3D[0]); // temp1 is now the vector between the first vertex and the third.
		normal.setToCross(temp0, temp1); // find the vector orthogonal to the two vectors that represent the surface of the polygon/tri.
		normal.unit(); // make it a unit vector since you don't want a magnitude greater than 1 for a normal which is a direction vector.
		return normal;
	}


// these are in the Vector class

	public Vector subtract(Vector v) {
		x -= v.x;
		y -= v.y;
		z -= v.z;
		return this;
	}

	public Vector unit() {
		float invMag = 1 / magnitude();
		x *= invMag;
		y *= invMag;
		z *= invMag;
		return this;
	}

	public float magnitude() {
		return (float) Math.sqrt(dot(this));
	}

	public float dot(Vector v) {
		return x * v.x + y * v.y + z * v.z;
	}

	public void setToCross(Vector a, Vector b) {
		this.x = a.y * b.z - a.z * b.y;
		this.y = a.z * b.x - a.x * b.z;
		this.z = a.x * b.y - a.y * b.x;
	}

EDIT: is this spoon feeding? :persecutioncomplex: ???