Forums > Jitter

export 3d model from Jitter GL (& import nurbs)


dtr
February 14, 2008 | 9:49 am

Hi people,

First time my max/msp/jitter issues can’t seem to be solved by simply searching this great forum, so here it goes…

I want to import an .obj 3d model (relatively simple surfaces, no texturing) in Jitter, modulate it by data extracted from audio sample analysis and export the resulting shape to have it 3d-printed.

My problem is in the last step: exporting. The jit.gl objects don’t seem to have any means of exporting to for example an obj file. Has anyone found a workaround?

Vade suggested I could parse the output of my jit.gl objects with @matrixoutput 1, save as a Jitter binary file and parse/convert to a 3d app readable format. Theoretically feasible but I probably can’t work this out in the given timeframe. Any other ideas?

Additionally, the surfaces I’d like to work with are nurbs but I understood Jitter can only import tesselated models. I could live with it but nurbs would be better. Any workarounds for that?

Thanks, Dieter


February 14, 2008 | 8:15 pm

Hi Dieter,

I wrote a javascript that exports obj files from a matrix in jitter. I attached you an archive containing the script as well as a demo patch, which should demonstrate the use of the script.

Basically it just receives a jit_matrix and writes its contents into an obj file. If you need you can also define groups and materials for your object.

If you need any further explanation please feel free to contact me.

stephan



dtr
February 15, 2008 | 9:30 am

fantastic! i’ll try it out over the weekend…



dtr
February 20, 2008 | 5:22 pm

works like a charm… my eternal tanx to you!


November 7, 2008 | 3:57 pm

Hi Dieter and Stephan,

I am glad I found this post. I am looking to do a similar project with max.
I have a couple of questions for the two of you.

Dieter, 1. how has your project progressed?
2. how much clean up did you have to do with your OBJ file before you converted to STL?

Stephan, 1. I have downloaded your zip but have not opened it yet, can the exporter work with jit.gl.sketch or does one need an object file to start with?

I am excited to read that others are working on this!

Erika



dtr
November 7, 2008 | 6:53 pm

hi erika
i developed this app for a workshop with students. in the end they worked with the exported obj files. i guess it d be easy to convert those to stl using popular 3d modeling apps. i don t have experience with that myself.
from my memory (it s been a while) stephane’s script worked straight out of the box. no need for an obj file to start with either. i worked with a jit.gl.nurbs generating the model. i can send you the patches if you d like to have a look.

grtz dieter


November 8, 2008 | 5:16 am

hi stephan.

really cool patch.
but one question: is there a way of reading a "obj." back to your patch? the
idea would be to draw it using "line" or "line-strip", etc and saving it
like that.
any clues?

sandroid

On Thu, Feb 14, 2008 at 6:15 PM, spray wrote:

> Hi Dieter,
>
> I wrote a javascript that exports obj files from a matrix in jitter. I
> attached you an archive containing the script as well as a demo patch, which
> should demonstrate the use of the script.
>
> Basically it just receives a jit_matrix and writes its contents into an obj
> file. If you need you can also define groups and materials for your object.
>
> If you need any further explanation please feel free to contact me.
>
>
> stephan
>
>
>


Sandro Canavezzi de Abreu


November 8, 2008 | 4:00 pm


November 9, 2008 | 4:20 pm

Hey Dieter,
thanks for responding so fast, I have been looking at Stephan’s patch over the weekend and trying to get jit.gl.sketch to work with it. At this point I have built a simple line draw patch with jit.gl.sketch now the task is to figure out how to get the info into Stephan’s objectexport patch

I would appreciate it greatly if you could send me one of your nurbs patches, maybe it will be easier to understand to see how you worked it.

I am on a macbook pro OS 10.4.11 running MAX/MSP/JItter 4.6 jitter 1.6.3

best
Erika


November 9, 2008 | 5:17 pm


November 11, 2008 | 7:07 pm

Dieter, Stephan, and Sandro

By plunking in jit.gl.nurbs in place of gridshape, in Stephan’s patch I can get my nurbs object exported. I still have to figure out exactly if I can make the shape I want in nurbs, I am trying to draw a series of lines to make a shape almost like a nest. I did want to start from scratch that is why I wanted to use gl.sketch but I cannot figure out how to send my sketch data out to the matrix, I know that i have to use the glcommands but ????
still working I will post my patch soon if anyone wants to look at it.

