Gerneration of vertex in gridshape and gl.mesh

nicolasnuzillard's icon

Hello !

I'm working on visuals based on cubes.
I've got 2 questions

1)
"jit.gl.gridshap @shape cube @polymode 1 1" creates more segements as we add rows and colums to the dimention of the grid shape. However the generation of segments doesn't makes grids on the top part, isnted of it, segments are crossing on the top part of this cube. I don't even manage to have a gridshape that looks like the physword with phys.draw. So i made something by my self with multiple "@dim 2 2 planes" but I think there is another way to do a such simple thing.
So the the first question is "how to make a simple cube with onely 12 segments?"

2)
The points of 3D models are stored in 2d matrixes, I don't understant how the vertex are linked together according to the way points are stored in this 2d matrix. In other words, points set in a specific order won't have the same results in a 6x4 matrix than in a 4x6 matrix. can someone explain this or give a clear documentation about it. I use as reference the page 2 of this link http://peterelsea.com/Maxtuts_jitter/OpenGL_in_Jitter.pdf

Thanks for helping.

Nicolas

Andro's icon

The jit.gl.sketch help file and tutorial show how to generate your shapes per vertex. Generating a matrix to create such a shape is a complex operation due to triangles being used. Maybe try to make a basic tri cube in blender. Load it with jit.gl.model. Set matrix output to 1. Send this to a 3 plane matrix and then save that matrix as a file. Thats my quick and easy way to have a matrix of verts that i can then manipulate in a matrix. At best its a great way to analyse basic geometry and create your own matrix files to use.

nicolasnuzillard's icon

Thanks for helping

I thought about using a 3d software and export, it's such a pitty that such method have to be used to make such simple thing.
As a solution I'm playing with planes and multi to make a cube, so I can have great contol on each faces of this cube, and then apply another multi on this rendered cube for fun.

Concerning jit.gl.mesh, the way vertexes are organised depending the dimention of a matrix stills a mystery.

Andro's icon

Well its not really a mystery. Jitter uses triangles to create a mesh. When you draw 3 vertexes then the third one creates one face by connecting the 1st and the third vertex together. This just repeats. Creating an equation to do this is the challenging part.
Like i said a 3 plane matrix is the xyz co ordinates of each vertex. Plane 0 x. Plane 1 y. Plane 2 z.
Therefore you need to make 3 dimensional matrix like this.
This-matrix 3 float32 4 4 4
This creates a 3 plane matrix with 3 dimensions.
You then need to use. Jit.expr to fill it.
Jit.expr snorm[0] snorm[1] snorm[2] will create a 3d space equal to a cube with co ordinates inside it.

Using seperate planes wont work so well because theyre not joined together so any vertex alterations will break the cube apart.
Just try to learn to alter a basic tri cube from blender first. When you get the hang of that the rest will become easier.
3d equations are just hard.