WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   how to change shadow direction? (https://forum.worldviz.com/showthread.php?t=2725)

shahramy 05-04-2010 10:43 AM

how to change shadow direction?
 
i used Shadow module to create shadow but I cant change the direction of shadow in the other hand the point in which the imaginary light source exists. i have used this code.

SHADOW_RES = 2048
#Postion of shadow projector
SHADOW_POS = [-30.800,5.000,50 ]
SHADOW_AREA = [150,150]

#Create shadow projector
shadow = Shadow.ShadowProjector(size=SHADOW_RES,pos=SHADOW_ POS,area=SHADOW_AREA)

#Add avatar as a shadow caster
shadow.addCaster(obj1)
shadow.addCaster(obj2)

#Add ground as shadow receiver
shadow.addReceiver(sh)

with this shadow_pos the shadow will create exact under the two object which have many distance from each other!!!

Jeff 05-05-2010 12:22 PM

The following example shows how to set the position and orientation of the shadow projector. It moves in a circle around the avatar and turns so that it is always pointed at the avatar.
Code:

import viz
viz.go()

#Add ground model
ground = viz.add('tut_ground.wrl')

#Add avatar
avatar = viz.add('vcc_female.cfg',euler=(180,0,0))
avatar.state(5)

#Shadow resolution (power of two)
#Higher values mean sharper shadows, but take more texture memory
SHADOW_RES = 256

#Postion of shadow projector
SHADOW_POS = [0,0,0]

#Controls size of orthographic shadow projector
#Large values mean larger area is covered, but resolution will be diluted
SHADOW_AREA = [5,5]

#Create shadow projector
import Shadow
shadow = Shadow.ShadowProjector(size=SHADOW_RES,pos=SHADOW_POS,area=SHADOW_AREA)
#Add avatar as a shadow caster
shadow.addCaster(avatar)

#Add ground as shadow receiver
shadow.addReceiver(ground)

import math

SPEED = 0.5
def moveProjector():
    t = viz.tick() * SPEED
   
    # Move projector in a circle
    newX = -math.cos(t) * 2
    newZ = math.sin(t) * 2
    shadow.setPosition([newX, 2, newZ])
    shadow.setEuler([t/math.pi * 180,40,0])

vizact.ontimer(0,moveProjector)       
       
import vizcam
viz.cam.setHandler(vizcam.PivotNavigate(center=[0,1.5,0],distance=7))


shahramy 05-05-2010 09:37 PM

thanks man. that is great. vizard is the best:D


All times are GMT -7. The time now is 12:05 AM.

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