Sandro, I think I am running into the same problem with the objects
I dont know if this helps but what I have been doing is exporting the object then using meshlab to look at my files, but they stay as solids even if i change the primitives for the objects. Again that is why I wanted to do it in gl.sketch

can one draw multiple lines in nurbs?


November 11, 2008 | 7:50 pm


March 17, 2009 | 12:35 pm

export 3d mesh from Jitter openGL matrix

great tool, I was about to try and make it, so glad someone told me this was here. I added those words at the top of this message so that it would come up if someone searches export OBJ 3d mesh like I did. I searched a few times and for some reason nothing came up, and it was because I didn’t say export 3d "MODEL"

at any rate, this is awesome, I cant wait to render out some of my jitter stuff in high res, or make a version of this that will do whole obj animation sequences!!

thanks so much!!


November 26, 2009 | 12:16 am

Can anyone please post the example patch DIeter has posted, I cant find it here…

Thank you!!

Tonko



efe
November 26, 2009 | 5:54 am

It seems that all the attached files are not uploaded to the forum yet, possibly related with the new site and the data migration they might be doing.
Maybe a little bit of patience


November 27, 2009 | 3:17 am

Yes, Ive assumed that. Anyway I have it sorted thanks to kind help of Dieter.


March 16, 2010 | 9:22 am

can anyone that has this patch post it here>? ive been trying to figure this one out for a while


January 24, 2011 | 6:14 am

Bump! I’d also be interested in the obj exporter patch. Thanks!


January 24, 2011 | 7:08 am

This may not have been the final version, but give it a go.

-Ben

Attachments:
  1. objWriter.zip

March 15, 2012 | 8:47 pm

Hey there

I’m also working on a similar problem,

I want to export the XYZ data from jit.gl.gridshape as a text file by using jit.fprint and I’m having some issues

I’ve attached a max patcher from max5 as an example

I’m going to be working on this problem further and posting the solution if I can find it, any help would be appreciated

Attachments:
  1. saveashape.maxpat

March 16, 2012 | 6:12 am

Hey I figured it out , you can save vertex data out of this patch as a txt file and rename it to .asc and load it into whatever will take that format , I’m using meshlab

It was to do with carriage returns VS "line feed" , sending the message 10 to itoa to use a line feed was the answer

Attachments:
  1. saveashape.maxpat

March 16, 2012 | 4:53 pm

Hi Sterling,
Thanks for sharing this, and for taking the time to work out the kinks.


August 11, 2012 | 5:43 pm

Hi all (no Max for ages, nice to be back!)

After a frustrated waste of time trying to get an old c external of mine to work properly (trying to use glFeedbackBuffer – long story, everything coming out, but flat!) and now running out of time i’ve now switched to making some changes to jsobjwriter.js to fit what i need – specifically scaling, positioning (easy, done) and rotation (more chewy, working on it!)

I’ll share back the results here when done, but was just wondering if anyone had already done this – or can point to how to get the jit.gl.model objects i’m using to output the matrix with these transforms already on? (in which case i may be sick! ;)

Thanks

jonny


August 11, 2012 | 7:09 pm

Hey Jonny

My workaround to getting scaling, positioning & rotating was to just measure where the object was then add all of that to the matrix to offset it

I’ve attached an example to show what Im talking about, you could do the same in javascript if you needed

let me know what you come up with

Attachments:
  1. offsetshape.maxpat

August 13, 2012 | 6:56 pm

hi guys. i just want to make sure you are aware that in Max 6, gl objects that support @matrixoutput 1 also support @matrixoutput 2.
matrixoutput mode 2 will apply ob3d’s transformations (position, rotate, scale) to the object’s geometry prior to matrix output.


August 13, 2012 | 6:59 pm

I had not caught that thanks!


August 14, 2012 | 8:45 am

Aaaaaaaargh! Would have saved me about 30 hours of headache! :) But thanks Robert, i was fearing there might be an easy answer, glad at least it seems to be an undocumented one.

Oh, and thanks Stirling for the trig pointers, what i got working eventually was based upon that.


August 14, 2012 | 3:27 pm

Ah, of course that’s documented and i’ve been staring at it all week without understanding what "On With Transform" means – doh! :)


August 14, 2012 | 5:04 pm

yeah some of the reference descriptions can be kind of technical.
don’t hesitate to ask the forum for anything that doesn’t make sense (documentation is an ongoing process).


