To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > General Help > Games

Reply
 
Thread Tools Search this Thread Display Modes
Old 03-28-2007, 10:29 PM   #1
trogdor458
Please, Call Me Bob
 
trogdor458's Avatar
 
Join Date: Aug 2006
Location: Pensacola, FL
Posts: 875
[HELP]"projecting" a bitmap

honestly, ive gotten myself seriously stuck with this whole "super-perfect collision" deal ive been trying every now and then

its not so much i cant figure out what to do with the bitmap objects after collision, its simply determining the collisions in the first place

these bitmaps will be physic enabled objects (correction: MIGHT be, if i ever get anywhere with this) and will perform picture-perfect collisions no matter what their speed

because they may be travelling at high speeds, you cant just do a simple bitmap to bitmap collision, you'll have to collide the path of the object, with a background object

my question is therefore: does anyone have an idea on how to "project" bitmap paths? this things going to have a total combo of rotations, velocity, and accelerations all on it, so making a path is kind of tricky

that, and ive also downloaded flash 9 and dont have the foggiest idea about it either

would anyone be so kind as to offer some ideas?
__________________
trogdor458 is offline   Reply With Quote
Old 03-28-2007, 11:35 PM   #2
mr_malee
M.D.
 
mr_malee's Avatar
 
Join Date: Dec 2002
Location: Shelter
Posts: 4,039
here's something i made a while ago. I would probably do things a bit different now, but maybe it'll help you out.

I don't really want to think about new methods right now, so i can't help that much.
__________________
lather yourself up with soap - soap arcade
mr_malee is offline   Reply With Quote
Old 03-29-2007, 12:20 AM   #3
trogdor458
Please, Call Me Bob
 
trogdor458's Avatar
 
Join Date: Aug 2006
Location: Pensacola, FL
Posts: 875
at first glance i guess i dont understand what this is doing, i suppose your testing your lines against others using that whole getColorBoundsRect thing, which I have managed to use succesfully already

in fact, i almost got a sphere supercollision working %100, until I found out that I might need multiple supercollision tests as the ball could bounce off really fast, and although the bounce would be determined correctly, it would not retest to see if it bounced more than once in a single frame

it would appear i got rid of that version however and replaced it with even more disfunctional ones? darn, i was going to post it (seeing as the path of the ball would remain drawn, the thing looked like a bullet ricocheting everywhere)

i had managed to determine slope of its collision based only off the rectangle it left behind, and the direction of the ball (though with the way I set it up, it seemed to work better with the ball going super fast)

thanks for posting (i really appreciate it), but its not exactly what I need

imagine defining the path of a ball, easy enough to do with your drawing api, but is it possible with a more complex shape? a complex shape, that rotates

i have a bad feeling i might have to try simpler collisions, because there does not appear to be a fast way of doing this
__________________
trogdor458 is offline   Reply With Quote
Old 03-29-2007, 12:57 AM   #4
mr_malee
M.D.
 
mr_malee's Avatar
 
Join Date: Dec 2002
Location: Shelter
Posts: 4,039
i really don't understand your problem. Maybe you could do s aimple diagram of what you want to achieve.
__________________
lather yourself up with soap - soap arcade
mr_malee is offline   Reply With Quote
Old 03-29-2007, 01:10 AM   #5
renderhjs
Student
 
Join Date: Apr 2001
Location: -
Posts: 4,756
@ trogdor458: you are writing to much (makes my head dizzy),- would be more pleasent if you´d provide a demo or illusration of the actual question/ issue
renderhjs is offline   Reply With Quote
Old 03-29-2007, 12:47 PM   #6
newblack
Senior Member
 
Join Date: May 2006
Location: Manhattan
Posts: 229
it really sounds like you're trying to squeeze an elephant into a jar. doing a pairwise pixel by pixel comparison (maybe...) makes sense, but to force an object's path through rendering to determine collision is bypassing the mathematics of the situation by asking the flash player to work doubly hard.

find a way to represent your objects geometrically.
newblack is offline   Reply With Quote
Old 03-29-2007, 06:18 PM   #7
trogdor458
Please, Call Me Bob
 
trogdor458's Avatar
 
Join Date: Aug 2006
Location: Pensacola, FL
Posts: 875
right, sorry if i wasnt clear enough, heres a basic diagram of what i need to do:

