3D Shockwave Collision

Hi guys,
I have a small problem, i need to add collision to some road
barriers in a driving game i am making, but i have looked on the
net for some tutorials or info about it, and i can't find anything!
I'm finding it pretty difficult as i may need to use x,y AND
z axis for the collision, so does anyone know of any good sources
for some 3D collision detection methods or ideas on what lingo i
could use for my game?
thanks in advance
Sam

collision detection is something that is really often
dicussed, you find a lot of information on this topic if you search
this forum:
this
forum about collision detection
there are different ways you can go:
1. modelsunderray
2. collision modifier
3. havok
4. imaging lingo (2D collision detection based on the color
values of a image)
the last method is not used very often, but here is an
example that shows it in action:
http://www.hoverster.net/
(click on the green "Start" link to start the game)
best regards!

Similar Messages

  • Events Triggered By Collision Detection In Shockwave 3D Environment Happen More Than Once?

    Okay, I've finally managed to get my Director 3D game to move an object to a new random position when collision detection occurs with that object! HOWEVER, sometimes it will work as expected and other times the object seems to move SEVERAL times before settling. Anyone have any idea why it isn't always just moving once and settling as I'd hoped it would...?
    To see an example of the problem I'm facing, create a new Director movie then insert a new Shockwave 3D media element into that Director movie named "Scene" and apply the below code to that 3D media element. I've tried to trim the code down as much as possible to get right to the heart of the problem:
    =====
    property Scene  -- reference to 3D cast member
    property pSprite    -- referebce to the 3D sprite
    property pCharacter -- reference to the yellow in the 3D world
    property pTransformgreen01Flag -- reference to the flag which will trigger action to move green01 + increase score on collision
    property pTransformgreen02Flag -- reference to the flag which will trigger action to move green02 + increase score on collision
    on beginSprite me
      -- initiate properties and 3D world
      pSprite = sprite(me.spriteNum)
      Global Scene
      Scene = sprite(me.spriteNum).member
      Scene.resetWorld()
      Tempobjres = Scene.newmodelresource("sphereRES", #sphere)  --create sphere modelresource
      Tempobjres.radius = 10     --set sphere modelresrource radius to 20
      Tempobjres.resolution = 17   --set the sphere modelresource resolution to 17
      Tempobj = scene.newmodel("yellow", tempobjres)   --create a model from the sphere modelresource
      Tempshader = scene.newshader("sphereshd", #standard)   --create a new standard shader
      Tempshader.diffuse = rgb(250,250,10)   --set the diffuse color (in this case, a light green)
      Tempshader.texture = void   --set the texture of the shader to void
      Tempobj.transform.position=vector(0,0,0)
      Tempobj.shaderlist = tempshader   -- assign the shader to the model
      Tempobjres1 = Scene.newmodelresource("sphereRES1", #sphere)  --create sphere modelresource
      Tempobjres1.radius = 10     --set sphere modelresrource radius to 20
      Tempobjres1.resolution = 17   --set the sphere modelresource resolution to 17
      Tempobj1 = scene.newmodel("green01", tempobjres1)   --create a model from the sphere modelresource
      Tempshader1 = scene.newshader("sphereshd1", #standard)   --create a new standard shader
      Tempshader1.diffuse = rgb(100,200,50)   --set the diffuse color (in this case, a light green)
      Tempshader1.texture = void   --set the texture of the shader to void
      Tempobj1.transform.position = vector(25,25,0)
      Tempobj1.shaderlist = tempshader1   -- assign the shader to the model
      Tempobjres2 = Scene.newmodelresource("sphereRES2", #sphere)  --create sphere modelresource
      Tempobjres2.radius = 10     --set sphere modelresrource radius to 20
      Tempobjres2.resolution = 17   --set the sphere modelresource resolution to 17
      Tempobj2 = scene.newmodel("green02", tempobjres2)   --create a model from the sphere modelresource
      Tempshader2 = scene.newshader("sphereshd2", #standard)   --create a new standard shader
      Tempshader2.diffuse = rgb(100,200,50)   --set the diffuse color (in this case, a light green)
      Tempshader2.texture = void   --set the texture of the shader to void
      Tempobj2.transform.position = vector(-25,-25,0)
      Tempobj2.shaderlist = tempshader2   -- assign the shader to the model
      --the following lines will add collision detection for all three on-screen 3D objects
      Tempobj.addModifier(#collision)
      Tempobj.collision.enabled=true
      Tempobj1.addModifier(#collision)
      Tempobj1.collision.enabled=true
      Tempobj2.addModifier(#collision)
      Tempobj2.collision.enabled=true
      Tempobj.collision.resolve=true
      Tempobj1.collision.resolve=true
      Tempobj2.collision.resolve=true
      --the following lines will tell Director what to do with a specific object when it collides with another
      Tempobj.collision.setCollisionCallBack(#beepsound, me)
      Tempobj1.collision.setCollisionCallBack(#hitgreen01, me)
      Tempobj2.collision.setCollisionCallBack(#hitgreen02, me)
      pCharacter = Scene.model("yellow")
      -- we must define pCharacter after we use the resetWorld() command
      -- otherwise this variable object will be deleted
      createCollisionDetect
      pTransformgreen01Flag = false
      pTransformgreen02Flag = false
    end
    on createCollisionDetect
      Global Scene
      -- add collision modifier to the character
      pCharacter.addmodifier(#collision)
      -- set bounding geometry for collision detection to bounding box of model
      pCharacter.collision.mode = #mesh
      -- resolve collision for character
      pCharacter.collision.resolve = TRUE
    end
    on keyDown
      Global Scene
      case(chartonum(the keypressed)) of
        30: --up arrow
          scene.model("yellow").translate(0,5,0)
        31: --down arrow
          scene.model("yellow").translate(0,-5,0)
        28: --left arrow
          scene.model("yellow").translate(-5,0,0)
        29: --right arrow
          scene.model("yellow").translate(5,0,0)
      end case
    end
    --when "yellow" (player character) hits another object, this will happen:
    on beepsound me, colData
      beep --plays sound
    end
    --when "green01" is hit by another object, this will happen:
    on hitgreen01 me, colData
      Global Scene
      pTransformgreen01Flag=true
    end
    --when "green02" is hit by another object, this will happen:
    on hitgreen02 me, colData
      Global Scene
      pTransformgreen02Flag=true 
    end
    on enterFrame me
      Global Scene
      if pTransformgreen01Flag then
        --the following lines will generate new random x and y co-ordinates for green01
        randomx=random(-110,110)
        green01x=randomx
        randomy=random(-90,90)
        green01y=randomy
        Scene = member("Scene")
        Scene.model("green01").transform.position = vector(green01x,green01y,0)
        pTransformgreen01Flag = false
      end if
      if pTransformgreen02Flag then
        --the following lines will generate new random x and y co-ordinates for green02
        randomx=random(-110,110)
        green02x=randomx
        randomy=random(-90,90)
        green02y=randomy
        Scene = member("Scene")
        Scene.model("green02").transform.position = vector(green02x,green02y,0)
        pTransformgreen02Flag = false
      end if
    end
    =====
    I imagine the part that's causing the issue is the "on enterFrame me" part at the end, but can't see any reason why it wouldn't just perform the desired action ONCE every time...?
    This is really confusing the hell out of me and is pretty much the final hurdle before I can call my game "finished" so any and all assistance would be GREATLY appreciated!

    You can get yourself a used copy of my book http://www.amazon.com/Director-Shockwave-Studio-Developers-Guide/dp/0072132655/ for $0.82 + shipping.  Chapter 14 contains 33 pages which deal specifically with the vagaries of the collision modifier.
    You can download just the chapter on Collision Detection from http://nonlinear.openspark.com/book/Collisions.zip.  This includes the demo movies and the unedited draft of the text for the chapter.
    Perhaps you will find this useful.

  • Trying to get collision detection working with havok

    Hi - I'm having some trouble using collision detection within
    director using a w3d file with havok applied to it. I've been using
    the registerinterest function but I get a "value out of range"
    error.
    This is my code (there is a cone and box on a plane imported
    from 3d max - named Cone01 and Box01 these are both movable rigid
    bodies).
    on beginSprite me
    box1=member("3d").model("Box01")
    cone1=member("3d").model("Cone01")
    w = member ( 1 )
    hk = member( 2 )
    hk.initialize( w, 0.1, 1 )
    hk.registerInterest (box1, cone1, 10, 0, #collision, me)
    end
    on collision me, details
    sound(2).play(member("hihats"))
    end
    on enterFrame me
    end
    I've also tried this and had no luck:
    on beginSprite me
    rb1 = sprite(1).pHavok.rigidBody("Box01")
    rb2 = sprite(1).pHavok.rigidBody("Cone01")
    w = member ( 1 )
    hk = member( 2 )
    hk.initialize( w, 0.1, 1 )
    hk.registerInterest (rb1, rb2, 10, 0, #collision, me)
    end
    Any help would be great.
    Thanks

    quote:
    Originally posted by:
    josiewales
    Hi - I'm having some trouble using collision detection within
    director using a w3d file with havok applied to it.
    Just study this example:
    http://necromanthus.com/Games/ShockWave/tutorials/FPS_Havok.html
    cheers

  • Shockwave runs too fast!

    Hello,
    Years ago at Ben & Jerry's I built a Shockwave game to support Phish Food ice cream. Computers run so much faster now that the game is unplayable. Is there a way to slow down the plug-in so the game responds more like it did in 1995?
    You can see the game here: http://dryfoos.com/phish.html
    Note that as soon as you try to move the Ice Cream Man, the collision sound plays. this means that the chocolate fish sprites have collided with the character - but they have come across the screen so fast that you do not even see them. Also, the sound loop plays one or twice and stops - I suspect that is related to the clock speed as well.
    Thank you!
    -Rik Dryfoos

    Hi,
    If you have the original .DIR file that was used to make the Shockwave, then you are in business. If not, then not so easy.
    Rod

  • BSOD in Shockwave 3D

    http://i266.photobucket.com/albums/ii249/RomeoMarian/BSOD_Hopeless.jpg
    lol

    You can get yourself a used copy of my book http://www.amazon.com/Director-Shockwave-Studio-Developers-Guide/dp/0072132655/ for $0.82 + shipping.  Chapter 14 contains 33 pages which deal specifically with the vagaries of the collision modifier.
    You can download just the chapter on Collision Detection from http://nonlinear.openspark.com/book/Collisions.zip.  This includes the demo movies and the unedited draft of the text for the chapter.
    Perhaps you will find this useful.

  • Adobe Flash/Shockwave Problems

    for some reason Adobe Flash is Crashing Every day for the last 2 weeks with Firefox i'v reinstalled it and it didn't help one bit and not sure whats going on. my system is a Win 8 (64bit) Firefox version is 25.0

    Download the following files (Right click and "Save Link as"):
    Flash Player Plug-in (All other browsers)
    Shockwave Player Uninstaller
    Flash Player Uninstaller
    Shockwave Player 12 FULL Installer
    Reboot.
    Run the Uninstallers from your Downloads folder, to remove BOTH Flash Player and Shockwave.
    Go to: C/Windows/System32 and delete the Macromed folder.
    Go to: C/Windows/SysWOW64 and delete the Macromed folder.
    Open your Windows Registry Editor (Start>Run or press the Windows key+r. Tpye "regedit" [minus the quotes] and click OK.
    In the Registry Editor, go to: HKEY_LOCAL_MACHINE/SOFTWARE and delete the Macromedia folder.
    Go to: HKEY_CURRENT_USER/Software and delete the Macromedia folder.
    Close the Registry Editor and empty your Recycle bin.
    Run the Shockwave FULL Installer first, and THEN the Flash Player Installer. These are offline installers and will require no connection during the process.
    If problems persist, try disbaling other plugins and extensions for Firefox, to determine if one or more is conflicting with Flash and Shockwave.

  • How do I fix the "shockwave flash" error, causing firefox to lock up, slow, or crash?

    continous errors about "shockwave flash", "script has stopped working" etc, causing numerous slowdowns, lock-ups, and crashes. have tried several fixes, but none have worked.....please advise

    Is it a permissions problem? Here's another way.
    (1) In a My Computer or Windows Explorer window, open this folder:
    C:\Windows\SysWOW64\Macromed\Flash
    If that folder does not exist, then you are using 32-bit Windows, and you can open the following folder instead:
    C:\Windows\System32\Macromed\Flash
    ''(Note: This folder exists on both 32-bit and 64-bit Windows, but on 64-bit Windows Firefox uses the Flash player in the SysWOW64 folder instead.)''
    (2) Check for a file named mms.cfg:
    (A) ''If mms.cfg exists,'' drag it to your '''Documents folder''' where you can edit it without being bothered about administrator privileges
    (B) ''If mms.cfg does not exist,'' open your '''Documents folder''', right-click > New > Text File and name the new file mms.cfg
    (3) Open mms.cfg from Documents into a text editor such as Notepad. Add this on its own line (I put it last):
    ProtectedMode=0
    Save the file and close Notepad.
    (4) Hold down the Ctrl key and drag the mms.cfg file back to the Flash folder to make a copy there, keeping the original in Documents
    This change should take effect the next time you restart Firefox.
    Hopefully that works around the permission issue.

  • Firefox Plugins lists Shockwave Flash 12.0.0.70 but Adobe lists this as Adobe Flash Player, and Version 12.0.9.149 as Adobe Shockwave Player, so wtf is going on

    Flash causes us all immense confusion, and Firefox is adding to the problem.
    My Firefox Add-ons page lists (under Plugins -- isn't there a difference?) that I have:
    Shockwave Flash 12.0.0.70 which is set to "Always Activate".
    Adobe websites list:
    Adobe Flash Player 12.0.0.70
    Adobe Shockwave Player 12.0.9.149
    -- so what on earth is the Firefox-listed "Shockwave Flash"?
    This simply adds to the utter confusion already surrounding Flash Player -- which I cannot find anywhere amongst my Programs -- but which I can find under "Uninstall or change a Program" where it is listed as "Adobe Flash Player 12 Plugin".
    There is also the thorny issue of FlashPlayer vs. FlashPlayerDownloader......
    I need a flash of inspiration to get me out of shock -- I'm not waving, I'm drowning!

    In the internals of the plugin it is still referenced as Shockwave Flash. That hasn't changed as it would break websites that check for a specific plugin name. You can see that on the about:plugins page and in the properties of the Flash plugins file.
    You can open the Web Console (Firefox/Tools > Web Developer) and paste this JavaScript code in the command line to see how the Adobe Flash Player plugin identifies itself:
    <pre><nowiki>console.log(navigator.plugins["Shockwave Flash"].name);
    console.log(navigator.plugins["Shockwave Flash"].description);
    </nowiki></pre>
    *https://developer.mozilla.org/Tools/Web_Console
    On disk you will also see Macromedia for folder names used by the plugin.
    *32 bit Windows: C:\Windows\System32\Macromed\Flash\
    *64 bit Windows: C:\Windows\SysWOW64\Macromed\Flash\
    * C:\Users\&lt;user&gt;\AppData\Roaming\Macromedia\Flash Player\

  • Collisions (Separating Axis Theorem)

    Hi,
    I'm working on a 2D game, it's top-down like GTA2, but I'm havinfgproblems with the collision detector. I know there are a lot of posts about collision already but they didn't help me much. I'm using the separating axis theorem (explained here: http://www.harveycartel.org/metanet/tutorials/tutorialA.html#section1) and most of the code is inspired by http://www.codeproject.com/cs/media/PolygonCollision.asp .
    Separating axis theorem:
    find all axis perpendicular to all the edges of both objects,
    project both objects on the axis,
    if there is an axis where the projections do not overlap, then the objects do not overlap.
    The problem is that I think my code should work. And guess what, it doesn't. I checked the code 30 times this weekend but maybe there is some tiny mistake I overlook each time..
    When I run the program with 6 objects I get this:
    1 2 3 4 5 6
    1: - 0 0 0 0 0
    2: 0 - 1 0 0 0
    3: 0 1 - 0 0 0
    4: 0 0 0 - 0 0
    5: 0 0 0 0 - 0
    6: 0 0 0 0 0 - (1=intersect, 0=doesn't intersect)
    but this is completely wrong. You can run the program yourself to see the exact locations of the objects.
    1 is the triangle at the top,
    2 and 3 are the triangles who share an edge
    4 is the one on the left intersecting with 3
    5 is the triangle on the right
    6 is the parallelogram
    But it really gets weird when I add a 7th object (the one in the comments):
    1 2 3 4 5 6 7
    1: - 0 0 0 0 0 0
    2: 0 - 0 0 0 0 0
    3: 0 0 - 0 0 0 0
    4: 0 0 0 - 0 0 0
    5: 0 0 0 0 - 0 0
    6: 0 0 0 0 0 - 0
    7: 0 0 0 0 0 0 -
    Now 2 and 3 don't intersect anymore! They didn't change I just added another object.
    I'm adding a short explanationof all the classes and the code itself. I know it's a lot of code but I added all the test classes so you can just run Test.Test
    I hope someone can help me with this.
    Thanks,
    El Bandano
    _<h5>package CollisionDetector:</h5>_
    <h6>CollisionDetector</h6>
    The class that is supposed to check for collisions. It will take 2 Props and return a CollisionResult
    <h6>CollisionResult</h6>
    A small class with 2 public fields. For now only the boolean Intersect matters.
    <h6>Interval</h6>
    Another small class that represents an interval of floats. It's pretty simple. Distance should return something negative if 2 intervals overlap.
    _<h5>package World</h5>_
    <h6>MovableProp</h6>
    An interface of an object. All objects should be convex.
    <h6>Vector2D</h6>
    A 2D-vector. It has an x and a y value (floats) and some simple methods. a 2D vector can represent a point or an edge/axis. For a point the x and y are the coordinates. For an axis you need a normalized vector (x^2+y^2=1) and the x and y are coordinates on a parrallell line through (0,0).
    _<h5>package Test</h5>_
    <h6>Test</h6>
    The main class. It makes some objects, prints a matrix showin which intersect eachother and shows a window with all objects.
    <h6>TestMovProp</h6>
    A basic implementation of MovableProp.
    <h6>TestPanel</h6>
    A panel that draws MovableProp.
    _<h5>package CollisionDetector:</h5>_
    <h6>CollisionDetector</h6>
    package CollsisionDetector;
    import World.MovableProp;
    import World.Vector2D;
    import java.util.ArrayList;
    public class CollisionDetector {
        public CollisionDetector(){
        public CollisionResult DetectCollision(MovableProp propA, MovableProp propB) {
            CollisionResult result = new CollisionResult();
            result.Intersect = true;
            result.WillIntersect = true;
            Vector2D[] edges = UniqueEdges(propA, propB);
            // loop through the edges
            // find an axis perpendicular to the edge
            // project the props on the axis
            // check wether they intersect on that axis
            for (Vector2D edge: edges){
                Vector2D axis = edge.getPerpendicular();
                Interval intA = projectPointsOnAxis(propA.getCoordinates(), axis);
                Interval intB = projectPointsOnAxis(propB.getCoordinates(), axis);
                if (intA.distance(intB) > 0)
                    result.Intersect = false;
            return result;
        public Interval projectPointsOnAxis(Vector2D[] points, Vector2D axis){
            Interval i = new Interval();
            for (Vector2D p: points)
                i.add(projectPointOnAxis(p, axis));
            return i;
        public float projectPointOnAxis(Vector2D point, Vector2D axis){
            // axis <-> y=a*x
            float a  = axis.y / axis.x;
            // line <-> y=(-a/1)*x+b
            float a2 = -axis.x / axis.y;
            // b = y-a2*x
            float b = point.y - a2*point.x;
            // y = a *x
            // y = a2*x + b
            // => a*x = a2*x + b
            float x = b/(a-a2);
            float y = a*x;
            // is there a better way to do this?
            return new Float(Math.sqrt(x*x + y*y)).floatValue();
         * Put all edges in 1 array, eliminate doubles (parallels).
        public Vector2D[] UniqueEdges(MovableProp propA,MovableProp propB){
            Vector2D[] aEdges = propA.getEdges();
            Vector2D[] bEdges = propB.getEdges();
            ArrayList<Vector2D> tmp = new ArrayList<Vector2D>();
            for (Vector2D v: aEdges){
                tmp.add(v);
            for (Vector2D v: bEdges){
               if (! tmp.contains(v))
                    tmp.add(v);
            return tmp.toArray(new Vector2D[tmp.size()]);
    }<h6>CollisionResult</h6>
    package CollsisionDetector;
    import World.Vector2D;
    public class CollisionResult {
        public boolean WillIntersect;
        public boolean Intersect;
        public Vector2D MinimumTranslationVector;
        public CollisionResult() {
    }<h6>Interval</h6>
    package CollsisionDetector;
    public class Interval {
        public float min;
        public float max;
        public Interval() {
            min = Float.MAX_VALUE;
            max = Float.MIN_VALUE;
        public void add(float f){
            // no 'else'! In an empty interval both will be true
            if (f>max)
                max = f;
            if (f<min)
                min = f;
        public float distance(Interval interval){
            if (this.min < interval.min) {
                return interval.min - this.min;
            } else {
                return this.min - interval.min;
    }_<h5>package World</h5>_
    <h6>MovableProp</h6>
    package World;
    public interface MovableProp {
        public int getNPoints();
        public Vector2D[] getEdges();
        public Vector2D[] getCoordinates();
    }<h6>Vector2D</h6>
    package World;
    public class Vector2D {
        public float x;
        public float y;
        public Vector2D(float x, float y) {
            this.x = x;
            this.y = y;
        public boolean equals(Object obj){
            if (!(obj instanceof Vector2D)){
                return false;
            }else
                return (this.x == ((Vector2D)obj).x && this.y == ((Vector2D)obj).y);
        public String toString() {
            return ("Vector2D  x=" + x + " ,  y=" + y);
        public void normalize(){
            if (x*x + y*y != 1){
                float x2 = x;
                x /= Math.sqrt(x2*x2+y*y);
                y /= Math.sqrt(x2*x2+y*y);
        public Vector2D getPerpendicular(){
            Vector2D per = new Vector2D(-y,x);
            per.normalize();
            return per;
    }_<h5>package Test</h5>_
    <h6>Test</h6>
    package Test;
    import CollsisionDetector.CollisionDetector;
    import World.MovableProp;
    import java.awt.Polygon;
    import java.util.ArrayList;
    import java.util.Vector;
    import javax.swing.JFrame;
    public class Test {
        public static void main(String args[]) {
            CollisionDetector detect = new CollisionDetector();
            float[] x = new float[3];
            float[] y = new float[3];
            ArrayList<MovableProp> list = new ArrayList<MovableProp>();
            x[0] = 200; x[1] = 300; x[2] = 500;
            y[0] = 400; y[1] = 200; y[2] = 300;
            list.add(new TestMovProp(x,y));
            x[0] = 300; x[1] = 500; x[2] = 600;
            y[0] = 400; y[1] = 400; y[2] = 500;
            list.add(new TestMovProp(x,y));
            x[0] = 200; x[1] = 300; x[2] = 600;
            y[0] = 600; y[1] = 400; y[2] = 500;
            list.add(new TestMovProp(x,y));
            x[0] = 100; x[1] = 200; x[2] = 300;
            y[0] = 800; y[1] = 500; y[2] = 700;
            list.add(new TestMovProp(x,y));
            x[0] = 600; x[1] = 600; x[2] = 700;
            y[0] = 400; y[1] = 700; y[2] = 500;
            list.add(new TestMovProp(x,y));
    //        x[0] = 100; x[1] = 001; x[2] = 900;
    //        y[0] = 001; y[1] = 900; y[2] = 500;
    //        list.add(new TestMovProp(x,y));
            x = new float[4];
            y = new float[4];
            x[0] = 450; x[1] = 550; x[2] = 500; x[3] = 400;
            y[0] = 200; y[1] = 250; y[2] = 650; y[3] = 600;
            list.add(new TestMovProp(x,y));
            int n = list.size();
            boolean[][] matrix = new boolean[n][n];
            for (int i=0; i<n; i++){
                for (int j=0; j<n; j++){
                    if (i!=j)
                    matrix[i][j] = detect.DetectCollision(list.get(i),list.get(j)).Intersect;
            System.out.print("  ");
            for (int i=0; i<n; i++){
                System.out.print("  " + (i+1));
            for (int i=0; i<n; i++){
                System.out.print("\n" + (i+1) + ":  ");
                for (int j=0; j<n; j++){
                    if (i==j)
                        System.out.print("-  ");
                    else if (matrix[i][j])
                        System.out.print("1  ");
                    else
                        System.out.print("0  ");
            System.out.println();
            JFrame window = new JFrame();
            window.setDefaultCloseOperation(window.EXIT_ON_CLOSE);
            window.pack();
            window.setVisible(true);
            window.setContentPane( new TestPanel(list));
            window.pack();
    }<h6>TestMovProp</h6>
    package Test;
    import World.MovableProp;
    import World.Vector2D;
    public class TestMovProp implements MovableProp{
        float[] X;
        float[] Y;
        Vector2D[] coor;
        public TestMovProp(float[] x, float[] y) {
            X=x; Y=y;
            coor = new Vector2D[getNPoints()];
            for(int i=0; i< getNPoints(); i++){
                coor[i] = new Vector2D(X, Y[i]);
    public Vector2D[] getCoordinates(){
    return coor;
    public int getNPoints() {
    return X.length;
    public Vector2D[] getEdges() {
    int n = getNPoints();
    Vector2D[] v = new Vector2D[n];
    for (int i=0; i<n-1; i++){
    v[i] = new Vector2D(X[i]-X[i+1], Y[i]-Y[i+1]);
    v[i].normalize();
    v[n-1] = new Vector2D(X[0]-X[n-1], Y[0]-Y[n-1]);
    v[n-1].normalize();
    return v;
    public String toString() {
    String s = "\n";
    for (Vector2D v: getCoordinates())
    s += ("\n" + v);
    return s;
    <h6>TestPanel</h6>package Test;
    import World.MovableProp;
    import World.Vector2D;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Polygon;
    import java.util.ArrayList;
    import javax.swing.JPanel;
    public class TestPanel extends JPanel {
    public ArrayList<MovableProp> list;
    public TestPanel(ArrayList<MovableProp> list) {
    super();
    this.list = list;
    setPreferredSize(new Dimension(1000,850));
    public void paint(Graphics g) {
    super.paint(g);
    for (MovableProp prop:list){
    Vector2D[] coor = prop.getCoordinates();
    int n = prop.getNPoints();
    g.drawLine((int)coor[0].x, (int)coor[0].y, (int)coor[n-1].x, (int)coor[n-1].y);
    for (int i=0; i<n-1; i++){
    g.drawLine((int)coor[i].x, (int)coor[i].y, (int)coor[i+1].x, (int)coor[i+1].y);

    .java wrote:
    I have been search for what seems like hours, Nice try, but in less than 15 seconds I found a complete discussion on the subject.
    and I still have not managed to find anybody or anything that can clearly answer these three questions:
    1. What is SAT?
    2. How does it apply to 2D collision detection? (How would it be different with 3D collision detection?)
    3. How can this be implemented in Java using Shape objects?
    Note: I am easily confused by geometric terminology.This really looks like a question you should have an answer for in your notes from class, or in your book. If not perhaps you need to go ask your teacher what it is and explain why you don't have it in your notes or book.

  • Bouncing balls collision

    I am creating a program that has two balls which produce a sound when bouncing off the walls and each other. I am having trouble when they collide with each other, as my value for when they hit each other does not seem to be working. Here is my source code :
    import java.applet.Applet;
    import java.awt.Graphics;
    import java.awt.*;
    import java.applet.AudioClip;
    import java.awt.event. *;
    public class BallBouncing extends Applet implements Runnable {
            int x_pos = 20;
            int y_pos = 100;
            int x_speed = 1;
            int y_speed = 1;
            int x1_pos = 70;
            int y1_pos = 130;
            int x1_speed = 1;
            int y1_speed = 1;
            int appletsize_x = 300;
            int appletsize_y = 200;
            int radius = 20;
            int pos = (x_pos - x1_pos)*(x_pos - x1_pos) + (y_pos - y1_pos)*(y_pos - y1_pos);
            double pos1 = Math.sqrt(pos);       
            public AudioClip sound1, sound2;       
            Thread t;
            Button b1 = new Button("Reverse Direction");
            public void init() {
                b1.addActionListener(new B1());           
                add(b1);
            class B1 implements ActionListener {
            public void actionPerformed(ActionEvent e) {
            x_speed = +3;
            y_speed = -3;
            public void start() {
                            t = new Thread(this);
                            t.start();
            public void stop() {
            public void paint(Graphics g) {
                    g.setColor (Color.blue);
                    g.fillOval(x_pos - radius, y_pos - radius, 2 * radius, 2 * radius);
                    g.fillOval(x1_pos - radius, y1_pos - radius, 2 * radius, 2 * radius);
            public void run() {
                    sound1 = getAudioClip( getDocumentBase(), "Audio1.au" );
                    sound2 = getAudioClip( getDocumentBase(), "Audio2.au" );
                    while (true) {
                        try {
                            Thread.sleep(20);
                        } catch (InterruptedException e) {}
                        if (x_pos > appletsize_x - radius)
                            x_speed = -3;
                            sound2.play();
                        else if (x_pos < radius)
                            x_speed = +3;
                            sound2.play();
                        else if (y_pos > appletsize_y - radius)
                            y_speed = -3;
                            sound2.play();
                        else if (y_pos < radius)
                            y_speed = +3;
                            sound2.play();
                        else if (x1_pos > appletsize_x - radius)
                            x1_speed = -3;
                            sound2.play();
                        else if (x1_pos < radius)
                            x1_speed = +3;
                            sound2.play();
                        else if (y1_pos > appletsize_y - radius)
                            y1_speed = -3;
                            sound2.play();
                        else if (y1_pos < radius)
                            y1_speed = +3;
                            sound2.play();
                        else if (pos1 < 40)
                            x_speed = -3;
                            x1_speed = +3;
                            y_speed = -3;
                            y1_speed = +3;
                            sound1.play();
                            x_pos += x_speed;
                            y_pos += y_speed;
                            x1_pos += x1_speed;
                            y1_pos += y1_speed;
                            repaint();
    }Any help would be appreciated, thanks.

    Hi, here is a solution to your problem I hope. I have also included some extra features and brought your code up to a higher standard in terms of java conventions (however the {} on the next line is my convention, from C# :p).
    A few things:
    - For the balls deflecting at the proper angles then you will need to learn vector maths and I am afraid that my knowledge of that is rather sketchy (still 1st year uni student, more on that next year :p)
    - I used Graphics2D purely because I was lazy so I could write g2.draw(bounds); instead of using g.drawRect(x, y, height, width); - both methods give the same result
    - You will need to look up how to do drawing in applets to remove that flickering, I'm not sure if you do the same thing as normal swing/awt components (ie double buffering), as applets aren't my strong point.
    - I removed the button because it was unneccessary, it will take you 60 seconds to add it back in if you want.
    - You really REALLY should write a 'Ball' class and make some Ball objects instead of having separate variables for each ball. I will leave that up to you :)
    - I STRONGLY recommend the use of comments throughout any program you use, not because of convention but because it not only helps other developers to understand your code and what it does, but also to refresh your memory when you come back from a break and try to keep writing. (trust me, do not underestimate the power of comments!) . I have put a few in to show you what they should look like; they should be brief and concise, explain what a section of code does, and how it does it.
    - Enjoy!
    package sunforum_bounceball;
    import java.applet.*;
    import java.awt.*;
    public class BallBouncing extends Applet implements Runnable
         private static final long serialVersionUID = 1L;
         // ball 1
         private int x1_pos;
         private int y1_pos;
         private int x1_speed;
         private int y1_speed;
         private int b1_radius;
         // ball 2
         private int x2_pos;
         private int y2_pos;
         private int x2_speed;
         private int y2_speed;
         private int b2_radius;
         // other variables
         private Rectangle bounds;
         private Dimension appletSize;
         private boolean hasCollision;
         private boolean debugCollisionTesting;
         private AudioClip sound1, sound2;       
         private Thread t;
         public BallBouncing()
              // ball 1
              x1_pos = 100;
              y1_pos = 109;
              x1_speed = 2;
              y1_speed = 1;
              b1_radius = 40;
              // ball 2
              x2_pos = 100;
              y2_pos = 237;
              x2_speed = 1;
              y2_speed = 1;
              b2_radius = 20;
              hasCollision = false;
              // This is just for your help; turn this on to disable the balls changing direction when they collide.
              // This will enable you to check that when the balls are touching, we are detecting it.
              debugCollisionTesting = false;
              // Variables for the size of the applet and the bounding rectangle for the balls.
              appletSize = new Dimension(400, 400);
              bounds = new Rectangle(0, 0, 400, 400);
         public void start()
              t = new Thread(this);
              t.start();
         public void stop()
         public void paint(Graphics g)
              Graphics2D g2 = (Graphics2D)g;
              if (hasCollision)
              { g2.setColor(Color.RED); }
              else
              { g2.setColor(Color.BLUE); }
              g2.fillOval(x1_pos - b1_radius, y1_pos - b1_radius, 2 * b1_radius, 2 * b1_radius);
              g2.fillOval(x2_pos - b2_radius, y2_pos - b2_radius, 2 * b2_radius, 2 * b2_radius);
              g2.setColor(Color.BLACK);
              g2.draw(bounds);
         public void run()
              // +1 just so we can see the border of the collision area. Try taking out the +1's and see what happens.
              this.setSize(appletSize.width + 1, appletSize.height + 1);
              sound1 = getAudioClip( getDocumentBase(), "Audio1.au" );
              sound2 = getAudioClip( getDocumentBase(), "Audio2.au" );
              // Used to hold the distance between the balls.
              double p;
              while (true)
                   try
                   { Thread.sleep(20); }
                   catch (InterruptedException e)
                   // ball 1 x coordinate.
                   if (x1_pos > (bounds.x + bounds.width) - b1_radius || x1_pos < bounds.x + b1_radius)
                        x1_speed *= -1;
                        sound2.play();
                   // ball 1 y coordinate.
                   else if (y1_pos > (bounds.y + bounds.height) - b1_radius || y1_pos < bounds.y + b1_radius)
                        y1_speed *= -1;
                        sound2.play();
                   // ball 2 x coordinate.
                   if (x2_pos > (bounds.x + bounds.width) - b2_radius || x2_pos < bounds.x + b2_radius)
                        x2_speed *= -1;
                        sound2.play();
                   // ball 2 y coordinate.
                   else if (y2_pos > (bounds.y + bounds.height) - b2_radius || y2_pos < bounds.y + b2_radius)
                        y2_speed *= -1;
                        sound2.play();
                   // Checks the distance between the balls. If it is less than the sum of the radii, then they are colliding.
                   p = Math.sqrt(Math.pow((x1_pos - x2_pos), 2) + Math.pow((y1_pos - y2_pos), 2));
                   if (p < (b1_radius + b2_radius))
                        // To check there is a collision. Useful for debugging.
                        // System.out.println("Collision");
                        hasCollision = true;
                        // see declaration for details
                        if (!debugCollisionTesting)
                             x1_speed *= -1;
                             x2_speed *= -1;
                             y1_speed *= -1;
                             y2_speed *= -1;
                             sound1.play();
                   else
                   { hasCollision = false; }
                   // Move both balls.
                   x1_pos += x1_speed;
                   y1_pos += y1_speed;
                   x2_pos += x2_speed;
                   y2_pos += y2_speed;
                   // Repaint the scene
                   repaint();
    }Cheers
    Sutasman
    Edited by: Sutasman on Dec 6, 2009 1:17 AM

  • Time enry collisions and wage type issues

    Hi Experts,
    We do not have holiday's embedded in our schedules due to the flexibility in when employees are allowed to take the paid time off and also due to
    our "flex" work schedules being more than 8 hour work days but the holiday benefit is an 8 hour benefit.  This has caused us a lot of issues with
    time entry, however, we thought it had been corrected.  We are now running into the same issues.  Here is an example:
    First Issue:
    Work Schedule week of 12/31/07 - 01/05/08
                Sun   Mon   Tues  Wed   Thur  Fri   Sat
    Schedule    0     10    10    10    10    0     0
    Tuesday the 1st is a holiday and the employee must enter Absence type 240 for 10 hours to fit his schedule.  Employee also work on the holiday and
    needs to enter Attendance type 832 for unscheduled holiday work.  When we try to enter the attendance we receive a full day collision error and
    cannot continue.
    Second Issue:
    Work Schedule week of 12/31/07 - 01/05/08
                Sun   Mon   Tues  Wed   Thur  Fri   Sat
    Schedule    0     8     8     8     8     8     0
    Tuesday is the holiday and the employee enters Absence type 240 for 8 hours to fit her schedule.  She is also on Standy-By time for the holiday.  We
    had to configure standby time specifically as a wage type and activate the wage type column in the CATS entry screen.  She must enter W/T (it's the
    only option) 1802 and then record 24 hours in the date 01/01/08.  This entry also gives us a full day collision message and we cannot continue.
    We can provide more examples when a consultant is assigned.  These options used to work and we do not know why they are no longer working.
    Advice me to resolve this ticket on time, its high priority ticket.

    Hi,
    I think your 1st problem comes from the misunderstanding of SAP work schedule logic.
    As you mentioned, you want to input ab type 240 to fit work schedule. But it's not necessary.
    For that day is a WORK day with holiday class 1. That means scheduled work can be overwrited by holiday. If the employee does not come to work in that day without any 2001 informations, he/she is NOT absence,because that day is a paid time off.
    And as for the attendance type, it's also no needed. Because if employee came to work in a public holiday, the working hours will automatically counted as OT hours but UNAPPORVED! To approve this OT, you need input 2007 attendance quota. In this example, the employee got 10 hours OT in puplic holiday which is recorded by SAP TM but unapporved. Then you should create a 2007 record with 10 hours attendance quota in the same day. By doing this, the TM evaluation will count those 10 hours as paid OT.
    I think the way above is what you called "flexibility in when employees are allowed to take the paid time off "
    Hope helpful
    Br,Kee

  • Jabber and Shockwave

    I use Jabber, but since installing have had issues with Shockwave not responding.  Is this common, connected or just coincidence?
    Cheers
    Chris

    Hi Chris,
     I have Adobe Shockwave 12.1.6r156 and Jabber for Windows 10.5(4).
     Try to install and test each one separately.
     What versions do you have?

  • Old movie will not play in new shockwave player

    Hi, I have searched the forums, Adobe support and web in
    general for help on this, but to my surprise have not found
    anything. I created some Shockwave movies perhaps 5 years ago for
    science education and have not used Director since then. I just
    received a report that the movies are broken and will not play.
    This is happening on WinXP in IE and in Firefox with the latest
    Shockwave player installed, but the movies work fine on OSX 10.4.8
    in Safari and Firefox, also with the latest Shockwave player
    installed. I am not a Director developer anymore and do not own a
    current version of the program, I am primarily a scientist and
    educator. I'm hoping the problem is in the code that embeds the
    movie, and that the movies are still compatible with the new
    Shockwave player on Windows. Can anyone help out, please? One of
    the movies can be found at
    http://www.biochem.umass.edu/mydna/modules/sort.html

    p

  • Shockwave Player updates, gives 2 options, full or slim - nothing explains the difference How do I know what to use

    McAfee program searches for programs that are susceptible to malware and automatically searched for updates and installs them. For some Reason, when it comes to Adobe products it requires myself to have to perform a manual update.  
    When I followed the link McAfee provides to the Adobe website and follow the steps to install the update....at one point it give you and option of an update that as the word "Full" in the middle of the Update Choice, and the 2nd option is exactly the same except instead of the word "Full", it has the word "Slim".
    Nowhere (FAQs, etc) can I find the difference between the two, so how do I know which I need?
    I have a Dell Laptop with Windows 8.1 operating system.  
    8GB Ram  and I think its one of those Quad Drive things
    1 TB Memory
    I use Firefox as my internet operating system.  
    I started with Internet Explorer, but a problem existed that had something to do with that program not being loaded properly initially,
    I tried to Get Microsoft Help but they wanted $149 to fix it, So I abandoned use of Internet Explorer and loaded Fire Fox.
    I will note, I don't know if its germane or note,  Since switching to Fire Fox,   my system stalls quite frequently and I get a popup that says something about a Flash Program (maybe shockwave flash) and it states it is not responding.  It gives me the option to continue or cancel and a check box to not ask me again.   Though I select that check box I do get asked often.
    When this Popup occurs, I can't use any of the internet windows I have open or any of the internet window Tabs I have open.  It also seems to affect the one game I play (Spider) and it stalls that game also.  I sense it has something to do with anything that has pictures on it possibly.  After several minutes 3 to 5 plus it seems to recover
    I'm sorry I am not real computer literate
    Thank you for any help you can provide
    Keith
    PS  All I am trying to do is get hold of Adobe to ask about their program, why I have to do all this registering and go into a Forum or Community (whatever those are) is confusing to me.

    The Full version includes all xtras and the Slim version just the bare essentials. I would recommend using the full version as your experience of using the plugin will be more seamless (no pausing while required xtras are downloaded on demand)

  • Shockwave and Flash Player installed works fine but it says damaged in the dependency tab.

    I have Windows Vista Home Premium 32 bit. When I go to
    downloaded programs in windows where your active x programs are.
    The icons on the leftt of shockwave player are white. I right click
    on the shockwave player and click on properties and in the
    dependency tab has nothing in the file name. Over to the right size
    bites says damaged. On the download programs itself where the
    shockwave player is the status says installed and the bite size
    says 4 KB it did not it did not say damage only in the dependency
    tab. My shockwave programs and games work fine. On the dependency
    it has this message,This page lists the 1 file (s) amd 0 java
    packages upon which shockwave active x controls depends on. I tried
    uninstalling and reinstalling about 5 times and the samething came
    up. If it has to run on the main package java the samething is
    there too. There too it is installed and the bites are okay the
    only place it says damage is in the dependency tab. I unstalled
    that and reinstalled it the same number of times and the samething
    appeared. Flash player the same way. How do I fix this problem? In
    dowloaded programs I also have another shockwave active x control
    with the same version and 2 java of the same version. Also after I
    uninstall shockwave player I go to manage add ons and delete the
    one that is still there and in the downloaded programs it has
    unknown with a bunch of letters. There is no way to delete that
    when you right click it you only see properties.

    Try clearing the Cache in Firefox.
    Tools-> Clear Recent History -> [v] Cache
    or
    Tools->Options->Advanced->Network -> Offline storage -> [Clear Now]
    Youtube may have made some changes recently. Clear the Youtube cookie and refresh page if above does not do it.

Maybe you are looking for

  • SQL Developer - Data Modeler

    The Data Modeler is a great Tool within SQL Developer. Will there be a possibility to work with it, without installing Subversion extension in the next Version of SQL Developer?

  • Anyone know why my computer would shutdown on it's own?

    So far it this has happened three times now. My computer for no apparent (at least not apparent to me) has shutdown on it's own. After the second time it happened, I took the tower into the Apple store and the mac genius at the genius bar suggested t

  • Is there a 2014 version of PS Bridge?

    I have installed the trial version of PS CC 2014 but I do not see a 2014 version of PS Bridge. So if I am to use the CC 2014, I still cannot delete the earlier versions of CC & Bridge (well, at least not Bridge, right)? Thanks.

  • Upgrading to a new iMac

    I am upgrading from an older MacPro to a new i7 iMac. What is the best way to get all my files and programs to the new iMac - Time Machine or using the old MacPro in Target mode?

  • Two Items Displayed For Single Task In Inbox

    Employees are entering time and there managers are getting the tasks in the UWL inbox, but there are always two items for each one.  When the manager approves one of the items the other one disappears.  What can cause this? Thanks, Redding