2 registered members (AndrewAMD, TipmyPip),
12,709
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Collision detection and transparent TGAs
#134604
06/07/07 20:29
06/07/07 20:29
|
Joined: Oct 2005
Posts: 131
CBSection31
OP
Member
|
OP
Member
Joined: Oct 2005
Posts: 131
|
Hey everyone, I've created a TGA file containing an image of a giant puddle of water. I placed this TGA in my level and assigned an action to it. Basically, the action detects collision with another entity--a ball entity. When the ball is thrown, it normally bounces on the ground. When the ball collides with the puddle, it makes a splash sound, using event_impact. This all works perfectly. The problem I'm having - and I'm not sure a solution is even possible - is this: the puddle is round, but obviously the image file is square. So, when the ball hits the edges of the TGA image, it makes a splash sound, even though there is no water along the edges of the file. The image below explains what I mean. Is it possible to somehow detect if the ball is only hitting a non-transparent portion of the TGA? My guess is no, it isn't possible, but it doesn't hurt to ask! 
|
|
|
Re: Collision detection and transparent TGAs
[Re: CBSection31]
#134605
06/08/07 04:57
06/08/07 04:57
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
It's possible, but it might take alot of code.
Basically, you'd have to put the texture on a flat model. Then, using the target vector to see where the ball hit the image, convert the vec to texture coords (not as hard as it sounds), and then get that pixel from the image and check!
Or, you could simply using a circular range for the collision, and check if distance from model center to target vec is less than X...
xXxGuitar511 - Programmer
|
|
|
Re: Collision detection and transparent TGAs
[Re: xXxGuitar511]
#134606
06/08/07 12:41
06/08/07 12:41
|
Joined: Nov 2006
Posts: 141 South Africa
quasarchangel
Member
|
Member
Joined: Nov 2006
Posts: 141
South Africa
|
Puddles of water usually don't stand out above the ground. What are you using as ground, a terrain? If you place the puddle file a bit lower so the edges are below ground you shouldn't have the problem, or am I not understanding correctly?
God DID give us a manual on how to change this world...
|
|
|
Re: Collision detection and transparent TGAs
[Re: xXxGuitar511]
#134608
06/08/07 16:25
06/08/07 16:25
|
Joined: Aug 2000
Posts: 7,490
Orange Brat

Senior Expert
|

Senior Expert
Joined: Aug 2000
Posts: 7,490
|
I suppose this kind of problem could pop up for any number of situations. I can think of a few. I don't suppose there's already a flag or attribute within the existing c-script syntax to force the engine to "ignore" an alpha value of (0,0,0). That would be one way to get around this, but I don't know if that's possible now or if will ever be. I know this problem existed with oddball shaped buttons and panels, although I think it might have been fixed and the alpha does get ignored (or maybe it's in the pipeline or maybe I'm just making that up  ).
My User Contributions master list - my initial post links are down but scroll down page to find list to active links
|
|
|
Re: Collision detection and transparent TGAs
[Re: Shadow969]
#134610
06/08/07 17:48
06/08/07 17:48
|
Joined: Oct 2005
Posts: 131
CBSection31
OP
Member
|
OP
Member
Joined: Oct 2005
Posts: 131
|
Thank you for all your responses!  quasarchangel - It is an indoor level (my outdoor levels use terrain), so I am using blocks, and I have the TGA barely above the ground. The model method would work, but that presents another minor issue: the TGA is animated, to look like raindrops are falling on the texture. There are 8 frames of this. Is there a way to animate the texture of a model (8 frames worth)? If there is, then that might be the best way to go.
|
|
|
|