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?

hey! can you share that shadow script?

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:
track.append(track[0])
del track[0]
x = normalize(cross(track, vec))
y = cross(z,x)
return [[x[0],y[0],z[0]],
[x[1],y[1],z[1]],
[x[2],y[2],z[2]]]

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

thanx man!

any chance of a simple demo of this? please?

-david

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

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

-Luke

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