Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (monarch), 1,259 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 3 of 4 1 2 3 4
Re: Shotting detection in different body parts [Re: DestroyTheRunner] #256945
03/19/09 17:25
03/19/09 17:25
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
OK, kewl. The approximate code to use is like so.
Code:
BMAP* skin;
var UV[3], pixel, AlphaValue;

...
you=NULL;
dist = c_move(me, reldist, NULL, IGNORE_ME|IGNORE_PASSABLE|IGNORE_SPRITES);
if(you!=NULL)   
{  //hit some entity
   c_trace(me.x, you.x, IGNORE_ME|IGNORE_PASSABLE|IGNORE_SPRITES);
   vec_for_uv (UV, you, hitvertex);             //get UV co-ordinate of hit vertex
   skin = bmap_for_entity (you, you.frame);     //get skin at you's current frame
   format = bmap_lock(skin,0);                       //open BMAP for reading and get its format
   pixel = pixel_for_bmap(skin, UV[0], UV[1]);       //get the pixel of the UV co-ordinate
   bmap_unlock(skin);                                //close BMAP now its been read
   pixel_to_vec(NULL, AlphaValue, format, pixel);    //get pixels AlphaValue
   //do something with AlphaValue. Like
   switch(AlphaValue)
   {
      case 10:
         HitArms(you);
         break;
      case 25:
         HitLegs(you);
         break;
      case 50:
         HitTorso(you);
         break;
      case 100:
         HeadShot(you);
         break;
      default:
         Clipped(you);
   }
}
...



"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Shotting detection in different body parts [Re: EvilSOB] #256948
03/19/09 17:53
03/19/09 17:53
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Right, photoshop. Bear with me as Im doing this from memory, as I dont have Photoshop here,
and yours may be a different version. There may be some differences.

