WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-19-2008, 01:53 PM
michaelrepucci michaelrepucci is offline
Member
 
Join Date: Jul 2008
Posts: 53
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()
I can still see my square, albeit darker than without lighting enabled.

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()
they're all the same as the vertexcolor I originally set. And if I set any one of these properties (square.ambient, square.color, square.emissive, square.shininess, or square.specular) to something else, it changes them all to the new value. This doesn't make sense to me. Please can somebody explain this?
Reply With Quote
  #2  
Old 08-21-2008, 10:36 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
  #3  
Old 08-21-2008, 01:49 PM
michaelrepucci michaelrepucci is offline
Member
 
Join Date: Jul 2008
Posts: 53
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)
With viz.lightModel.twoSided=0 both sides look pink, but with viz.lightModel.twoSided=1 the top side looks pink, while the bottom side is darker. What is really odd is that if I draw a disc with:
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()
and do the same thing as above, the bright and dark faces seem to get swapped. Both the square and the disk are drawn counter-clockwise, and have the same normals, so what gives?

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.
Reply With Quote
  #4  
Old 08-22-2008, 04:16 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
  #5  
Old 08-23-2008, 08:14 AM
michaelrepucci michaelrepucci is offline
Member
 
Join Date: Jul 2008
Posts: 53
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.
Reply With Quote
  #6  
Old 08-27-2008, 09:45 AM
tobin tobin is offline
WorldViz Team Member
 
Join Date: Feb 2003
Posts: 251
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.
Reply With Quote
  #7  
Old 07-04-2009, 08:34 AM
jrajsic jrajsic is offline
Member
 
Join Date: Jul 2009
Posts: 2
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
Reply With Quote
  #8  
Old 07-04-2009, 02:26 PM
michaelrepucci michaelrepucci is offline
Member
 
Join Date: Jul 2008
Posts: 53
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).
Reply With Quote
  #9  
Old 07-08-2009, 11:01 AM
jrajsic jrajsic is offline
Member
 
Join Date: Jul 2009
Posts: 2
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.
Reply With Quote
  #10  
Old 07-08-2009, 11:16 AM
michaelrepucci michaelrepucci is offline
Member
 
Join Date: Jul 2008
Posts: 53
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).
Reply With Quote
  #11  
Old 02-09-2011, 06:57 PM
renama renama is offline
Member
 
Join Date: Jun 2010
Posts: 15
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....
Attached Thumbnails
Click image for larger version

Name:	lighting.jpg
Views:	1052
Size:	5.1 KB
ID:	407  

Last edited by renama; 02-09-2011 at 07:01 PM.
Reply With Quote
  #12  
Old 02-10-2011, 09:11 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
  #13  
Old 02-11-2011, 08:26 AM
renama renama is offline
Member
 
Join Date: Jun 2010
Posts: 15
We use on-the-fly object by using viz.startlayer(), viz.endlayer(). I did not know the vizshape module. That works better. Thank you!
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -7. The time now is 01:25 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC