1
\$\begingroup\$

Can anyone point me to techniques for drawing lines, with the mouse, on 3D objects in WebGL or OpenGL?

Here's the effect I'm looking for, using WebGL: http://www.spacegoo.com/cadillac/

I can imagine the general idea - projecting a ray onto the surface, then perhaps using normals and UVs, transform the intersections into UV-space and drawing the line on a texture, which gets mapped onto the object.

Would love to find some proper literature on it though.

\$\endgroup\$
1
\$\begingroup\$

You could start by taking a look at the JavaScript code of that page you've linked to figure out how they did it. I'd guess each line is composed by a lot of tiny rounded dots used as decals. That could explain why the lines look dotted when seen from close. I don't think using decals would be the most efficient technique, but it should be the simplest to implement.

Here are some refs from google, if you want to take a look:

Apart from that, Virtual Texturing techniques can greatly simplify and improve texture painting, but just getting a VT system to work properly is a tremendous amount of work, so I doubt that would be relevant to you...

\$\endgroup\$
  • \$\begingroup\$ Thanks, yes I figure it's about a ray-pick to find the UVs at the intersection, then using those to find the pixels to update on the texture image. BTW I've looked at that page and since it has minified JavaScript, it's not much use as an example. \$\endgroup\$ – xeolabs May 9 '15 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.