Forums > Jitter

.obj file to jit.gl.nurbs

September 5, 2008 | 6:24 pm

Hey everyone.

I’m working on a small set of tools to pass obj files around, operate on them, display them, etc. I’m working with a bunch of architects who work in Rhino, so we’ve been doing alot with the jit.gl.nurbs object.

Up to now, smooth sailing. I can get jit.gl.nurbs outputting obj files. But if someone hands me an obj file, I can get all the control points into jit.gl.nurbs using an edited version of what I found in this thread: http://www.cycling74.com/forums/index.php?t=msg&goto=130767&rid=0&srch=obj+nurbs#msg_130767 but they do not connect to make any surfaces – they are literally just a collection of control points in the outline of the obj.

Before I spend my time going deeper into iterating through an obj file and parsing it into a matrix to use as a ctlmatrix for jit.gl.nurbs, I thought I’d ask if anyone had any tricks up their sleeves for this kind of thing, or a list of stuff to watch out for. Or maybe admonition for this just being a silly thing to try to do, and suggestions for a better way to operate on the guts of an obj file in Max?

In a post from a while ago, JKC had this to say:

*Note that Jitter currently only supports OBJ files that are triangulated meshes. While the OBJ spec has support for NURBS surfaces and other types of parametric surfaces, you will need to force the output OBJ to be tesselated triangles for Jitter to use it.*

which I only partially understand. So. Any help is appreciated.


September 6, 2008 | 5:35 pm

it sounds like you have a pretty good grasp of what you’re doing, do i don’t think i can offer much help.

i believe what joshua was referring to was jitter’s jit.gl.model object. this object will only load .obj files that contain mesh information, which is basically a list of triangles that creates a surface. i had no idea .obj’s even supported nurbs, but apparently they do. nurbs are not triangles, but curves.

you can parse your obj files however you want, and do whatever you want with that information. if you have a .obj that contains nurbs info, it’s up to you to translate that into a controlmatrix for gl.nurbs object. all he’s saying is you can’t use gl.model to automagically load it for you.

i’d be interested to hear what you come up with.
-rob


September 6, 2008 | 11:51 pm

Yeah I kinda figured it out the hard way: I’m beta testing Rhino for mac and the export .obj as a tesselated mesh (instead of NURBS) function is broken – jit.gl.model gets an "out of memory" error upon trying import a NURBS .obj.

Then again being beta it could probably also be 1,000,000 other things.

I tried some stuff parsing the output of jit.gl.model’s matrix into jit.gl.nurbs but nothing seems to translate right. Even simple stuff like a 16 point square (2D, not a cube) doesn’t come out right. I thought maybe jit.op was the secret but no luck yet. I’ll keep pluggin’.

Thanks for the encouragement – I’ll show and tell when something cool happens.


September 8, 2008 | 5:43 pm

> I tried some stuff parsing the output of jit.gl.model’s matrix into jit.gl.nurbs but nothing seems to translate right. Even simple stuff like a 16 point square (2D, not a cube) doesn’t come out right. I thought maybe jit.op was the secret but no luck yet. I’ll keep pluggin’.

completely different methods of rendering. again, gl.model is triangles, gl.nurbs is curves. if you want to do something with the matrix output of gl.model, send it to gl.mesh.
here’s an example…