and i think you may be right newblack, either ill have to create my own vector data, or use the "marching squares" technique to determine the vectors of the bitmap ahead of time

although just a plain bitmap to bitmap collision might be impossible, i think i can figure out some logic in a line segment to vector collision

however, id have to figure out which side hits first (*sigh*), and the path of a single side would be really weird and possibly troublesome to calculate

i wanted to avoid this kind of collision, because i was hoping i could fit it into just a single procedure (which even then there's the possibility of multiple bounces)
__________________
trogdor458 is offline   Reply With Quote
Old 03-29-2007, 07:14 PM   #8
renderhjs
Student
 
Join Date: Apr 2001
Location: -
Posts: 4,756
bitmap & bitmap comparison is just waste of CPU imo. because a bitmap is basicly a very huge array each cell with a plain information (hit or not)- there are so many more effective ways as this brute force method (its almost like any other method is more effective as this one).

Perhaps you are searching for octree techniques:
http://en.wikipedia.org/wiki/Octree
this budy shows very good what it´s benfits are:

insead of computing each pixel of the complex character shape you analyze before the shape and devide it into different block sizes. Once done you only check collision with those blocks and once hit do a brute force collision only on that block part of the detailed shape.

some links explaining better what as I can do atm:
http://www.gamasutra.com/features/19970801/octree.htm
http://www.flipcode.com/articles/art...ooctrees.shtml
renderhjs is offline   Reply With Quote
Old 03-29-2007, 07:30 PM   #9
trogdor458
Please, Call Me Bob
 
trogdor458's Avatar
 
Join Date: Aug 2006
Location: Pensacola, FL
Posts: 875
no thinks, i think ill stick to the vector method, im pretty sure i might be able to whip up an equation thats based off a few variables:
xinitial,yinitial,length,rotation,acceleration,vel oinitial, and time

however, itll still be hard to test against all those other vectors...therefore, ill have to make something to narrow down the number of vectors it hitTests against

the good thing is that this means i can make this thing completely math-based, which ive heard as3 is VERY good with

ill need to use that instead if I can ever figure out why it keeps throwing all these errors at me

EDIT: why does veloinitial look like vel oinitial?
__________________
trogdor458 is offline   Reply With Quote
Old 03-29-2007, 08:54 PM   #10
newblack
Senior Member
 
Join Date: May 2006
Location: Manhattan
Posts: 229
i made this a little while ago that illustrates collision detection for circles independent of their velocities:
http://lab.generalrelativity.org/circle_collision/

here's my post about it, where you can also find the source files:
http://blog.generalrelativity.org/?p=7
newblack is offline   Reply With Quote
Old 03-29-2007, 11:33 PM   #11
Flashkit
FK founder & general loiterer
 
Flashkit's Avatar
 
Join Date: Feb 2000
Location: Sydney
Posts: 1,148
http://www.johanvanmol.org/content/category/6/23/37/
ball collision based on whether the vectors cross. Havent played with it but looked pretty solid
__________________
Regards Mark Fennell - Flash Kit Founder, general loiterer
-------------------------------
markfennell.com | original games | world panoramas
Flashkit is offline   Reply With Quote
Old 03-30-2007, 06:11 PM   #12
trogdor458
Please, Call Me Bob
 
trogdor458's Avatar
 
Join Date: Aug 2006
Location: Pensacola, FL
Posts: 875
although that example is very nice looking, and again, thanks for the post, its irrelevant to the thing i may or may not get around to this weekend

for collisions like these, time is pretty much the variable youre trying to figure out (equations sure are useful!!), and then you can determine collision position and rotation off of that

since equations are pretty solid, it makes this process easier than the whole (make up fantasy ways of figuring it out)

got another question. will i just continue to slack off?

*shake*shake*shake*

Answer: Hell yes
trogdor458 is offline   Reply With Quote
Old 03-30-2007, 06:27 PM   #13
Cimmerian
hippie hater
 
Cimmerian's Avatar
 
Join Date: Oct 2006
Location: over there
Posts: 599
Are your bitmaps going to rotate?
Cimmerian is offline   Reply With Quote
Old 03-30-2007, 07:19 PM   #14
trogdor458
Please, Call Me Bob
 
trogdor458's Avatar
 
Join Date: Aug 2006
Location: Pensacola, FL
Posts: 875
yes, if i had stuck with my initial idea

i think ill choose a different approach though, seems easier and more efficient
__________________
trogdor458 is offline   Reply With Quote
Old 03-31-2007, 08:02 AM   #15
Cimmerian
hippie hater
 
Cimmerian's Avatar
 
Join Date: Oct 2006
Location: over there
Posts: 599
grant skinner has made a class to shape shape hitTest, you can google it
But if you think on f8 powers, this is nothing expectacular,Is just a matter of have acess to the pixels of each shape
I have an idea but havent tested yet, wich is make a shape shape hittest using 'tiles' that are just data for each pixel on screem, the complication will start when the shapes rotate, but i suspect its possible to pre calculate his pixel values for each rotation value...
Cimmerian is offline   Reply With Quote
Old 03-31-2007, 12:49 PM   #16
trogdor458
Please, Call Me Bob
 
trogdor458's Avatar
 
Join Date: Aug 2006
Location: Pensacola, FL
Posts: 875
...its not just a hitTest, im trying to calculate perfect physics.
you know how if things go too fast in some games, they'll go right through the walls? im going to attempt to fix that common problem

using colorBoundsRect is what I found to be an easy way to hitTest bitmaps
__________________
trogdor458 is offline   Reply With Quote
Old 03-31-2007, 08:56 PM   #17
trogdor458
Please, Call Me Bob
 
trogdor458's Avatar
 
Join Date: Aug 2006
Location: Pensacola, FL
Posts: 875
anyone know of a complex inequality solver lying around? if not, i might have to run this doozy of equations through a loop:
Quote:
//y=Math.atan(rotinitial+rotvelo*time)(x-xinitial-xvelo*time)+yinitial+yvelo*time
//y=avar*x*x+bvar*x+cvar
//Math.max(xinitial+xvelo*time-Math.abs(length/2*Math.cos(rotinitial+rotvelo*time)),xbegin)>=x>=M ath.min(xinitial+xvelo*time+Math.abs(length/2*Math.cos(rotinitial+rotvelo*time)),xend)
//time>=0
and ill have to find the smallest time possible...hell if i can solve it
__________________
trogdor458 is offline   Reply With Quote
Old 03-31-2007, 09:50 PM   #18
trogdor458
Please, Call Me Bob
 
trogdor458's Avatar
 
Join Date: Aug 2006
Location: Pensacola, FL
Posts: 875
anyone? becuz using a loop would kind of defeat the purpose here...
best inequality solver i found was the first one i found:
http://www.hostsrv.com/webmab/app1/M...advanced#reply

but when i ask something like sine(x)<0.5 it responds with x<0.523599, which is not true, and it warns me of this beforehand as it is nonpolynomial
__________________
trogdor458 is offline   Reply With Quote
Old 04-06-2007, 06:22 AM   #19
Q__Hybrid
Qwaizang:syntax_entity_
 
Q__Hybrid's Avatar
 
Join Date: Aug 2005
Posts: 270
What you're trying to do sounds rather easy, you just need to do a few things to make it all come together. Here's just one possibility:

Scale down a duplicate of your travelling bitmap when it is first being loaded. Use a routine to check for opaque pixels or pixels of a certain range of color to determine the irregular shape within the image, then store the results as an array of points (do this only once, at load time.) Scale the coordinates of these points back up to normal resolution and transform them along with the image each frame.

Finally, draw line segments between the current location of each point and the next expected location of each point. Use the same principle to create line segments in collidable surfaces, etc. If any of the projected lines of travel intersect with a surface line segment, objects have collided.

Does that make any sense?
__________________
Qwai•zang \kwî-'zan\ n [origin unknown] 1 : abstract designer, esp. of complex real-time experiments, c. 21st century
Q__Hybrid is offline   Reply With Quote
Old 04-06-2007, 02:52 PM   #20
trogdor458
Please, Call Me Bob
 
trogdor458's Avatar
 
Join Date: Aug 2006
Location: Pensacola, FL
Posts: 875
yes, and ive actually thought of this before, but due to the overall complexity, you cant optimize it all that well

the point of this thread was actually to do amazingly accurate hitTests without plugging in every possible outcome

when i get around to it (i still haven't yet?), im going to set up a and solve a very complex equation

may be harder for me to do, but should mean that the collisions will calculate faster
__________________
trogdor458 is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > General Help > Games

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:16 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.