jit.gl.model, keep mesh coherent when applying vertex manipulations?

dtr's icon

Hi there,

I have an issue with manipulating imported 3D models. I want to do vertex manipulations on them, using matrixoutput. The issue is that it seems that the models I create in Maya - or the way jit.gl.model interprets them - is that meshes are built up of triangle faces, and each triangle has its own 3 vertices. This means that every mesh vertex actually has 5 or 6 vertices at that position. One for each triangle that joins in that point.

Now when I do operations on the vertex matrix, for example adding noise to it, these vertices in the same position split up. The patch below demonstrates that. When I add noise I'd like ducky to deform but keep mesh connected. Though what happens is that the individual triangles disconnect in a kind-of explode effect. That's because the triangles don't share vertices in a triangle-trip fashion.

How can I prevent this from happening? Is it an export setting in Maya (I = modelling noob)? Or can I do something in Max?

Max Patch
Copy patch and select New From Clipboard in Max.

Tanx for all help, Dtr

Andro's icon

(Not behind the computer right now)
Try the same technique on a basic jit.gl.gridshape and see if you get the same results. Eg. jit.gl.gridshape @shape plane
or
@shape cube

When I export models from blender I use the triangulate modifier and everything seems to displace fine without exploding into separate faces. With jit.gl.render @draw_primitives triangles

dtr's icon

Thanks for chiming in. The transforms work fine with gridsphape and other geometry generated in Max.

I got some Maya tips from friends telling me to merge vertices before exporting. Didn't help.

What file format do you export to from Blender? Could you perhaps give me a Blender generated model that I could test with?

I'd be happy to switch to Blender if that solves it. Need to learn modelling from scratch anyway.

Andro's icon

Just download blender.
Add a cube.
Use a subdivision surface modifier
then a triangulate modifier

Export as a .DAE file with the settings in the screenshots.

Because its exported with the modifiers applied then you can do none destructive editing and always go back and alter the geometry.

Always check that you merge double vertices.
And with jit.gl.model I turn off some option which allows jitter to change the vert order. Not sure what it is anymore.

Screen-Shot-2014-06-02-at-16.22.43.png
png
Screen-Shot-2014-06-02-at-16.21.41.png
png
Rob Ramirez's icon

And with jit.gl.model I turn off some option which allows jitter to change the vert order. Not sure what it is anymore.

possibly @optimize ?

Andro's icon

Just looked it up, thats the one Rob !
If thats off then you know that the vertex order is exactly "the way " it should be.

madjax's icon

Has anybody solved this? I tried changing the jit.gl.model to @optimize 1 and the triangles still become detached when noise is added. I too want to warp vertices and have to mesh not decompose into individual triangles.

dtr's icon

A colleague helped me with this. He merged vertices in the 3D modelling software (Rhino?) before importing into Jitter. I don 't know enough to be able tell you the details of what and how exactly. Sorry. I know it was finicky and took a while before he found what exactly worked.

carsol's icon

hello Andro...

i give a try to Dtr patch and im having the same result, when noise is added using his patch, the mesh is broke in disconnected triangles...

i follow you suggestions about Blender exportation but the only thing i don't found in Blender is; how to merge double vertices?

i tried too optimize 0 and 1 and the result is the same...

thanks!

Andro's icon

Hi Carsol,

Do the following.
In blender press tab ( edit mode)
Press a ( select all vertices edges and faces)
Press t ( transform menu)
Click remove doubles.

carsol's icon

eii Andro, my dear blender friend aahaha...
ye ye is what i did and tried now again and the objects breaks in tris....

as you said, doing this:
Add a cube.
Use a subdivision surface modifier
then a triangulate modifier
select all
Remove Doubles
export DAE (with the settings of your screenshot)

and then with DTR patch the vertexs of the object remains connect when apply the noise????

in the image what i get, object broke in tris..

Captura-de-pantalla-2015-04-22-a-las-19.36.43.png
png
Andro's icon