November 19, 2012 | 9:34 pm

Hi guys, I’m usually on the Max and MSP side of things, but for this project I wanted to adventure to the land of OpenGL and 3D printing. Little did I know…

What I’m trying to do is draw a curve and extrude it exactly like with [jit.gl.path] so that I can export an .obj to 3D print it. If [jit.gl.path] had the matrix output attribute I would be in heaven, but it doesn’t so I don’t know what to do. There are others here that tried, but it has been four years so I’m hoping things have changed :-) Is it doable using [jit.gl.nurbs] and [jit.gl.mesh]? Or maybe there’s a way to draw my curves with lots and lots of [jit.gl.gridshapes]? If so, is there a tutorial or example patch out there that could demonstrate how to do so?

I have scrounged the forum but with my limited knowledge of Jitter and OpenGL, I feel very very lost. I thought I found my answer with this awesome objWriter patch, but even though it has taught me a lot, I couldn’t figure it out. I would really appreciate it if someone could point me in the right direction.

Thanks for any tips!

Andrew


November 20, 2012 | 12:34 am

Hey Andrew,

Do you just want XYZ points or normals as well? Are you trying to create a solid form or just a thin path that has some depth to it? There are a lot of ways to approach this.

You could use jit.gl.expr and write the math in for what kind of curve you want then output that into a matrix and save that data to some file if you just need the xyz points. If you need normals it might be better to start with a gridshape or plato object

Checkout Meshlab http://meshlab.sourceforge.net/ for reconstructing points into solid forms


November 20, 2012 | 11:48 am

Hi Sterling,

Thanks so much for responding. Just to clarify, I think I need the normals as I’m trying to create a solid form suitable for 3D print. Does this mean I need to use gridshape? If so, can I use it with jit.gl.multiple to create my curve? Sorry if I’m not asking the right questions, but this is new to me. My ideal scenario would be to be able to give XYZ coords, and a solid is created out of that. I really thought it would be that simple, right ;-)

If I send Meshlab my XYZ coordinates, can I make a solid out of that? To test, I tried creating a simple arc in Rhino and using "uniform mesh resampling" to give it volume, but with no luck.

Thanks again for taking the time to help.


November 20, 2012 | 7:05 pm

Hey Andrew

You’re probably either looking at taking a gridshape and pushing the location of each vertex around based on wherever you want them. Or moving around an entire shape at small enough intervals so that its one interconnected thing. I’ve always written one matrix into a larger matrix multiple times using srcdimstart / srcdimend / dstdimstart / dstdimend rather than using jit.gl.multiple , either way would work I suppose.

I’ve also generated big clouds of vertices without normals and strung them together in meshlab with accuracy just based on the fact that I had so many of them in proximity. You could give that a shot then generate normals in meshlab. If your points all have normals the Remesh by Alpha complex shape works well from my experience , or you could try Remesh by Ball pivoting with/without normals.

I don’t really know what you’re trying to make, each approach has its advantages/disadvantages and would result in different things. If you’re just trying to create a few french curves for a single project you’re doing it might be easier to just use Maya.

It would be really nice if you could do matrix output on a jit.gl.mesh


November 20, 2012 | 10:21 pm

Thanks, Sterling for all these tips. I’ll keep exploring with these options in mind.


November 22, 2012 | 1:21 pm

Just to let you all know i did end up getting mine working thanks to the kind help of those here (thanks! :)

The object we created will be on exhibition in London from the end of this month onwards – more info at href="http://www.londonfieldworks.com/projects/null-object

In the end i used a modified version of jsobjwriter.js, which i’ll try and attach here in case it helps anyone else. If needed i can try and make a help patch to show how i used it… if i get time.

Thanks all again!


November 22, 2012 | 1:24 pm

(can’t get my head around how this forum works – there’s the help? ;)

Hopefully js file attached…

Attachments:
  1. jsobjwriter.js

November 22, 2012 | 3:23 pm

Thanks Jonny. Can you briefly comment on what kind of changes were done to the original jsobjwriter.js file?


November 22, 2012 | 3:28 pm

Hi Pedro
Can’t really remember but doing a diff of the original one posted here and mine it’s mainly adding transformations (pos, scale & rotate) and some stuff about colours (ambcolor, diffcolor & speccolor) but can’t remember what that bit was for as i wasn’t interested in colour for this project…

Hope that helps!


November 22, 2012 | 4:56 pm

