# bullethole in a person

Has anyone else tried to make a mark or bullethole on a target that can move and rotate? The first problem I have is that “setPosition()” , when used in a child object, is offset by the parent’s location () - which can be compensated for but the rotation can not, because when a parent rotates a child moves by a distance I don’t know how to get.
The second problem is that I don’t understand the results of the getHitNormal(), does anyone have a formula to convert it’s result to a 3x3 matrix usable is setOrientation like “vector2matrix”? Will this also be offset by the amount the parent has rotated?

I read a recent post suggesting you could vertex paint a vertex in realtime, to get a blood stain for example, but the getMesh() array is tough, it seems to have a point for each face each vertex touches. I’m sure somone else out there has seen a face unexpectedly fly off a cube. Anyone know if there’s any info on this somwhere? Maybe a script to “sort” these values?

I don’t know at all. Sorry, I’m not a python person, but I would also Like to know how to make a bullethole on a person.

I did write a script to sort the vertices by position putting ones with equal positions together sorted from -x to +x but it messes up on anything complicated. If anyone requests I’ll put it into a user friendly format and put it here.

I’d like to use that code.

I will soon, It also has an acompanying script to control the vertices but it needs work.

This work in progress script will create an array of lists of vertex induces. The vertices should be sorted from -x to +x from the object’s center. If the xes are the same they seem to be in -y to +y as well but don’t count on it.
It is not yet setup to get meshes with both triangles and quads(squares) or to get meshes with multiple materials!
I used it in an Always sensor with no pulse. I tried somthing with 1700+ vertices and it took time to run but did not hamper performance afterwards.
MAKE SURE YOU PUT TABS IN, I DON’T KNOW HOW TO INCLUDE THEM ON THIS BOARD…

EDIT - Z3RO D posted this code in the proper format below, so I removed the unformated one. Thanks Z3ROD! See his post.

Now if you want to manipulate it take c.ass and add the lists of the vertices you want. (The "extend command seems to mess up)
vs=ass[0]+ass[1] etc.

this example worked on an 8*8 GRID mesh and made a dip at the closest vertex to a coliding object, it was linked to a collision sensor.

c=GameLogic
cont=GameLogic.getCurrentController()
own=cont.getOwner()
gho=cont.getSensor(“y”).getHitObjectList()
mesh=own.getMesh()
drop=0.01
for a in gho:
obp=a.getPosition()
la=(int(obp[1]*4))+4
print la
lb=(int(obp[0]4))+4
lx=la+lb
8
if lx>63:
lx=63
if lx<0:
lx=0
ara=c.ass[lx]

``````for b in ara:
vert=mesh.getVertex(0,b).getXYZ()
vert[2]=vert[2]-drop
mesh.getVertex(0,b).setXYZ(vert)
``````

Anyway there are a lot of applications to this kind of system, tell me what you come up with.

MAKE SURE YOU PUT TABS IN, I DON’T KNOW HOW TO INCLUDE THEM ON THIS BOARD…

Cool… How to do that? I’ll be VERY happy if you can give me a .blend file, that uses your script

-ZuiQ

``````c=GameLogic
cont=c.getCurrentController()
ow=cont.getOwner()
me=ow.getMesh()
v=me.getNumMaterials()
#print v
f=1
vx=me.getVertexArrayLength(0)
arr=[0]
axx=[[[0]]]
ass=[[[0]]]
avv=[[[0]]]
for b in range(vx):
temp=me.getVertex(0,b).getXYZ()
temp.append(b)
arr.append(temp)

#the arr array has all the vertex xyzs and ids and sorts them by x value
arr.pop(0)
arr.sort()

yoyo=9
l=0
for b in range(vx):
geek=0
for l in range(vx):

if len(avv)&gt;l:
if avv[l][0]==[arr[b][0],arr[b][1],arr[b][2]]:
#	axx[l].append(arr[b])
ass[l].append(arr[b][3])
avv[l].append([arr[b][0],arr[b][1],arr[b][2]])
geek=1
else:
break
if geek==0:
#	axx.append([arr[b]])
ass.append([arr[b][3]])
avv.append([[arr[b][0],arr[b][1],arr[b][2]]])

ass.pop(0)
avv.pop(0)
#axx.pop(0)
#print len(ass)
#ass contains all the ids grouped by location, even if there is only one
#for example: [[1,2,3],[4],[5,0]]
#avv contains only xyzs and not ids, axx is not currently used
c.ass=ass

``````

it is the

`` thing``