Hey,
I’m currently trying to implement Bullet-Holes into my Game.
My first thought was to create a Quad with the Texture of the Bullethole and just put it where it hit the Wall.
My Problem is now, how to rotate the Quad, so it fits on the Wall and doesn’t look weird.
I’m not quite sure how to explain this, so here are two Screenshots:
How it’s supposed to be:
And how it’s not supposed to be:
Currently I’m loading my Map from an XML-File and all the Walls are just Boxes, but i want to change this and load a Model instead.
For the beginning it would be enough to put the quad on the Box, but since i want to change this and load a Model instead it would be nice to know how to put the Quad on a Mesh.
So this is the method i’m currently using to make the Quad fit on the Box:
private void faceBox(Quad bulletHole, Box b, Vector3f start, Vector3f end) {
if(b.getXExtent() > b.getZExtent() && b.getYExtent() > b.getZExtent()) {
// System.out.println("z small");
bulletHole.lookAt(bulletHole.getLocalTranslation().add(new Vector3f(0,0,5)), Vector3f.UNIT_Y);
}else if(b.getYExtent() > b.getXExtent() && b.getZExtent() > b.getXExtent()) {
// System.out.println("x small");
bulletHole.lookAt(bulletHole.getLocalTranslation().add(new Vector3f(5,0,0)), Vector3f.UNIT_Y);
}else if(b.getXExtent() > b.getYExtent() && b.getZExtent() > b.getYExtent()) {
// System.out.println("y small");
bulletHole.lookAt(bulletHole.getLocalTranslation().add(new Vector3f(0,5,0)), Vector3f.UNIT_Y);
}else if(b.getXExtent() == b.getYExtent() && b.getYExtent() == b.getZExtent()) {
// All sides are the same
bulletHole.lookAt(start, Vector3f.UNIT_Y);
}
}
start is the Location, from where the player shoot and end is the location, where the bullet hit the box.
But as you can see, this method isn't really good and it won't work on any other Meshes.
So is there a better way to do this? (which hopefully also works on any other mesh?)
Dennis