Can I set a constant colour for a shape regardless of orientation?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Can I set a constant colour for a shape regardless of orientation?

unixnerd
I some labels made using OrientedShape3D and they're a bit dull when my model is rotated in certain orientations. Is there any way to give them a constant colour regardless of how a light source falls on them?

I increased AmbientLight a bit and it helps but I don't want to increase it any more.
Reply | Threaded
Open this post in threaded view
|

Re: Can I set a constant colour for a shape regardless of orientation?

jfpauly
Hi.
I think you can do that  if normals generation is disabled. But I believe that this is not the way. Doing that, the label will always be dull, as you said.
May be another way would be use of diffuse light, also said "glow in the dark". This is just an idea because i never tested this light.
Anyway this is easy to try.
Good luck...
jfp
Reply | Threaded
Open this post in threaded view
|

Re: Can I set a constant colour for a shape regardless of orientation?

philjord
Hi,
The Material Attribute of an Appearance object determines whether lighting is enabled for the Shape3D.

By default a Shape3D with no Material set, or a Material created via new Material(); will both have lightingEnabled == true. To set it false do something like this:

        Appearance a1 =  new Appearance();
     
        Color3f eColor    = new Color3f(0.0f, 0.0f, 0.0f);
        Color3f sColor    = new Color3f(0.5f, 0.5f, 1.0f);
        Color3f oColor    = new Color3f(0.5f, 0.5f, 0.3f);

        Material m = new Material(oColor, eColor, oColor, sColor, 100.0f);
        m.setLightingEnable(false);
        a1.setMaterial(m);


Once it's set to false the color the object will be rendered in will be either the VertexColor for each vertex of the Geometry of the Shape3D (if set), otherwise the Color of the object set by the

        appearance.setColoringAttributes( new ColoringAttributes() );

I'd like to be able to point to an example of this in the Java3D examples, but I see that it only has lit examples throughout :(
https://github.com/philjord/java3d-examples

So the only place where this fact could be discovered is in the Java3D tutorials here (and elsewhere)

https://github.com/philjord/java3d-core/tree/master/docs/tutorial

under
2.6.3 Attribute Classes

but I realize that's pretty obscure! I would encourage you to install and get the examples running as it helps a lot with early questions here are 2 pictures of appearance options shown in the examples

examples/appearance



examples/picking/PickTest.java





Reply | Threaded
Open this post in threaded view
|

Re: Can I set a constant colour for a shape regardless of orientation?

unixnerd
Excellent! Thanks for the help. I've used Material quite a bit but hadn't spotted that option.