Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (AndrewAMD, TipmyPip, NewbieZorro, Grant), 14,196 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Collision detection and transparent TGAs #134604
06/07/07 20:29
06/07/07 20:29
Joined: Oct 2005
Posts: 131
C
CBSection31 Offline OP
Member
CBSection31  Offline OP
Member
C

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 Offline
Expert
xXxGuitar511  Offline
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 Offline
Member
quasarchangel  Offline
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: quasarchangel] #134607
06/08/07 16:16
06/08/07 16:16
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
He most likely has it placed ~4 quants above a map block.


xXxGuitar511
- Programmer
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
O
Orange Brat Offline

Senior Expert
Orange Brat  Offline

Senior Expert
O

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: Orange Brat] #134609
06/08/07 16:41
06/08/07 16:41
Joined: Oct 2006
Posts: 873
S
Shadow969 Offline
User
Shadow969  Offline
User
S

Joined: Oct 2006
Posts: 873
I'd prefer xXxGuitar's solution, but implementing this may be difficult. There's one other solution - make a model that represents the puddle's shape and use a polygonal collision

Re: Collision detection and transparent TGAs [Re: Shadow969] #134610
06/08/07 17:48
06/08/07 17:48
Joined: Oct 2005
Posts: 131
C
CBSection31 Offline OP
Member
CBSection31  Offline OP
Member
C

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.

Re: Collision detection and transparent TGAs [Re: CBSection31] #134611
06/08/07 18:59
06/08/07 18:59
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
8 skins

Just animate through the skins. Someone should hopefully post an example, cause I've got to go to work, don't have time


xXxGuitar511
- Programmer
Re: Collision detection and transparent TGAs [Re: xXxGuitar511] #134612
06/08/07 22:14
06/08/07 22:14
Joined: Oct 2005
Posts: 131
C
CBSection31 Offline OP
Member
CBSection31  Offline OP
Member
C

Joined: Oct 2005
Posts: 131
Oh, I already know how to do multiple skins. I just never thought of using it for animation!

Re: Collision detection and transparent TGAs [Re: CBSection31] #134613
06/09/07 09:11
06/09/07 09:11
Joined: Oct 2006
Posts: 873
S
Shadow969 Offline
User
Shadow969  Offline
User
S

Joined: Oct 2006
Posts: 873
Code:
 action animated_puddle
{
while(1)
{
my.skin+=1*time;//1 - skin change speed
my.skin%=8;//cycle through 8 skins
wait(1);
}
}


Simple skin changing example

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1