Beispiel #1
0
Box2D::Box2D(const AABox2D& b) {
    for (int i = 0; i < 4; ++i) {
        m_corner[i] = b.corner(i);
    }
    
    computeAxes();
}
Beispiel #2
0
Box2D::Box2D(const Vector2& center, float w, float h, float angle) {
    Vector2 X( cos(angle), sin(angle));
    Vector2 Y(-sin(angle), cos(angle));
    
    X *= w / 2;
    Y *= h / 2;
    
    m_corner[0] = center - X - Y;
    m_corner[1] = center + X - Y;
    m_corner[2] = center + X + Y;
    m_corner[3] = center - X + Y;
    
    computeAxes();
}
Beispiel #3
0
OBB::OBB(const AABB& aabb)
{
	corner[0] = vec2(aabb.x1,aabb.y1);
	corner[1] = vec2(aabb.x2,aabb.y1);
	corner[2] = vec2(aabb.x2,aabb.y2);
	corner[3] = vec2(aabb.x1,aabb.y2);

	// rotate by current matrix
	mat4 mt = glGetCurrentMatrix(GL_MODELVIEW_MATRIX);
  for (int c = 0; c < 4; ++c)
		corner[c] = vec2(transformPoint(mt,vec3(corner[c])));
	
  computeAxes();
}
Beispiel #4
0
Box2D::Box2D(const CFrame& frame, Box2D& b) {
    for (int i = 0; i < 4; ++i) {
        m_corner[i] = frame.pointToWorldSpace(Vector3(b.corner(i), 0)).xy();
    }
    computeAxes();
}