Can someone give me a code sample that renders 2 cubes at different Z-axis?

Started by Peilot, January 24, 2017, 15:56:10

Previous topic - Next topic

Peilot

Since I've had trouble rendering on Z-axis, I would like to see how you do it!

bobjob

have you tried having a look at the LWJGL Demos?

to draw a cube at a different z level.

Either create 2 cubes with different z values (not what you want), or simply translate the mesh then re draw it.

notice the model translate method in the code:
model
	.identity()
	.translate(
		-15.0f + xx * 3.0f,
		-15.0f + yy * 3.0f,
		0.0f) // <-- change this value here to effect the position on the z-axis
	.rotateAffineXYZ(
		time + xx * 0.21f,
		time + yy * 0.37f,
0.0f)


keep in mind that the example demo sets the limit of the depth range to 0.1 - 100 if your second cube is positioned outside of this range from the camera view it will not display