No Clue Carsol. I'm pretty sure that if you get a model in blender ( a cube)
export it (lets call it model A)
go into edit mode and do a few simple changes to a few verts, export it as model B
Load them both into jit.gl.model @matrix output 1
send both outputs to a jit.xfade. If you crossfade it should go smoothly.
So why this happens with noise being added to the verts is a mystery to me,
Never solved it myself :(

Andrew Benson's icon

I think the best workaround I've come up with is to use UV coordinates to look up the distortion (noise) value instead. I've done this using jit.gl.shader with a vertex program that did a texture lookup into a noise texture, and I've used jit.gen to do it. The good thing about that way is that you know that all the copies of the same vertex will have the same UV coordinates, so it will keep the triangles together. Texture coordinates are also a 2D space, so it's easy to reference matrix/texture coordinates with that. The downside is that you must actually do some UV mapping in your modeling app to make it work properly.

Hope that helps.

Wetterberg's icon

I know some of those words.

dtr's icon

lol

dtr's icon

@Andrew: While that sounds, well... sound, do you have an insight to share on the cause of the vertices splitting? Is it perhaps because even though we tell our 3d modelling programs to join the vertices they're still written to file multiple times and subsequently read into Max?

carsol's icon

DTR: Theres a post in this topic where you mention that a friend of your did and object that dosent broke... :-?

Andrew: heheh... happens the same here, i understand the words but no clue how to start implementing your technic...

besides this, its a pity that jit.gl.model isn't able to merge vertices that are in the exact same position, when i found this topic i thought optimize=1 was the solution because i always set it to 0. From the reference: Optimize vertices and nodes on import (default = 1). An optional post-processing step when importing the model file. >>>>>>>>>>>> Identical vertices are jointed to optimize indexing <<<<<<<<<<<<<

if we could merge the indentical vertexs, then we will be able to deform the mesh, but don't looks like the identical vertices are jointed with optimized=1, no?

thanks!

dtr's icon

Well last month I was working on this project again and I couldn't find the mesh files that were supposed not to split. I think I confused it with another deformation I have in this patch. All of the files I had were breaking up when adding noise.

Rob Ramirez's icon

jit.gl.model draws triangle meshes, which means every vertex in the model file is a unique vertex of a unique triangle. if you want two adjacent vertices from distinct triangles to stay joined, you must multiply them by the same amount.

Max Patch
Copy patch and select New From Clipboard in Max.

andrew's technique, while brilliant, is probably a little less complex than it sounds.
here's a basic working example using the duck:

Andrew Benson's icon

LOL, yeah, thanks Rob for banging that together. That's exactly what I meant, but expressed in over-wrought language. It's a case of a simple idea that starts sounding really complex as soon as you want to put it into words, or should've just made the patch in the first place instead of talking about it. :D

carsol's icon

amazing Rob!! thanks for work out Andrews clever idea!!

one question, what exactly does the gen sample operation between the UVs and the noisy matrix?
and what happens with z plane?

!THANKS!

Andrew Benson's icon

The 'sample' operator outputs the cell/pixel value from its left input using the coordinates given by the right input. The coordinates are expected to be in normalized x/y values (0-1). In this case the texcoord values are used to get values from the noise matrix and output them. The z-plane should also be getting a noise value as well.

t's icon

I very often work with points only so what I needed was a kind of "zl thin" for matrix that would remove all the duplicates from a geometry matrix that comes from jit.gl.model. The reason for that is saving big amount of processing power when working with bigger models. So I made a java external that removes all duplicates from geometry matrix. It is very badly programmed but it works!:) Hence it might take quite a lot of minutes for larger models/matrices to process. So it expects 3 plane matrix and it spits out 3 plane matrix. Send in a matrix only once (!) because as I said it might take few minutes for larger matrices.

geomThin.zip
zip
visualpaco's icon

Hello @T and thank you for your tip and idea. Could you share a simple example of usage of your geomThin script?
Thanks

Matteo Marson's icon

Thanks T for sharing!

one way to speed up the process is to use an acceleration structure (like a regular space partitioning grid) to limit the search for duplicate vertices among smaller groups of vertices.
The speed boost is significant, as removing duplicate vertices from a model with ~150.000 vertices takes about 1 second.
Here's a javascript implementation:

geometry thin.zip
application/zip 3.01 KB
Unzip