Bullet Holes?

Hi all :smiley:

Im having trouble managing time lately what with work and everything, so havent posted in an age. :frowning:

But if someone could point me in the right direction or just give a quick answer then great!

I take it the a plane with a bullethole texture on it can be orientated to be the same as the wall i wanna place it one by getting the normals of the hit wall?? Ive tried but cant get the plane to orientate properly! :( I remember seeing a bullet hole script somewhere before but cant find it.
If anyone could help with this then thanks. :slight_smile:

Soz that i havent been on here much giving feedback and stuff lately but hopefully ill have more time in a few weeks! Yay!

That angel game was Way cool and great work (as usual) Saluk on the .exe thing. :smiley:

Ummmm if i missed anything then soz and soz if none of this makes sense, its sorta rushed.

-Daz.

SLOW DOWN BOY! lol
Iā€™m not really sure what you mean. could you explain yourself a little more?

Well, I tried to figure this out, but I donā€™t know how to convert the normal direction to a transform which setOrientation needs. I tried to figure out a workaround but havenā€™t. I think that the blendergal skateboard game used a script for the shadow that does pretty much what you need a bullet hole script to do, so look into that. Iā€™ll get back to you later when I figure it out better.

I not so good at maths :slight_smile:

-The simplest way is to add an empty that has the wall orientation(you can see the Euler angles by pressing N)and make a little script that copies
the empty orientation and connect it to an always sensor of the plane.The python controller must be connected with an insignificant controller of the empty an the script must be:

import GameLogic
cont=Gamelogic.getCurrentController()
own=cont.getOwner
ori=cont.getActuator(ā€œnameactuatorā€).getOwner()
own.setOrientation(ori)

Hope it helps you.Ben

Hi all,

Got a bit more time at the moso ill try and explain a little more.

I got a ray which is giving me the HitNormal() of the wall, and the HitPosition(). Then i`m putting an empty at the HitPosition() and adding the BulletHole Plane with that empty. All i feel that i need to do now is transform the Normal value into an orientation value and setOrientation(??) of the plane.

Saluk, any luck/other pointers, cos I cant seem to get hold of the skatergal demo thing! :frowning: A sneaky preview of what i`m workin on may be in it for you! :wink:

Ben, i sorta get what you mean, but i got alot of walls, my gamething is sorta set in corridors with pipes and stuff. Wouldn`t i need to seperate all the differing angles of walls to use the empties on? Like i said i only sorta got what you meant.

Actually, would some kind person maybe mail me just the Python script from the skategal demo, just the one/s that relate to the shadow that Saluk mentioned? Please! :slight_smile: There maybe a sneaky preview in it for ya. :wink:

Ummm i think thats allā€¦?

Thanks again for all your help peeps! :slight_smile: much appreciated.

-Daz


The body stirs and is re-animated, only briefly, but then life is only brief.

Yeah, here it is. Well, in a minute, my computer is having a tummy ache :slight_smile:


#=====================
# shadow.py
#
# This script locates a shadow mesh
# on the floor.
#
# The object casting the shadow should have
# a "Python" controller linked to this script.
#
# The shadow object should have a sensor
# linked to the controller (I use "always"
# with the pulse turned off, so the script
# doesn't run unnecessarily).
#
# The object casting the shadow should have
# a vertex-child located on its underside
# which has a "ray" sensor linked to the
# controller, with pulse mode on and f:0.
#
# Randall Rickert
# [email protected]
#=====================

from math import sqrt

#=====================
# Functions
#
# These are standard vector math.
#=====================
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],s*x[1],s*x[2]]
#=====================
# Given any two vectors, vecToMat3 will return
# a 3x3 matrix having z aligned to the first
# vector and y tracking as near as possible
# to the second.
#=====================
def vecToMat3(vec, track):
	z = normalize(vec)
	dotprod = dot(z, normalize(track))
	if abs(dotprod) == 1: #prevent gimbol lock
		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]]]

# Get handlers for logic bricks and their owners
controller = GameLogic.getCurrentController()
shadowray = controller.getSensor("shadowray")

if shadowray.isPositive():
	shadowsensor = controller.getSensor("shadowsensor")
	shadowcaster = controller.getOwner()
	shadow = shadowsensor.getOwner()

	# Read orientation for orienting the shadow
	orientation = shadowcaster.getOrientation()
	forward = orientation[0]

	# Get the position and normal where the ray hit
	shadowpos = shadowray.getHitPosition()
	faceNormal = shadowray.getHitNormal()

	# Build orientation matrix for shadow
	shadowori = vecToMat3(faceNormal, forward)

	# Set the shadow's position and orientation
	shadow.setPosition(shadowpos)
	shadow.setOrientation(shadowori)


Yes! So they have all that nifty math in there already. You can pretty much just copy those defines into your program it looks like, and change the bit at the end to match your objects. Thanks NaN!

I can finally do stuff I always was afraid of trying.

Hay! :slight_smile:

Im still awake and its 3am for me, this bullet hole thing has been doin my head in. Thanks in a million man, im off to look at the script now. Ill send you awhat ive done so far kinda snippet in a few days. Try not to get too excited! :wink:

Thanks again,

-Daz

Iā€™m already too excited:)

Anything with bullet holes in walls canā€™t be all bad. Heck, ANY blender game is a good thing right now, there havenā€™t been too many releases lately.

Saluk.
How did you unpack the script from the .blend file? Or did you copy the whole script by hand?

I found out how to do this through trial and error :slight_smile: Blender can be weird with itā€™s hotkeys sometimes.

I think its alt-shift-f. It brings up a file menu with save and load on it.

cool, thanks :smiley:

Saluk, i sent WIP to [email protected]

Thanks again,

-Daz