void OBB::SetUpValue()
{
  /*   V1      V4  */
  /*   --------    */
  /*   |   .  |    */
  /*   --------    */
  /*   V2      V3  */

  // update mHalfextend
  static Matrix Tran;
  static Matrix InvRot;
  static Matrix InvTran;
  static Vector3 scale;
  mRotation = cphysics->gameObject->transform->GetGlobalRotationMatrix();
  Tran = cphysics->gameObject->transform->mTranslation;
  Tran.m03 += cphysics->GetOffSetX(); 
  Tran.m13 += cphysics->GetOffSetY();
  InvRot = mRotation.Inverted();
  InvTran = Tran.Inverted();
  mWorld = Tran * mRotation;
  mInvWorld = InvRot * InvTran;
  scale = cphysics->gameObject->transform->scale;
  float scalex = cphysics->mWidthScale;
  float scaley = cphysics->mHeightScale;
  mHalfextend[0].x = abs(scale.x) * 0.5f * scalex;
  mHalfextend[1].y = abs(scale.y) * 0.5f * scaley;
  
  // update center
	mCenter	   = cphysics->GetPosition();
  // update axis
  Vector AxisX(1.0f,0,0,0);
  Vector AxisY(0,1.0f,0,0);
  static Vector newAxisX; 
  static Vector newAxisY;
  newAxisX = mRotation * AxisX;
  newAxisY = mRotation * AxisY;
  newAxisX.Normalize();
  newAxisY.Normalize();
  mAxis[0] = newAxisX;
  mAxis[1] = newAxisY;


   // update four points
  float halfX = GetHalfExtendX().x;
  float halfY = GetHalfExtendY().y;

  mPoints[0] = mCenter - mAxis[0] * halfX + mAxis[1] * halfY;
  mPoints[1] = mCenter - mAxis[0] * halfX - mAxis[1] * halfY;
  mPoints[2] = mCenter + mAxis[0] * halfX - mAxis[1] * halfY;
  mPoints[3] = mCenter + mAxis[0] * halfX + mAxis[1] * halfY;
}
Exemple #2
0
Matrix4x4 Frame::GetTransformationMatrix(const Date& t, const Frame& ref) const
{
	Matrix4x4 transform = Matrix4x4::Zero;

	Vector3 x = AxisX(t, ref);
	Vector3 y = AxisY(t, ref);
	Vector3 z = AxisZ(t, ref);

	for(int row = 0; row < 3; row++)
	{
		transform.Set(row, 0, x[row]);
		transform.Set(row, 1, y[row]);
		transform.Set(row, 2, z[row]);
	}

	transform.Set(3, 3, 1.0);

	return transform;
}
// 武器の移動(ブレード)
void CWeapon::Move() {
    //ブレード左手に持たせる
    if (blade_hand_chang==left_hand) {
        CModelBone* b = Owner->GetBone(L"L_kobusi_Joint");
        //順手持ち
        if (blade_hold == blade_hold_normal) {
            Rotation = RotationY(0.0f)*RotationX(-0.25f)*RotationY(-0.02f)*b->Rotation;
            Position = b->Position + CVector(-0.05f, -0.3f, 0.12f)*b->Rotation;
        }
        //逆手持ち
        if (blade_hold == blade_hold_reverse) {
            Rotation = RotationY(-0.025f)*RotationX(-0.23f)*RotationY(-0.5f)*b->Rotation;
            Position = b->Position + CVector(-0.05f, -0.3f, 0.12f)*b->Rotation;
        }
    }
    //ブレード右手に持たせる
    if (blade_hand_chang==right_hand) {
        CModelBone* b = Owner->GetBone(L"R_kobusi_Joint");
        //順手持ち
        if (blade_hold == blade_hold_normal) {
            Rotation = RotationY(0.0f)*RotationX(-0.25f)*RotationY(-0.02f)*b->Rotation;
            Position = b->Position + CVector(-0.05f, -0.3f, 0.12f)*b->Rotation;
        }
    }

    if (blade == blade_on) {
        //ブレード出現
        Color = CColor(1, 1, 1, 1.0f);
    }
    if (blade == blade_off) {
        //ブレード出現
        Color = CColor(1, 1, 1, 0.0f);
    }
    //ブレード光
    EmissiveColor = CColor(1, 1, 1, 1);

    //--------当たり判定-------------------------------------------------------------------------------------------------------
    //クリア条件にになっていない
    if (clear == clear_off) {
        //ブレード出現中
        if (blade == blade_on) {
            //メカペン
            CMover *HIT_ENEMY = NULL;
            CMover *HIT_ENEMY3 = NULL;
            EnemyList.Apply([&](CMover* e) {
                CHit hit;
                if (e->BladeHitState == 1) {
                    if (ENEMY_BLADE_HIT == 0 && hit.SegmentAndModel(Position, Position - AxisY() * 13.8f, e, e->Model)) { //中心・半径・ポインタ・アローモデル
                        HIT_ENEMY = e;
                        ENEMY_BLADE_HIT = 1;
                    }
                    if (ENEMY_BLADE_HIT == 1 && HIT_ENEMY) {
                        New<CEffect_zan_position>(CVector(HIT_ENEMY->Position.X, HIT_ENEMY->Position.Y, HIT_ENEMY->Position.Z));
                        HIT_ENEMY->Life -= 50.0f;
                        ENEMY_BLADE_HIT = 2;
                        Blade_hit_se();//ブレードヒット効果音
                    }
                    if (ENEMY_BLADE_HIT == 2 && !hit.SegmentAndModel(Position, Position - AxisY() * 13.8f, e, e->Model)) { //中心・半径・ポインタ・アローモデル
                        ENEMY_BLADE_HIT = 3;
                    }
                    if (ENEMY_BLADE_HIT == 3) {
                        ENEMY_TIME++;
                        if (ENEMY_TIME == 5) {
                            ENEMY_TIME = 0;
                            ENEMY_BLADE_HIT = 0;
                        }
                    }
                }
            });

            //多脚ロボ
            Enemy_takyakuList.Apply([&](CMover* et) {
                CHit hit1;
                if (et->BladeHitState == 1) {
                    if (ENEMY_BLADE_HIT2 == 0 && hit1.SegmentAndModel(Position, Position - AxisY() * 13.8f, et, et->Model)) { //中心・半径・ポインタ・アローモデル13.8
                        HIT_ENEMY = et;
                        ENEMY_BLADE_HIT2 = 1;
                    }
                    if (ENEMY_BLADE_HIT2 == 1 && HIT_ENEMY) {
                        New<CEffect_zan_position>(CVector(HIT_ENEMY->Position.X, HIT_ENEMY->Position.Y, HIT_ENEMY->Position.Z));
                        HIT_ENEMY->Life -= 50.0f;
                        ENEMY_BLADE_HIT2 = 2;
                        Blade_hit_se();//ブレードヒット効果音
                    }
                    if (ENEMY_BLADE_HIT2 == 2 && !hit1.SegmentAndModel(Position, Position - AxisY() * 13.8f, et, et->Model)) { //中心・半径・ポインタ・アローモデル
                        ENEMY_BLADE_HIT2 = 3;
                    }
                    if (ENEMY_BLADE_HIT2 == 3) {
                        ENEMY_TIME2++;
                        if (ENEMY_TIME2 == 10) {
                            ENEMY_TIME2 = 0;
                            ENEMY_BLADE_HIT2 = 0;
                        }
                    }
                }
            });

            //BOSS
            Enemy_BossList.Apply([&](CMover* eb) {
                CHit hit2;
                if (eb->BladeHitState == 1) {
                    if (ENEMY_BLADE_HIT3 == 0 && hit2.SegmentAndModel(Position, Position - AxisY() * 100.8f, eb, eb->Model)) { //中心・半径・ポインタ・アローモデル13.8
                        HIT_ENEMY3 = eb;
                        ENEMY_BLADE_HIT3 = 1;
                    }
                    if (ENEMY_BLADE_HIT3 == 1 && HIT_ENEMY3) {
                        New<CEffect_zan_position>(CVector(HIT_ENEMY3->Position.X, HIT_ENEMY3->Position.Y, HIT_ENEMY3->Position.Z));
                        HIT_ENEMY3->Life -= 50.0f;
                        Blade_hit_se();//ブレードヒット効果音
                        ENEMY_BLADE_HIT3 = 2;
                    }
                    if (ENEMY_BLADE_HIT3 == 2 && !hit2.SegmentAndModel(Position, Position - AxisY() * 100.8f, eb, eb->Model)) { //中心・半径・ポインタ・アローモデル
                        ENEMY_BLADE_HIT3 = 3;
                    }
                    if (ENEMY_BLADE_HIT3 == 3) {
                        ENEMY_TIME3++;
                        if (ENEMY_TIME3 == 10) {
                            ENEMY_TIME3 = 0;
                            ENEMY_BLADE_HIT3 = 0;
                        }
                    }
                }
            });
        }
    }
}
bool StudentLocalization::stepFindHead(const IntensityImage &image, FeatureMap &features) const {
	Histogram AxisY(image, 50, 50, 0, 0, Axis::y);
	
	//determine top of the head

	int topHead = -1;

	for (int i = 0; i < AxisY.getSize(); ++i) {
		if (AxisY.getValue(i) > 2) {
			topHead = i;
			break;
		}
	}
	if (topHead == -1) {
		return false;
	}
	
	//determine sides

	int lastLeftX = -1;
	int lastRightX = -1;
	for (int y = topHead; y < image.getHeight(); y += 20) {
		Histogram layerX(image, 0, 0, y, (image.getHeight() - y - 20), Axis::x);
		
		//determine leftside of the head
		int leftX = -1;
		for (int i = 0; i < layerX.getSize(); ++i) {
			if (layerX.getValue(i) > 2) {
				leftX = i;
				break;
			}
		}

		//determine rightside of the head
		int rightX = -1;
		for (int i = layerX.getSize() - 1; i >= 0 ; --i) {
			if (layerX.getValue(i) > 2) {
				rightX = i;
				break;
			}
		}
		
		// if not both sides are found skip the rest of the loop
		if (leftX == -1 || rightX == -1) {
			continue;
		}

		int currentHeadWidth = rightX - leftX;
		int lastHeadWidth = lastRightX - lastLeftX;

		if (currentHeadWidth < lastHeadWidth) {
			Feature * headUpperBound = new Feature(Feature::FEATURE_HEAD_TOP, Point2D<double>(lastRightX - (currentHeadWidth / 2), topHead));
			Feature * headLeftBound = new Feature(Feature::FEATURE_HEAD_LEFT_SIDE, Point2D<double>(lastLeftX, y));
			Feature * headRightBound = new Feature(Feature::FEATURE_HEAD_RIGHT_SIDE, Point2D<double>(lastRightX, y));

			features.putFeature(*headUpperBound);
			features.putFeature(*headLeftBound);
			features.putFeature(*headRightBound);
					
			return true;
		}

		lastLeftX = leftX;
		lastRightX = rightX;
	}
	
	return false;
}