GLBasic forum

Main forum => Bug Reports => Topic started by: Millerszone on 2011-Apr-19

Title: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-19
Made a small program to confirm transparency part of sprite causing collision detection using a .png (PNG-24) with transparency.
Not using the Pink RGB(255,0,128), even though it doesn't make a difference.

Using GLBasic 9.052
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Kitty Hello on 2011-Apr-19
Code (glbasic) Select

CREATESCREEN 0,0,32,32
USESCREEN 0
DRAWRECT 0,0,32,32,RGB(255,0,128)
DRAWRECT 0,0,16,16,0xffffff
USESCREEN -1

DRAWRECT 100,100,32,32,0x505050
DRAWSPRITE 0,100,100
DRAWSPRITE 0,120,120


IF SPRCOLL(0,100,100,  0,140,140)
PRINT "COL", 100,200
ELSE
PRINT "NO COL",100,200
ENDIF
SHOWSCREEN
MOUSEWAIT
END


What does it say?
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-19
NO COL
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Kitty Hello on 2011-Apr-19
Excellent. Now I need a device to debug. I contacted Palm for the issue. Darn.

Does the console show any debug information for you? (compiler/webos/tools/bin/deviceshell.bat)
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-19
When i run, i get Putty fatal error, "Sever unexpectedly closed network connection".
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-19
If want me to test anything, I'm here.
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Kitty Hello on 2011-Apr-19
tool/bin/novaterm/pdk-device-install.bat <-- after that the "server unexpectedly closed network connection" should be gone.
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-19
O.K. now I have this:
Using username "root".
root@palm-webos-device:/var/home/root#

I never used before. Where do I look for the debug info?
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Kitty Hello on 2011-Apr-19
you cd to the directory:
cd /media/cryptofs/<tab><tab> palm.. apps... com.glbasic.yourapp
then type:
./glbasic-exe-webos

I think the manual has the path listed in the GLBasic intern/WebOS section.
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-19
This is the log from your test code. Did you want my HTD Baseball log file?
Code (glbasic) Select
=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2011.04.19 10:52:58 =~=~=~=~=~=~=~=~=~=~=~=
./glbasic-webos-exe
Init OGLRB
SDL_init video
SDL_GetVideoInfo = 320x480 @ 32 bpp
Setting video mode: 0x0x0 fl=2
SDL_SetVideoMode seems to be 1
flip
glclear
msgloop
...done
frame counter: next 0  cur 570
flip finished
flip
glclear
msgloop
...done
frame counter: next 586  cur 598
flip finished
flip
glclear
msgloop
...done
frame counter: next 598  cur 620
flip finished
BGRA ext supported
Framebuffer is init
init nw
init 3D
ctor inp
toggle fullscreen 1
init inp
exe path
1st flip
flip
glclear
msgloop
...done
frame counter: next 631  cur 694
flip finished
2d vp
smalfont
1st timer
system ptr 1
shared objects
Init sound engine
Init Finalized
flip
glclear
msgloop
...done
frame counter: next 710  cur 890
flip finished
Shut down GLB
glb is shut down
PDL_Quit
</PDL_Quit>
exit
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Kitty Hello on 2011-Apr-20
No. There's no error printed. I have to see what it does and might come back to you to test a more verbose version.
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-20
Quote from: Kitty Hello on 2011-Apr-20
No. There's no error printed. I have to see what it does and might come back to you to test a more verbose version.
Ok
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Kitty Hello on 2011-Apr-21
Can you test this and see if there's more info?

It works perfectly on a 2.1 device. Seems a driver issue.



[attachment deleted by admin]
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-21
I get NO COL

I'm getting "-sh: com.glbasic.support: Permission denied" when I try to get the log.

I also tried on other test app and got the same thing.

Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-21
Yes still in development mode.
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: MrTAToad on 2011-Apr-21
Can you try sending it to a PC ?
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: spacefractal on 2011-Apr-21
I have to ask:

1. Does this also happens with none transparency png, using pink (etc 8bit png instead of 24bit)?
2. How about using a real alpha png, rather than a transparency color?

Those could been used for col checks only.
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-21
Quote from: spacefractal on 2011-Apr-21
I have to ask:

1. Does this also happens with none transparency png, using pink (etc 8bit png instead of 24bit)?
2. How about using a real alpha png, rather than a transparency color?

Those could been used for col checks only.

I am using a real alpha transparency png and I also tried the pink transparency color.

If anyone wants to send me some code to test, I'll be glad to test it.
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Slydog on 2011-Apr-21
Are you trying to detect if the player presses inside the 'pitch' and 'swing' button areas?
They are both triangular, so do you have rectangular pngs for both, but only want to detect the non-transparent portion?

You could try detecting the touch by checking if the touch point is inside the triangular button by using the following function:
(from a Visual Basic 6 project of mine, so it will need to be converted to GLBasic, but simple (excuse my old naming convention!))