#P toggle 496 187 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 496 206 29 196617 gate;
#P window setfont "Fixedwidth Serif" 10.;
#P newex 515 165 172 1441802 jit.noise 3 float32 12120 1;
#P window setfont "Sans Serif" 9.;
#P comment 493 271 75 196617 normal x , y , z;
#P comment 407 271 63 196617 texture s , t;
#P newex 484 253 97 196617 jit.pack 3;
#P newex 398 253 53 196617 jit.pack 2;
#P flonum 280 147 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont "Fixedwidth Serif" 10.;
#P message 280 166 55 1441802 xfade $1;
#P window setfont "Sans Serif" 9.;
#P newex 340 129 52 196617 r thebang;
#P window setfont "Fixedwidth Serif" 10.;
#P newex 340 165 172 1441802 jit.noise 8 float32 100 100;
#P newex 269 192 62 1441802 jit.xfade;
#P window setfont "Sans Serif" 9.;
#P newex 57 210 182 196617 jit.gl.handle foo @inherit_transform 1;
#P newex 269 305 346 196617 jit.gl.mesh foo @draw_mode triangles @lighting_enable 1 @depth_enable 1;
#B color 5;
#P newex 269 253 97 196617 jit.pack 3;
#P newex 269 228 357 196617 jit.unpack 8;
#P user jit.fpsgui 282 94 60 196617 4;
#P message 269 51 73 196617 read apple.obj;
#P newex 269 72 157 196617 jit.gl.model foo @matrixoutput 1;
#P message 59 280 68 196617 fullscreen $1;
#P toggle 42 280 15 0;
#P newex 84 255 35 196617 sel 27;
#P newex 42 255 40 196617 key;
#P newex 42 300 147 196617 jit.window foo @depthbuffer 1;
#P newex 71 184 52 196617 s thebang;
#P newex 42 234 82 196617 jit.gl.render foo;
#P user jit.fpsgui 96 145 60 196617 0;
#P newex 42 119 66 196617 t b b erase b;
#P toggle 42 68 15 0;
#P newex 42 94 57 196617 qmetro 20;
#P comment 277 271 100 196617 position x , y , z;
#P comment 430 189 65 196617 color r , g , b;
#P connect 3 0 2 0;
#P connect 2 0 4 0;
#P connect 19 0 6 0;
#P connect 4 0 6 0;
#P connect 4 2 6 0;
#P fasten 10 0 11 0 89 277 47 277;
#P connect 12 0 8 0;
#P fasten 11 0 12 0 58 295 58 280;
#P connect 4 1 7 0;
#P fasten 9 0 10 0 83 272 83 257;
#P connect 4 3 5 0;
#P connect 14 0 13 0;
#P connect 13 0 20 0;
#P connect 23 0 20 0;
#P connect 20 0 16 0;
#P connect 16 0 17 0;
#P connect 17 0 18 0;
#P connect 24 0 23 0;
#P connect 13 0 15 0;
#P fasten 25 0 18 1 403 290 316 290;
#P connect 16 1 17 1;
#P fasten 21 0 20 1 345 187 326 187;
#P connect 22 0 21 0;
#P fasten 26 0 18 2 489 294 358 294;
#P connect 16 2 17 2;
#P fasten 30 0 18 3 501 299 400 299;
#P connect 16 3 25 0;
#P connect 16 4 25 1;
#P connect 16 5 26 0;
#P connect 31 0 30 0;
#P fasten 22 0 29 0 345 156 520 156;
#P connect 29 0 30 1;
#P connect 16 6 26 1;
#P connect 16 7 26 2;
#P window clipboard copycount 32;


September 10, 2008 | 5:31 am

Yeah I realized very soon after I posted that was not going to work. I did some more research on the .obj spec (mesh obj and nurbs obj). I’ve learned the following:

•Iterating through an .obj file of a simple shape exported from Rhino using the NURBS spec and loading it directly into jit.gl.nurbs ctlmatrix works… but:
•Complex shapes exported using the same method contain information which – as far as I can tell – has no place in a jit.gl.nurbs ctlmatrix. I’ve attached an example of one such NURBS obj file.
•The same complex shape exported as a meshed obj file will load just fine using jit.gl.model

Which gets me to your cool, and probably very helpful, suggestion to use jit.gl.mesh, Rob – but I feel like a dolt: I can’t for the life of me get any useful matrix data out of jit.gl.mesh. I’d assumed it would be a matter of associating a named matrix with jit.gl.render, but I guess I’m wrong…?

I hate to ask for some "spell it out for me" help… but I think I’m about there. Blast.


September 16, 2008 | 5:30 pm

Jitter and Rhino (maya, max, other)

mike, rob….

I too am interested in communicating 3D data between jitter and rhino… both importing and exporting using nurbs, tesselated geometries, or IsoSurface. I understand basic concept of importing obj as tesselated surface to jitter.

I would like to be able to manipulate 3D coordinates (of obj, isosurface, etc) in jitter and export the data back to rhino. Do either of you have any suggestions for doing so? Successful examples or trials thus far?

Thank you,

kcam


September 21, 2008 | 9:51 pm

I’ve been busy the last couple weeks on a residency, so this has kind of pushed to the back-burner for now, but in the next couple weeks I’ll be retackling this – hopefully with some fresh eyes.

Last week, I did find this though:

http://www.opennurbs.org/

The toolkit which Rhino uses to read and write 3dm files is open source.


June 6, 2009 | 1:40 am

mike…
any progress on transporting data between rhino and jitter?


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