Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Drac X
21
Years of Service
User Offline
Joined: 6th Sep 2003
Location:
Posted: 6th Sep 2003 22:37
Just started with this thing. Using dark basic classic (on day 3).
I've got a gun. It rotates on it's Y axis. When it shoots, the projectiles travel in just the direction they are supposed to (harder than I thought that would be). When the gun shoots, it makes a 3d sound. When the shots hit something, they make a noise too. And when the shots (lasers) fly over the ground, they make a neat lighting effect (which I'm really pleased with since I only have a limited number of light sources). So I'm new, but I'm workin' things out.

The next thing I want to add to my little dealy here is bullet holes.

I'm using a textured plain to accomplish this. Is this the best way?

I've got the location and orientation of my projectile, and the location and orientation of my target.

My target is currently a cube with a size of 3 units, and that has me puzzled enough. But what if my target isn't a cube? What if it's a sphere, or an irregular polygon?

What I DON'T have, and in fact, don't know how to get, is the location of impact. I'm not sure having that would solve all of my problem, as I don't know how to figure out the orientation of the plain once I've got the point of impact.

I'm not even sure what I need to ask for really... if someone can toss an explanation of my problem at me and a few formulas, that'd be great.

I've got some experience writing code, but I dropped out of highschool about as soon as I got through the front door. As a result, this math is a lot to chew on.

Drac - X
_________________
Excerpt from 'A Day in the Life of Some Guy' ©2003
Mucky Muck Ninja
21
Years of Service
User Offline
Joined: 4th Sep 2003
Location: im not entirely sure
Posted: 7th Sep 2003 04:08
I am not sure about making the hole but I imagine that you would get the X,Y,Z position of the bullet just as it hits. Like in this code. Hope that works!

Am I an Idiot...or is everyone else just really smart?
Drac X
21
Years of Service
User Offline
Joined: 6th Sep 2003
Location:
Posted: 7th Sep 2003 11:32
As it turns out, it's not as simple as that. There are a couple of problems.

1) I'm moving my projectile a certain number of units per cycle, so it's not as if the projectile passes through every point in it's path.

2) Even if it does for purposes of Object Hit(), if I place the decal exactly on the plane of the target, the decal is invisible, so I need to scoot it out a tiny bit (like .01 units) away from the target so it will show up.

I've attached the routine I'm using to attach the decal. Maybe someone can take a look at it and point out what I'm doing wrong? As it stands right now, it seems like I'm on the right track, but the decals are popping up inside the target, and in a round patter, as if the cube(the target) were actually a sphere.

Drac - X
_________________
Excerpt from 'A Day in the Life of Some Guy' ©2003
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 7th Sep 2003 12:46
I'm too lazy to look, but this can be solved with itterating by the 1/2 rule.

If the object hits, move it halfway between the new and old pos. Then repeat the process with the halfway point as the new coords, the previous new coords as the old. Keep doing this until the difference between new pos and old pos is marginal and the bullet is NOT colliding with the object.

As for the orientation of the bullethole plain, you'll need to do several tests similar to the one I described. The easiest way is one test per vertex to find out the angle between the collision points, so you know how much to rotate the plain on each axis.

Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 7th Sep 2003 12:49
Of course this would be much easier with the DarkCollision dll. This way, you could get the point of intersection and the face's normal vector (for rotating the decal plain).

David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 7th Sep 2003 13:49
Quote: "As it turns out, it's not as simple as that. There are a couple of problems.

1) I'm moving my projectile a certain number of units per cycle, so it's not as if the projectile passes through every point in it's path."


Move the projectile less, or increase it's collision radius to it's speed + 1 so you're guaranteed a hit.

Quote: "2) Even if it does for purposes of Object Hit(), if I place the decal exactly on the plane of the target, the decal is invisible, so I need to scoot it out a tiny bit (like .01 units) away from the target so it will show up."


Once the bullet has hit, point it at at player, move it forward slightly and then set it to it's original orientation.

Another idea would be to always have the plain object attached to the bullet. However, make the plain have sliding collision on the walls, ie. whereas the bullet will be able to travel through walls until you register an object hit() and it is destroyed, the plain object would stay on the wall's surface and "slide along" folowing the bullet buit not going through the wall until the bullet is destroyed, when the plain wil be shown.

Tha's slightly complex nad hard to demonstrate in DarkBASIC, however in DBPro some of the collision functions'd make it easier.

Theres no place like 127.0.0.1
There are 10 people in this world, those who understand binary and those who don't
Bus station = where bus stops. Train station = where train stops. Workstation = ?
Drac X
21
Years of Service
User Offline
Joined: 6th Sep 2003
Location:
Posted: 8th Sep 2003 05:25
You know, it's incredible the way you can get around nasty math with a little creative thinking. I'm not going to do it this way because I'm taking a short break from the project so I can teach myself vector mathmatics, but I'm going to save a copy of this post. Way to go on the creative thinking.

Drac - X
_________________
Excerpt from 'A Day in the Life of Some Guy' ©2003
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 8th Sep 2003 07:00
Found the link. You're best using this if you're in DBC (provided that you have the enhancement pack), as any collision command in DBC is painfully slow.

http://www.nuclearglory.com/developer/db/kdll.html
This will get you the point of intersection with the obstacle, and the face normal vector so you know how to rotate the decal.

CalvinHobbes2
21
Years of Service
User Offline
Joined: 23rd Jul 2003
Location: United Kingdom
Posted: 8th Sep 2003 19:04
Well, when I have downloaded the 3D Monster Hunt, That might have happened to me aswell...

"With great power, comes great responsibility." --Uncle Ben

SPIDER MAN 2: Swinging in theatres July 2nd 2004

Login to post a reply

Server time is: 2025-05-20 08:02:28
Your offset time is: 2025-05-20 08:02:28