Code (glbasic) Select
Public Function gxTriangle_IsPointInside(uXY As udtPoint, uT1 As udtPoint, uT2 As udtPoint, uT3 As udtPoint) As Boolean
    Dim fAB As Double
    Dim fBC As Double
    Dim fCA As Double

    fAB = CDbl((uXY.y - uT1.y) * (uT2.x - uT1.x)) - CDbl((uXY.x - uT1.x) * (uT2.y - uT1.y))
    fBC = CDbl((uXY.y - uT2.y) * (uT3.x - uT2.x)) - CDbl((uXY.x - uT2.x) * (uT3.y - uT2.y))
    fCA = CDbl((uXY.y - uT3.y) * (uT1.x - uT3.x)) - CDbl((uXY.x - uT3.x) * (uT1.y - uT3.y))

    If (fAB * fBC > 0) And (fBC * fCA > 0) Then
       gxTriangle_IsPointInside = True
    Else
       gxTriangle_IsPointInside = False
    End If
End Function


udtPoint is a TYPE with only (x, y) properties.
uXY is the Touch point.
uT1,uT2,uT3 are the Triangle 3 points.
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-22
Slydog I fixed all of the buttons. The problem is, the transparency part of the sprite(bat) is triggering collisions with WebOS 1.4.5

Thanks anyway.






Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-22
I made a small program with just the original baseball background, bat and ball, with bat and ball collision an of course it didn't work the first time, but after a few changes I got the ball to go through the bat's transparency without collision. Here is what I did.

First, for the bat I changed the mode to indexed color, then back to RGB Color in photoshop, so now the bat is pure black with a transparency background, then I filled the background with RGB(255,0,128).
Now for the ball, just like the bat, I changed the mode to indexed color, then back to RGB Color in photoshop, so now the ball is pure black with a transparency background, but I didn't change the background to RGB(255,0,128), or else the ball would collide with the bat's transparency.

So, I thought I found a temporary fix, nope. Just by adding another sprite to the code and ball would collide with the bat's transparency. So very inconsistent.

It seems like the problem is coming from LOADSPRITE, because SPRCOLL doesn't work when using LOADSPRITE, but Gernot test program above worked with SPRCOLL, but he didn't use LOADSPRITE.
Also BOXCOLL works perfect.

Just a guess. :S
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Slydog on 2011-Apr-22
Could you load them in using LOADSPRITE then draw them to the screen and copy them into a new sprite?  Or would that loose the transparency? 

And, this is for the actual bat and ball in the game area?  I had assumed this game was in 3D mode but maybe used 2d physics.  If this is purely 2D then bravo, very well simulated!  :nw:

[Edit] Not to imply that if it's in 3D that it isn't as impressive! ha
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-22
Yes, I tried grabsprite, lost the transparency.

HTD Baseball is all 2D, this is only my second game, so 3D was out of the question. If I was going do something like this again
I would use 3D. I'm probably going to add Box2D to improve the bat and ball physics.


Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-22
Gernot I finally got passed the "Permission denied". here is the log:
Code (glbasic) Select
root@palm-webos-device:/media/cryptofs/apps/usr/palm/applications/com.glbasic.support# ./glbasic-webos-exe
SDL_init video
SDL_GetVideoInfo = 320x480 @ 32 bpp
Setting video mode: 0x0x0 fl=2
SDL_SetVideoMode seems to be 1
BGRA ext supported
exepath: /media/cryptofs/apps/usr/palm/applications/com.glbasic.support/glbasic-webos-exe
Init Finalized
Shut down GLB
glb is shut down
PDL_Quit
</PDL_Quit>
exit

Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Kitty Hello on 2011-Apr-22
I get no error. There's a bug in glReadPixels from a framebuffer object then. Oh my.
I'll contact Palm.
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: ampos on 2011-Apr-22
Quote from: Kitty Hello on 2011-Apr-22
I get no error. There's a bug in glReadPixels from a framebuffer object then. Oh my.
I'll contact Palm.

Perhaps related with the mem2sprite bug?
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Kitty Hello on 2011-Apr-22
sprite2mem will not work, I think.
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: ampos on 2011-Apr-23
Quote from: Kitty Hello on 2011-Apr-22
sprite2mem will not work, I think.

No, ir didnt work. In fact, it crashes the apps.
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Kitty Hello on 2011-Apr-24
caan you paste the crashlog? (DeviceShell output)
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: ampos on 2011-Apr-24
Quote from: Kitty Hello on 2011-Apr-24
caan you paste the crashlog? (DeviceShell output)

http://www.glbasic.com/forum/index.php?topic=6090.msg48385#new (http://www.glbasic.com/forum/index.php?topic=6090.msg48385#new)

if you need something else, just ask  :)
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-Apr-29
Gernot, did you find out what was causing the transparency collision problem?

I got the bat and ball working on HTD Baseball, but I had to butcher the code to make it work.
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Kitty Hello on 2011-May-03
I don't have a 1.4.5 device. No reply from Palm, yet. The problem definitely is in glReadPixels - it's a driver issue I think. I have no idea if it can be fixed at all.
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Kitty Hello on 2011-May-05
There is an OTA update to WebOS 1.4.5.1 today. Does it fix it?
Title: Re: Transparent part of sprite causing collision on WebOS 1.4.5
Post by: Millerszone on 2011-May-05
I just checked, no updates available yet on the Palm Pre(1)