Thanks!


November 22, 2012 | 8:32 pm

Hi Jonny,
would you mind posting a help file about your use of the jsobjwriter.js file? thanx in advance.


January 20, 2013 | 4:18 pm

Hi friends

I’ve been revisiting this issue and I modified jsobjwriter.js to support the tri_fan , quad_grid and tri_strip primitives in a way I think is more accurate to the way Max/Jitter tends to render generative 3d files. I’ve also commented out some of the behavior in regards to the way it accepts messages about which primitive it ought to use, because it had this tendency to ignore what I was asking it to do.

The new primitive modes are accessible as tri_fan2 , quad_grid2 , tri_strip2 . I may work through all of them at some point but those seemed to be most useful ( or at least the ones I wanted ) .

You can find the file here with an example patch https://github.com/sterlingcrispin/public/tree/master/max

After exporting I suggest using Meshlab to clean your object. Sometimes very long edges are produced between ends of objects which are undesirable.
Filters > Selection > Select faces with edges longer than ….
Filters > Selection > Delete selected faces and verticies

http://meshlab.sourceforge.net/

the following screenshots show max (left) and meshlab (right) , not particularly interesting shapes but they’re highly nonconformal and essentially random vertices/faces as a proof of concept. If you’re having troubles with normals , you can usually generate them in meshlab with some success.

[attachment=212855,4918] [attachment=212855,4919] [attachment=212855,4920]

Attachments:
  1. ScreenShot20130119at8.59.21AM.png

January 20, 2013 | 7:13 pm

thanks a lot a lot a lot ,
this will save me so much time !

i have just made a try with the basic sphere, but reloading the obj. in BLENDER ,
i get the sphere sliced in 22 discs(+2 points at xtremities) ,
don’t know if this is expected , …
just to let you know ,
i try to join a screenshot .

thanks again , i have not read the thread , just discovered it right now ,
i’ll find this functionnality extremely useful , for sure
Matthieu

Attachments:
  1. blendercapture.tiff

January 20, 2013 | 7:30 pm

Thats what it looks like in max under the tri_fan primitive , as shown in this screenshot. Unless I'm on some kind of freak-mutant version of Max that no one else is experiencing. Try navigating around the sphere in 3D within Max, it should look like that 22 disk view.

I built the tri_fan2, quad_grid2 and tri_strip2 to mirror how things appear in Max, but there can be discrepancies. Play around until you get what you're after. If you want a solid object just use quad_grid or tri_grid , change the draw_mode from within Max , then set that as the same primitive on export and see if you're getting the results you expect.

[attachment=212869,4924]

Attachments:
  1. ScreenShot20130120at11.17.52AM.png

January 20, 2013 | 8:13 pm

now i get it
thanks
i like the tri_fan2 style …
matthieu


March 6, 2013 | 8:12 am

HI. thank you very much for the script post in the toolbox area here:

http://cycling74.com/toolbox/export-3d-obj-files-from-max/

It was the first one I was able to get working:) I think the issue with the tri_fan etc, probably caused the sphere to appear as in the attached image. The problem is, as I see it, is that the order of the points expected to construct solids from a mesh can vary from one 3D environment to another. that is, not all the solids shading options are necessarily consistent. Also there is a secondary issue, that is smoothing and creasing is adjustable on Carrara import. I don't knmow for other programs. However it's a real accomplishment nonetheless, and I'll share the capability in the Carrara forums :)

[attachment=216708,5107]

Attachments:
  1. Capture.JPG

March 6, 2013 | 7:01 pm

I have never used Carrara, but the idea of the OBJ format is that its supposed to be universal. Does Carrara actually ask you what primitive the OBJ is when you import it? Correct me if I’m wrong but OBJ’s dont actually contain explicit information about the primitives used, and can use any arbitrary method of stitching the vertices together. Its just a list of vertices and then a list of how they should be connected.

Try downloading Meshlab http://meshlab.sourceforge.net/ and opening your OBJ file from Max in that. If you’re still getting the same results than you’re probably sending data in the wrong shape or format to the exporting script. Check your plane count dimensions and data type. Or try tri_fan2, quad_grid2 or tri_strip2, play around with primitives and your geometry. You should be able to get something that gives you the results you want without much trouble.


March 28, 2013 | 12:42 pm

Thank you very much sterling!

L


Viewing 47 posts - 1 through 47 (of 47 total)