shadow problem

(Klein) #1

i have used an shadow script in an game. The shadow works right but it dont chase the cars direction and it duplicates allways the shadow plane. does any1 know what i mean, and know how to solve this problem?

Thx for all answers!!!

(gargola) #2

hey! can you share that shadow script? :smiley:

(Klein) #3

from math import sqrt
cont = GameLogic.getCurrentController()
owner = cont.getOwner()

def normalize(x):
length = sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2])
return [x[0]/length,x[1]/length,x[2]/length]

def cross(x,y):
return [x[1]*y[2] - x[2]*y[1],
x[2]*y[0] - x[0]*y[2],
x[0]*y[1] - x[1]*y[0]]

def dot(x,y):
return x[0]*y[0] + x[1]*y[1] + x[2]*y[2]

def mul(s,x):
return [s*x[0],sx[1],sx[2]]

def vecToMat3(vec,track):
z = normalize(vec)
dotprod = dot(z, normalize(track))
if abs(dotprod) == 1:
del track[0]
x = normalize(cross(track, vec))
y = cross(z,x)
return [[x[0],y[0],z[0]],

#at “ray” is the object that has an ray linked
#to the shadow plane(an car or the person…)
#at shadow is the shadow object
if cont.getSensor(“ray”).isPositive()==1:
HP = cont.getSensor(“shadow”).getOwner()
BHPosi = cont.getSensor(“ray”).getHitPosition()
BHNorm = cont.getSensor(“ray”).getHitNormal()
AFWD = owner.getOrientation()
BHOri = vecToMat3(BHNorm,FWD)

(gargola) #4

thanx man! :smiley:

(wiensta) #5

any chance of a simple demo of this? please?


(hiachi) #6

lol i remember trying to fake shadow’s by using a few lights to emulate the shape of the topography of an object, but once i realized (duh!) lights cant be black i stopped :frowning:

(Abracsis) #7

I reckon someone should just write a shadow stencil script. …what. it wouldn’t be that hard!!! :stuck_out_tongue:


(saluk) #8

Hmm, it could be possible, but it would be very difficult, and I don’t even know if it would be possible!

I don’t know what’s wrong with the script, sorry :frowning: