|
GL Tools Quad Strip Texture Coords and NormalsI wonder if it would be possible to fix the texture coords to allow meaningful texturing of a GL Quad-Strip. Currently, if you pipe an image into the Image port, you just get the colour of the first pixel of the image, as far as I can tell. Also, would it be possible to generate normals for the quad strip, so it can be lit? Or, have the option of generating normals, since I imagine calculating them would slow things down a bit. The above probably applies to the Triangle Structure patch too, but I haven't tried that one yet. a|x |
Set the U and V values, and you get texture mapping (there's a sample composition that does something with this I think -- subtractive blending perhaps?)
I don't recall if we support normals or not -- manually calculating them will give faceted lighting, and then people will want smooth lighting, and that's tricky (and part of kineme3d...)
Hmm.. how do you do that, then?
I see, slippery slope, and all that. To be honest, I just stuck the Quad Strip inside a Lighting patch, and lighting didn't appear to work. I guess there could be other reasons for that, too...
a|x
depends on how you're making the structure. Wherever you set the X and Y members, add a U and V for the texture coords.
You're dead-on with why it doesn't work -- GL lighting requires normals, otherwise you just get unlit polys.
OK, so let's assume you're not calculating normals, then...
I'll have a go at calculating UVs too. Not sure how that's going to go, though... Thinking about it, it's going to be a bit tricky....
a|x
Hmm.. not quite sure how this should work. I tried, as a test, adding the X and Y coords of each vertex onto the end of the array for each point (X, Y, Z, U(same as X), V(same as Y))
I know QC coords are centered on 0, so I'd kinda expect to see the input image tile across the quad-strip, as if projected onto it, or something. I can't completely get my head around the geometry, but I think I should anyway be getting something other than the exact same colour across the entire strip.
I've included a simple test QTZ. I know it's reinventing the wheel (or more precisely, toby*spark's SPK Caligraphy plugin), but I thought I'd try and implement something similar in JS, just as a test of the GL Quad Structure plugin.
If you could have a really quick look, I'd be really grateful. It's probably user error on my part.
a|x
Hang on, doesn't OpenGL automatically interpolate normals, if they're specified for each vertex?
It's a while since I looked into OpenGL, but I thought that was the deal.
a|x
Any more info on how the U and V variables work with the Kineme GL patches would be hugely appreciated.
Try this in the JS part:
For textures (and possibly normals, if they're supported), it requires names, not indices. Your method was just pumping out "0"-"5", while this needs "X", "Y", "U", "V" etc (I trashed your Z stuff, but I figured you at least get the idea from this).
The 0.5 + (blah) / 2 is to turn QC coordinates (-1 to +1) into UV tex coords (0 to 1)
It interpolates.
But when one "calculates the normal" of a primitive (a triangle, typically), you get a vector (the normal) -- all vertices of the triangle will have the exact same normal, so GL interpolating the normal won't do anything interesting. To make a curved surface, you need to bend the normals, and finding out how much to bend the normal requires smoothing. GL does Not smooth for you (as that's a big huge problem that isn't well defined)
U and V are "Texture Coordinates". In other words, they tell GL how to map a texture to a shape.
In GL, a texture generally goes from 0 to 1, on 2 axes. These are labeled U and V in GLTools, and S and T in GL documentation. 0,0 is the bottom left corner, 1,1 is the top right.
Ah, OK. It mentioned in the description that a simple array could be used, rather than an associative array/object.
yep, I knew that was going to be necessary.
Now it works!! Nice one cwright!
I did this fun variation.
a|x
That's pretty cool there TB.
I much prefer it because of the way that the kineme GL Tools blend modes work. I'm going to have to see if it is possible to make it take a right click before it clears the line, so that you can make line gaps, and multiple lines...
Do you get a debug when it opens, b/c the javascript doesn't have a point list? I know I do... Somewhat trivial really.
Oops, guess that's incomplete -- as you've no doubt noticed, it's happy to do basic x/y/z points from a simple array, but it doesn't do that for other stuff. It could, but we didn't bother adding it in for whatever reason (traversing structures is ugly enough as it is, perhaps?). Sorry about the confusion :(
Ah, no, I don't get that. pointsList should probably be initialised outside the main loop of the JS patch though.
adding
seems to work.
a|x
Haven't had time to look at that yet, and I've been barking up my own trees as far as QC ideas go, but that makes sense on the pointsList, I bet that's exactly it... will check...
Yeah, your proposed concept of the arrays/iterator seems to make perfect sense as well.
The first time I saw this thing (the tobyspark version), it looked much like one of the tools in the eMotion thing to me.
I will be interested at some point to get into taking the structure and manipulating it to "do stuff" after you have "written". That seems like it would be a fun route.