1> Open your texture in photoshop. (Original format un-important)
2> Use magic select tool with a color-range of 1(one), contiguous to select the UNUSED space
between your texture parts. All of it if possible, if its a bit broken up.
[dont de-select this mask till I say so, wink its important, we'll need it later]
2a> Optional - if you can find it, there is an option under the selection(?) menu called "Contract".
Its used to shrink the selection by xx number of pixels. Contract by 5 or so pixels.
3> Find the panel that normally shows the different layers on the image. It has a tab called "Channels".
Hit that and somewhere on this panel is a way to add new channels. Add one. It should call itself "Alpha 1".
Leave everything at default and just hit OK. You should now have a single, uniform color displayed.
4> Choose the Greyscale 0-100 pallet (happens automatic I think) and set the current color to WHITE (0%?)
5> Go to the selection menu and choose Invert, to invert our funky selection mask.
6> Fill in all our texture areas with our dead white till they are all done.
7> Now you can dump our selection mask. Basically All Done.
8> Now you can go through these Texture parts and give then different alpha levels.

REMEMBER the numbers 3dGS will see is the opposite of the 0-100 scale here in photoshop.
What you set to 10% here will be AlphaValue=90 in 3DGS.
ALSO REMEMBER you will need to make the RGB channel visible (on the channels panel) before you save.
When you save, TGA (32bit) is the best for this job. BMP's just get too big. And make sure the "Alpha Channels" box IS ticked.

That should get you started. Any questions, just ask.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Shotting detection in different body parts [Re: EvilSOB] #257794
03/25/09 15:21
03/25/09 15:21
Joined: Aug 2007
Posts: 286
DestroyTheRunner Offline OP
Member
DestroyTheRunner  Offline OP
Member

Joined: Aug 2007
Posts: 286
sorry sob... i sticked to the alpha problem and i forgot that my real problem is because i have several skins to my model.. and this color and alpha detection only works with the given skin.
eg.: bmap_for_entity (ent, ent skin);
so ill have to make the entire skin in one file, and then paint the parts with different colors.

thanks for the enlightment. i really appreciate! smile

Re: Shotting detection in different body parts [Re: DestroyTheRunner] #257839
03/25/09 20:57
03/25/09 20:57
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Gah! Me too. Oh well, one skin it is.

"Actually, no, wait a minute, whats that switch there..."

Do you think this is managable, create a duplicate SET of skins in each model, that are a low-res hit-point-color only skins.
When we have detected a hit, swap skins, c_trace(using SCAN_TEXTURE) to get the color at the target point(through TEX_COLOR),
then swap the skins back.

If its done inside 1 frame it should work, but it all depends on IF the skin swapping can be done quick enough in A6,
cause I have no idea how it switches between skins on a multi-skin model. I never have had to.

BUT do some testing of retrieving tex_color first, the manual says that it gets "color of the lightmap at the hit position."
Im not clear on how this works with multi-skin models though. It may not give us what we want...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Shotting detection in different body parts [Re: EvilSOB] #257859
03/26/09 01:02
03/26/09 01:02
Joined: Aug 2007
Posts: 286
DestroyTheRunner Offline OP
Member
DestroyTheRunner  Offline OP
Member

Joined: Aug 2007
Posts: 286
lol!

SOB actually the method that we achieved until now, works with 2 skins.
The first one is my real model skin( all grouped and packed in one TGA file) and the other one is a copy of the model real skin but in colors, where it is the head, its painted red, where its an arm its painted blue... and so on...
Lets say that my model real skin is 0 and the color value skin is 1.

So i can search in my skins by knowing that the color value skin is 1.. so
bmap_for_entity (stupid_ent, 1); //color value skin

so... if i have 3 real skins(head, body and arms&legs), i would need more 3 color value skins.
so this methods works GREAT with one real skin, but fails with anything more than that, since for every real skin your model got, i would need an extra color value skin!


ps1. SCAN_TEXTURE in c_trace only gives the texture name if it is a level block. if it is an entity,sprite or terrain it gives the model/bmap file name.

ps2. From the manual:
Quote:

The variable tex_light gives the shadow map brightness (0..255) at the hit position in the level, tex_color gives the light color and tex_fog gives the fog / albedo value.


tex_color doesnt work of me either.

Im almost completely convinced that as long as i dont buy something more than A6 standard. Ill have to have my models with only one skin if i want to have a body hit detection.

Re: Shotting detection in different body parts [Re: DestroyTheRunner] #257860
03/26/09 01:13
03/26/09 01:13
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Its not clear here, but are you using the SCAN_TEXTURE flag in the c_trace, when testing "tex_light"and "tex_color"?

The way I interpret the A7 manual, it seems you need to use the SCAN_TEXTURE flag otherwise it doesnt update the variables tex_light, tex_color.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Shotting detection in different body parts [Re: EvilSOB] #257864
03/26/09 01:44
03/26/09 01:44
Joined: Aug 2007
Posts: 286
DestroyTheRunner Offline OP
Member
DestroyTheRunner  Offline OP
Member

Joined: Aug 2007
Posts: 286
what i meant with 'doesnt work' means actually that its not usefull for me..
Scan_texture gives the model name and not the texture. and even if updates tex_light it wont work/be useful for me for what i need.

sorry for the complication!

Re: Shotting detection in different body parts [Re: DestroyTheRunner] #257865
03/26/09 02:00
03/26/09 02:00
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
But what about the tex_color? Does that (when updated by SCAN_TEXTURE) give
the pixel color of the hit skin, or something else? The manual isnt clear.

And you werent complicating, I was just trying to read between the lines.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Shotting detection in different body parts [Re: EvilSOB] #257927
03/26/09 16:25
03/26/09 16:25
Joined: Aug 2007
Posts: 286
DestroyTheRunner Offline OP
Member
DestroyTheRunner  Offline OP
Member

Joined: Aug 2007
Posts: 286
tex_color gives the light that is reflected or inflicted in the model, or something like this.
Still, i dont need tex_color because i already managed to get the color of the skin through the given xy coordinade.
The only problem for me is still that this method only works with one real skin and one color value skin.
frown

anyway thanks SOB for the help. Ill show you the results later when my game became playable.

Re: Shotting detection in different body parts [Re: DestroyTheRunner] #257956
03/26/09 21:22
03/26/09 21:22
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
OK good luck.

Also remember, the hit-color skin does not need to be as high detail as the real texture.
Say your real texture is 1024x1024, your hit-color skin can be 128x128 and it will get
"stretched" across the same UV mapping co-ordinates. It only need to have a
high enough resolution to make sure the right hit-colors are on the right body parts.
You can just let the colors bleed into the un-used space between body parts with no fear,
or just fill that unused space with the lowest hit-color value so everything is covered.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 3 of 4 1 2 3 4

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

Gamestudio download | chip programmers | 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