-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nurbs-interpolated coloring of SoNurbsSurface #413
Comments
This is a limitation of the original Inventor specification. See Inventor documentation . I agree, that we should improve the Coin documentation of the SoNurbsCurve/Surface classes to pinpoint those limitations. |
@VolkerEnderlein any chance we can add such a functionality? but I am also not sure if the glu library supports coloring nurbs this way. |
I would not recommend it as it breaks the intention of the original hierarchy. If you look to the hierarchy under SoShape you'll see primitives like Cone, Cylinder, Cube, Sphere, NurbsCurve, NurbsSurface, Text2 and Text3 as well as VertexShapes and VRMLGeometry. The materials for primitives can be specified PER_FACE or OVERALL, but not PER_VERTEX, as the vertices of primitives do not have to be specified. They are generated according to the complexity value and the ObjectSpace and ViewSpace setting. The coordinates/vertices you specify for the NURBS are control points and in general neither do coincide with vertices on the surface of the NURBS shape nor can be easily mapped onto the surface. I think you get far better results in coloring an arbitrary surface when creating an IndexedFaceSet or an FaceSet (or TriangleStrips) with given colors for the vertices. |
Just throwing this out there:
If this is your goal, you'll be able to do that for any shape by writing a shader. Admittedly, it is not a straightforward solution. A 3D texture is also an option (for a simple linear gradient you only need two pixels). This is rather straightforward. |
No, it is meant as an easy example. I would like to visualize a solution of a PDE solved directly for nurbs-surfaces. So every controlpoint has a result (eg. pressure) which is mapped onto the surface via the nurbs-basis functions. |
Maybe you can derive from SoNurbsSurface and implement that functionality there. Otherwise you can discretize the NURBS to an IndexedFaceSet like Volker suggests. |
This is an interesting idea. But how to generate a texture from a nurbs. If the control points are given by [u, v, z], I need to generate a texture where u, v are the pixel coordinates and z generates the color. |
This was only a suggestion for when the color should map to the z component of the geometry. I don't think it can be applied to your use case. However, you can use SoTextureCoordinate2 to visualize for example pressure over a surface (you'd have to check if this includes SoNurbsSurface). I am using a 1x2 pixel texture, and by varying the texture coordinate between (0.5, 0.5) and (0.5, 1.5) I can select any shade between twose two pixel values, varying over the surface. I use this to color a triangle strip to visualize curvature. So, texture coordinates need not be proportional to (u, v) parameters at all, which is pretty cool. You can cover all rainbow colours with only a handful pixels. But I guess you'd still have to discretise the surface into a SoIndexedFaceSet. Or, maybe you can implement a custom node that produces texture coordinates for a SoNurbsSurface. That may be the most elegant solution. |
I am looking for a way to put a color-distribution onto a SoNurbsSurface using the same basis for the color interpolation? I tried to do this the same way as it is done for IndexedFaceSets but it didn't work.
trying to visualize the z-value for this python example:
The text was updated successfully, but these errors were encountered: