亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? race_canvas3d.java

?? 這是一個Micro3D的學習代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
        // for now, simply set speed to 0
        carSpeedValue = 0;
        UpdateSpeedVect();
      }
    }
    catch (Exception e) {
      System.out.println("moveObjects(): update road err: "+e);
    }
  }

  private void UpdateSpeedVect()
  {
    // car is rotating around Z axis, so move in local car coordinated
    // has to be transformed into move in world coordinates.
    // take negative Y positions
    float x = 0, y = 0;
    float v = (float)KDegreeFactor*(float)(myCar.getSpinAngleY());
    int angle = (int)v;
    x = carSpeedValue*sinTab[angle];
    y = (-carSpeedValue)*cosTab[angle];
    carSpeedVect.x = (int)x;
    carSpeedVect.y = (int)y;
  }

  private Vector3D triPos = new Vector3D(0,0,0);
  // sets which direction (on the road) car is moving - wheather it moves 
  // forward (growing map index) or it moves back (goes back to 0 in map table)
  // function makes sence as long as car is going on a road.
  private void updateCarMoveDirection(boolean aUpdateSpeed)
  {
    if(aUpdateSpeed)
      UpdateSpeedVect();
    if( !mIsMulti && carSpeedValue == 0 )
      return;

    myCar.getLocation(aCarPosVect);
    int dotProd;
    road.getRoadVect(triPos, aCarPosVect);
    dotProd = triPos.innerProduct(carSpeedVect);
    // dotProd = 0, the angle between road is 90 or 180 degrees;
    // for 90 degrees it might be sometimes better to use it as forward
    if(dotProd > 0)
      carMoveForward = true;
    else
      carMoveForward = false;

    if( mIsMulti && aUpdateSpeed )
    {
      app.updateCarRemoteSpeedAndPos(aCarPosVect,
                                     myCar.getSpinAngleY(),
                                     carSpeedVect);
      mAvatarUpdateStep = 0;
    }
  }

  // iterates through all road unit's elements to find if there is collision
  boolean isCarCollidesWithRoadSides()
  {
    int carPosX = myCar.getPosX();
    int carPosY = myCar.getPosY();

    RoadUnit unit;
    for( int i=0; i<road.getRoadCount(); ++i )
    {
      unit = road.getUnit(i);
      if( carDidSideColision(carPosX, carPosY, unit) ) {
        unit = null;
        return true;
      }
    }
    unit = null;
    return false;
  }

  // check if there is collision between car and particular road unit
  Vector3D mCarBefore = new Vector3D(0,0,0);
  Vector3D mCarAfter  = new Vector3D(0,0,0);
  int mDistBefore, mDistAfter;
  private boolean carDidSideColision(int aCarX, int aCarY, RoadUnit aUnit)
  {
    // get vectors from one points belonging to the wall to the car position
    // at the current moment
    mCarBefore.set(aUnit.pointB.x - aCarX, aUnit.pointB.y - aCarY, 0);
    // after moving with move vector
    mCarAfter.set( aUnit.pointB.x - (aCarX + carSpeedVect.x),
                  aUnit.pointB.y - (aCarY + carSpeedVect.y), 0);
    // get dot product of these vectors with wall normal vector
    mDistBefore = mCarBefore.innerProduct(aUnit.sideNorm);
    mDistAfter = mCarAfter.innerProduct(aUnit.sideNorm);
    // if sign is different -> vectors are on the other sides of wall (or on if 0)
    if( mDistBefore >= 0 && mDistAfter <= 0 ||
        mDistBefore <= 0 && mDistAfter >= 0 ) 
    {
      // check if car goes in opposite direction to unit direction vector
      // scalar product between vectors is > 0, angle is: -90<angle<90 degrees
      if( carSpeedVect.innerProduct(aUnit.sideNorm) > 0 )
        return false;
      // scale variables (normal vector uses 1 as 4096)
      int carSpeedX_s = carSpeedVect.x*4096;
      int carSpeedY_s = carSpeedVect.y*4096;

      // get reversed vector to what the car wants be moved this turn
      Vector3D moveVect_s = new Vector3D(-carSpeedX_s, -carSpeedY_s, 0);
      int divisor_s = moveVect_s.innerProduct(aUnit.sideNorm);
      // if move is paraller to wall plane -> no possible colision
      if( divisor_s == 0 )
        return false;

      // calculate the collision point, scale some variables first
      int carX_s = aCarX*4096;
      int carY_s = aCarY*4096;
      // calculate vector from colision point to car position point
      Vector3D distVect_s = new Vector3D(carX_s - aUnit.pointE.x*4096,
                                         carY_s - aUnit.pointE.y*4096, 0);
      // calculate fracture of speed vector that car moves to collision with wall
      float speedPart = (float)distVect_s.innerProduct(aUnit.sideNorm) /
                        (float)divisor_s;
      // collision point: car position point moved with calculated part of speed vector
      Vector3D colPoint = new Vector3D((carX_s+(int)(speedPart*carSpeedX_s))/4096,
                                       (carY_s+(int)(speedPart*carSpeedY_s))/4096,
                                       0);

      // check if collision point is placed inside wall's borders
      if( isCollisionInsideWall(colPoint, aUnit.pointB, aUnit.pointE) )
      {
        doCarColisionResponce(aUnit.side.getSpinAngleZ());
        colPoint = null;
        return true;
      }
      else {
        colPoint = null;
        return false;
      }
    }
    return false;
  }

  // does responce to car's collision with road unit
  private void doCarColisionResponce(int aWallAng)
  {
    // As a responce to car colision, car gets rotated and speed is decreased.
    // Angle is taken from relation between orientation of wall and car movement.
    int carAng = myCar.getSpinAngleY() - 2048;
    if(carAng == -2048)
      carAng = 2048;
    int wallAng = -(aWallAng - 1024);
    int diff = carAng + wallAng;
    if( diff < -4096 )
      diff = wallAng - carAng;
    if( diff < -1024 && diff < 0 )
      diff = 2048 + diff;
    if(diff > 2048)
      diff = carAng - wallAng;
    if( diff > 1024 )
      diff = diff - 1024;
    // Bounce of the wall.
    // I set bounce angle with part of the angle car hit the wall, 
    // just so it is not an "ideal - (2*diff)" colision and "some energy get's lost".
    // This could depend on the speed (i.e. the faster car goes, the more energy
    // gets lost on bang - car gets damaged)
    myCar.rotate(0, -(diff+diff/4), 0);
    // decrease speed value
    carSpeedValue = (carSpeedValue / 4);
    // update speed vector and car move direction with smaller speed value
    updateCarMoveDirection(true);
  }

  // check if collision point (car-road unit) is inside road unit's borders
  private boolean isCollisionInsideWall(Vector3D aTested, Vector3D aPointOne, Vector3D aPointTwo)
  {
      if( aPointOne.x > aPointTwo.x ) {
        if( aPointTwo.x <= aTested.x && aTested.x <= aPointOne.x) {
          if( aPointOne.y > aPointTwo.y ) {
            if( aPointTwo.y <= aTested.y && aTested.y <= aPointOne.y) {
              return true;
            }
            else
              return false;
          }
          else {
            if( aPointOne.y <= aTested.y && aTested.y <= aPointTwo.y) {
              return true;
            }
            else
              return false;
          }
        }
      }
      else {
        if( aPointOne.x <= aTested.x && aTested.x <= aPointTwo.x) {
          if( aPointOne.y > aPointTwo.y ) {
            if( aPointTwo.y <= aTested.y && aTested.y <= aPointOne.y) {
              return true;
            }
            else
              return false;
          }
          else {
            if( aPointOne.y <= aTested.y && aTested.y <= aPointTwo.y ) {
              return true;
            }
            else
              return false;
          }
        }
      }
    return false;
  }

  public void updateAvatar( int aPosX, int aPosY, int aRY, int aVx, int aVy )
  {
    awatarCar.setPositionAndAngle(aPosX, aPosY, aRY);
    awatarSpeedVect.x = aVx;
    awatarSpeedVect.y = aVy;
    // assume awatar moved once while message was sent/received
    awatarCar.move(aVx, aVy);
  }

  private void moveAvatar()
  {
    awatarCar.move(awatarSpeedVect.x, awatarSpeedVect.y);
    // update car's direction periodically, to prevent bad direction used
    ++mAvatarUpdateStep;
    if(mAvatarUpdateStep > 10) {
      myCar.getLocation(aCarPosVect);
      app.updateCarRemoteSpeedAndPos(aCarPosVect, myCar.getSpinAngleY(), carSpeedVect);
      mAvatarUpdateStep = 0;
    }
  }

  private boolean isCarCollisionWithAvatar()
  {
    if(carSpeedVect.x == 0 && awatarSpeedVect.x == 0 &&
       carSpeedVect.y == 0 && awatarSpeedVect.y == 0)
      return false;

    int distX, distY, distance;
    distX = (myCar.move.m03+carSpeedVect.x) - (awatarCar.move.m03+awatarSpeedVect.x);
    distY = (myCar.move.m13+carSpeedVect.y) - (awatarCar.move.m13+awatarSpeedVect.y);
    distance = distX*distX + distY*distY;
    // distance between cars is smaller than their combined radius: we have collision
    if (distance <= mCarTwiceRadSqare )
      return true;
    return false;
  }

  // when collision signal is received, this function handles it.
  public void updateOnColisionSignal(int aPosX, int aPosY, int aRY, int aVx, int aVy)
  {
    System.out.println("received signal, is in updateOnColisionSignal");

    // update out view on awatar's speed and position
    awatarCar.setPositionAndAngle(aPosX, aPosY, aRY);
    awatarSpeedVect.x = aVx;
    awatarSpeedVect.y = aVy;
    mAvatarUpdateStep = 0;

    // If moveObjects() function is processing, let it finish.
    while(true)
    {
      if(!mMovingFunctionPending)
        break;
    }

    // check if there really was collision between cars,
    // assume my car moved once since message was sent by other party
    myCar.move(-carSpeedVect.x, -carSpeedVect.y );
    moveWorldCam(carSpeedVect.x, -carSpeedVect.y, 0);   // camera folows the car

    if( isCarCollisionWithAvatar() )
    {
      // do some collision responce
      carAvatarColisionResponce();

      // Send responce to awatar: car's current position and speed.
      // Tell also awatar its new speed vector after colision.
      myCar.getLocation(aCarPosVect);
      app.sendColisionBetweenCarsConfirmed(aCarPosVect,
                                           myCar.getSpinAngleY(),
                                           carSpeedVect,
                                           awatarSpeedVect);
      System.out.println("updateOnColisionSignal send confirmed");
    }
    else
    {
      myCar.move(carSpeedVect.x, carSpeedVect.y );
      moveWorldCam(-carSpeedVect.x, carSpeedVect.y, 0); // camera folows the car
      // if there was no collision, simply send car's valid parameters
      myCar.getLocation(aCarPosVect);
      app.sendColisionBetweenCarsNone(aCarPosVect, myCar.getSpinAngleY(), carSpeedVect);
      System.out.println("updateOnColisionSignal send none");
    }
  }

  // 1st message that can be received after we've send signal collision message
  public void updateColisionConfirmed(Vector3D aAvatarPos, int aAwRY, 
                                      Vector3D aAvatarSpeed, Vector3D aCarSpeed)
  {
    System.out.println("recived colision CONFIRMATION");

    // update car's speed vector after collision with the value received from other party
    carSpeedVect.set(aCarSpeed);
    carSpeedValue = (int)Math.sqrt( (carSpeedVect.x*carSpeedVect.x) + 
                                    (carSpeedVect.y*carSpeedVect.y) );
    updateCarMoveDirection(false);
    // update avatar's position and speed
    awatarCar.setPositionAndAngle(aAvatarPos.x, aAvatarPos.y, aAwRY);
    awatarSpeedVect.set(aAvatarSpeed);
    mAvatarUpdateStep = 0;
    repaint();
  }

  // 2nd message that can be received after we've send signal collision message
  public void updateColisionNone(Vector3D aAvatarPos, int aAwRY, Vector3D aAvatarSpeed)
  {
    System.out.println("recived colision NONE");

    awatarCar.setPositionAndAngle(aAvatarPos.x, aAvatarPos.y, aAwRY);
    awatarSpeedVect.set(aAvatarSpeed);
    mAvatarUpdateStep = 0;
    repaint();
  }

  // as a colision responce do simple swap of speeds between car and awatar
  private void carAvatarColisionResponce()
  {
  int tmpX = carSpeedVect.x;
  int tmpY = carSpeedVect.y;
  carSpeedVect.x = awatarSpeedVect.x;
  carSpeedVect.y = awatarSpeedVect.y;
  awatarSpeedVect.x = tmpX;
  awatarSpeedVect.y = tmpY;

  carSpeedValue = (int)Math.sqrt( (carSpeedVect.x*carSpeedVect.x) + 
                                  (carSpeedVect.y*carSpeedVect.y) );
  updateCarMoveDirection(false);
  }

}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美吻胸吃奶大尺度电影| www久久精品| 26uuu亚洲综合色| 亚洲精品视频自拍| 国产成人免费视频网站| 欧美一区二区三区视频在线| 亚洲日本一区二区| 国产成人一级电影| 日韩精品一区二| 日韩av中文在线观看| 欧洲亚洲精品在线| 亚洲视频精选在线| 成人高清免费在线播放| 精品999在线播放| 日韩精品久久理论片| 欧美日韩精品一区二区三区蜜桃 | 国产精品对白交换视频 | 色哟哟在线观看一区二区三区| 精品处破学生在线二十三| 青青草原综合久久大伊人精品优势| 日本乱码高清不卡字幕| 日韩理论片一区二区| 国产99久久久国产精品潘金| 久久久夜色精品亚洲| 精品一区免费av| 欧美一区二区三区公司| 日本aⅴ亚洲精品中文乱码| 欧美日韩一区二区不卡| 亚洲国产三级在线| 欧美三级中文字幕在线观看| 亚洲国产精品一区二区久久| 91搞黄在线观看| 亚洲一区二区在线播放相泽| 欧洲视频一区二区| 亚洲第一福利一区| 欧美另类videos死尸| 日韩影院在线观看| 日韩欧美国产精品一区| 九九国产精品视频| 国产女同性恋一区二区| 大白屁股一区二区视频| 亚洲手机成人高清视频| 91国产免费观看| 日av在线不卡| 国产欧美一区二区三区网站| caoporen国产精品视频| 一区二区三区不卡视频| 欧美一区二区三区视频免费播放| 国内精品免费在线观看| 亚洲欧美在线视频观看| 91电影在线观看| 丝袜诱惑制服诱惑色一区在线观看| 欧美成va人片在线观看| 懂色av中文一区二区三区| 亚洲日本青草视频在线怡红院 | 94色蜜桃网一区二区三区| 亚洲最大的成人av| 日韩手机在线导航| 成人美女在线观看| 亚洲小少妇裸体bbw| 国产日韩精品一区| 91女厕偷拍女厕偷拍高清| 亚洲影院久久精品| 久久久久高清精品| 91国产丝袜在线播放| 国产在线播精品第三| 亚洲欧美成aⅴ人在线观看| 日韩一区二区三区免费看 | 国产精品一区在线| 亚洲综合视频在线| 国产三级欧美三级| 在线观看日韩电影| 国产大陆a不卡| 日日夜夜一区二区| 亚洲欧洲精品天堂一级 | 亚洲免费观看高清| 欧美xxxx在线观看| 欧美亚洲国产bt| 丁香啪啪综合成人亚洲小说| 视频一区二区中文字幕| 亚洲人成亚洲人成在线观看图片 | 777a∨成人精品桃花网| 丁香六月综合激情| 久久电影网电视剧免费观看| 亚洲www啪成人一区二区麻豆| 中国av一区二区三区| 日韩精品中午字幕| 91.com视频| 欧美在线三级电影| 91麻豆免费看| 成人午夜大片免费观看| 久久99精品视频| 日本亚洲电影天堂| 午夜视频久久久久久| 亚洲免费成人av| 亚洲欧洲精品成人久久奇米网| 久久综合九色综合97婷婷女人| 91精品国产欧美一区二区| 在线观看欧美黄色| 91亚洲精品一区二区乱码| 国产精品一区2区| 国产精品亚洲第一区在线暖暖韩国| 男人的j进女人的j一区| 日韩黄色免费网站| 亚洲一区二区影院| 麻豆国产精品视频| 免费在线观看成人| 美腿丝袜亚洲三区| 久久国产精品99久久久久久老狼| 亚洲成人av在线电影| 亚洲福利视频一区二区| 一区二区三区久久| 亚洲一区二区三区四区在线| 亚洲精品欧美二区三区中文字幕| 亚洲色图一区二区三区| 亚洲欧美日韩电影| 亚洲成a人片综合在线| 性欧美大战久久久久久久久| 午夜电影一区二区| 日本视频免费一区| 久久av老司机精品网站导航| 激情小说亚洲一区| 国产麻豆精品一区二区| 国产成都精品91一区二区三| 99国产欧美另类久久久精品| 91福利在线免费观看| 欧美日韩久久不卡| 精品美女被调教视频大全网站| 精品国产污污免费网站入口 | av在线不卡电影| 色综合天天性综合| 精品视频免费在线| 欧美哺乳videos| 日本一区二区三区久久久久久久久不 | 久久综合久久综合久久| 中文欧美字幕免费| 亚洲已满18点击进入久久| 毛片一区二区三区| 国产精品一区二区在线看| 99精品视频在线免费观看| 欧美日韩极品在线观看一区| 欧美成人在线直播| 国产精品无人区| 亚洲第一搞黄网站| 国产99久久久国产精品潘金| 欧美日韩一区二区三区高清| ㊣最新国产の精品bt伙计久久| 一区二区三区四区五区视频在线观看| 午夜精品久久久久久久蜜桃app | 久久精品夜夜夜夜久久| 亚洲婷婷在线视频| 蜜桃精品在线观看| av不卡免费在线观看| 欧美一级国产精品| 最新日韩av在线| 久久国产成人午夜av影院| 99re8在线精品视频免费播放| 91精品国产高清一区二区三区 | 国产亚洲美州欧州综合国| 一区二区三区欧美久久| 国产成人综合自拍| 欧美美女bb生活片| 亚洲欧美一区二区三区极速播放 | 美女网站色91| 色狠狠综合天天综合综合| 久久精品人人爽人人爽| 日本不卡视频在线| 欧美伊人精品成人久久综合97| 国产欧美日韩另类一区| 免费人成在线不卡| 欧洲av在线精品| 国产精品乱人伦| 国产精品一区二区无线| 欧美一区二区三区视频免费播放| 一区二区三区电影在线播| 成人晚上爱看视频| 久久―日本道色综合久久| 蜜桃久久久久久| 欧美一区二区视频观看视频| 亚洲一级二级在线| 色综合天天视频在线观看 | 在线视频你懂得一区| 国产精品视频第一区| 国产美女久久久久| 欧美精品一区二区三区视频 | 天天操天天综合网| 色哟哟一区二区在线观看| 中文字幕中文乱码欧美一区二区| 国产一区二区91| 久久夜色精品国产噜噜av| 久草热8精品视频在线观看| 欧美一区二区精品在线| 日本美女视频一区二区| 日韩视频免费观看高清在线视频| 日韩不卡手机在线v区| 欧美吻胸吃奶大尺度电影| 亚洲电影一区二区三区| 欧美日韩一区二区在线观看视频| 一区二区三区四区乱视频| 欧美亚洲一区二区在线观看|