#1
|
|||
|
|||
lighting and on-the-fly objects
I'm not understanding how to get the correct lighting effects for my on-the-fly objects.
First of all, there are only three types of lights - directional, point, and spot - none of which seem to have an ambient light component. So is ambient light only specified by the material property <node3d>.ambient as set for each on-the-fly object? Secondly, I can't seem to shut off all lights. If I have the code: Code:
viz.startlayer(viz.QUADS) viz.vertexcolor(0.7,0.5,0.5) viz.vertex([x,y,0]) viz.vertex([-x,y,0]) viz.vertex([-x,-y,0]) viz.vertex([x,-y,0]) square = viz.endlayer() square.enable(viz.LIGHTING) headLight = viz.MainView.getHeadLight() headLight.disable() Finally, if I check the various lighting properties of the node: Code:
print 'square.getAmbient() =', square.getAmbient() print 'square.getColor() =', square.getColor() print 'square.getEmissive() =', square.getEmissive() print 'square.getShininess() =', square.getShininess() print 'square.getSpecular() =', square.getSpecular() |
#2
|
|||
|
|||
This is a bug in the current version. As a workaround you can add the On-The-Fly object to a group node and apply all your material settings to the group node. Either way, you still need to specify normal vectors for your OTF objects in order for the lighting calculations to work correctly. I'm not sure if you are already doing this, but the sample code you provided above does not specify normals.
|
#3
|
|||
|
|||
Okay. One annoying undocumented bug down. I'm getting other strange effects too.
Firstly, based on my initial tests, the setting viz.lightModel.twoSided (default=0) seems to imply 0="make the back look just like the front" and 1="make the back respond realistically to light". Consider the following code: Code:
headLight = viz.MainView.getHeadLight() headLight.disable() myLight = viz.addLight() myLight.enable() myLight.position(0,1,0,0) #make a "sun" myLight.spread(180) myLight.intensity(1) myLight.color(viz.WHITE) viz.startlayer(viz.QUADS) viz.vertexcolor(0.8,0.4,0.4) viz.normal(0,0,-1) viz.vertex([1,1,0]) viz.vertex([-1,1,0]) viz.vertex([-1,-1,0]) viz.vertex([1,-1,0]) obj = viz.endlayer() #make square in the XY plane at Z=0 obj.setEuler(0,30,0) obj.setPosition(0,0,1) obj.enable(viz.LIGHTING) Code:
viz.startlayer(viz.POLYGON) viz.vertexcolor(0.8,0.4,0.4) viz.normal(0,0,-1) for i in range(32): radians = 2*math.pi*i/32 viz.vertex([0.1*math.sin(radians),0.1*math.cos(radians),0]) viz.vertex([0.1*math.sin(radians),0.1*math.cos(radians),0]) obj = viz.endlayer() When I start grouping these objects together, and setting the color for the group, then the dark sides get even darker. I now think I understand that this is because the bug described above. Please correct me if I'm wrong. |
#4
|
|||
|
|||
The code you have draws the disc clock-wise to the normal, so that is why the coloring is inverted. Try negating the x value when specifying the disc vertex and the lighting should appear correct. Also, your code for drawing the disc is specifying the same vertex twice, which is unnecessary.
|
#5
|
|||
|
|||
That was what I suspected, since I do know a little OpenGL, but the documentation doesn't talk about that at all. Is it fair to assume that everything in Vizard simply reflects the analogous call in OpenGL?
BTW, I realized I'd made a basic trigonometry error: cos should be paired with the x value, and sin paired with the y. That would wind counter-clockwise, and was what I had intended. I don't know how that vertex line got doubled, but thanks for pointing it out. |
#6
|
|||
|
|||
Vizard is built upon OpenSceneGraph, which in turn is based on OpenGL. The behavior of some Vizard primitives can be predicted through knowlege of OpenGL, but we're not always strict in this relationship.
|
#7
|
|||
|
|||
I'm wondering something similar with regards to ambient lighting, and I'm just looking for a confirmation or disconfirmation of whether ambient lighting of objects in the environment (with the headlight turned off) is determined just by their ambient properties, or if there is an ambient light that can be disabled?
Thank you |
#8
|
|||
|
|||
There is a default head-lamp that you can shut off if you don't want. See the documentation for "head-lamp" under "light basics". Otherwise, from my understanding, the light calculations follow the same rules as those in OpenGL (or OpenSceneGraph).
|
#9
|
|||
|
|||
Sorry if my last post wasn't clear, what I'm wondering is basically the answer to the first of your questions in your initial post: "is ambient light only specified by the material property <node3d>.ambient as set for each on-the-fly object?"
It doesn't seem like that question was directly addressed, which I assume means you were right, but I'd just like to know for sure. With the headlamp turned off, objects are still semi-visible, and I'd like them to be completely dark. I have gotten this to work by setting the ambient values of the objects to (0,0,0) - I'm just wondering if there's another way to get total darkness? Thanks again. |
#10
|
|||
|
|||
Sorry, I don't think I read your question, or my previous posts very carefully. I do remember this strange effect, and I'm not sure I ever solved it, though I suspect I did given that I didn't ask again. Unfortunately, I am no longer using Vizard (new and different job), so I can't play around with this any more.
But perhaps in your setup the <node3d>.emissive property is not zero. This will make objects give off their own light. With the on-the-fly objects I was using that bug mentioned above prevented me from setting this property appropriately the obvious way, so keep that in mind. Beyond that shot in the dark (pun intended) I'm afraid I can't be of further help. Perhaps one of the Vizard gurus will shed some light on the topic (another bad pun). |
#11
|
|||
|
|||
This thread is discussing the exact issue we need in our project. But after many tries, I still could not make the 3D effect on the on-the-fly objects. The cylinder and cone do not have the same lighting effect with the imported 3D ball. I changed the value of obj.shininess, obj.emissive,obj.specular, and etc. but it does not work. I believe Vizard does support this function, I just could not figure out how to make it happen. Can anybody help. I apprecate it....
Last edited by renama; 02-09-2011 at 07:01 PM. |
#12
|
|||
|
|||
How are you creating the cone/cylinder objects? Are you using the vizshape module?
I just tried it out, and the cylinder object created by the vizshape module is affected by light. If you could provide some sample code, that might help us debug your issue. |
#13
|
|||
|
|||
We use on-the-fly object by using viz.startlayer(), viz.endlayer(). I did not know the vizshape module. That works better. Thank you!
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
lighting issue | cantwelljm | Vizard | 3 | 02-18-2006 08:21 AM |
The effect of lighting on performance | JRichizzle | Vizard | 1 | 06-18-2004 10:40 AM |
Problems with lighting in 2.0 | murm | Vizard | 6 | 04-21-2004 09:59 AM |
Lighting Problem | Plasma | Vizard | 1 | 02-03-2004 11:09 AM |
Vizard 2.0x lighting | FlyingWren | Vizard | 4 | 08-11-2003 12:20 PM |