153 lines
3.1 KiB
C++
153 lines
3.1 KiB
C++
// Copyright (c) 2016-2018 Easy2D - Nomango
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
// in the Software without restriction, including without limitation the rights
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
// THE SOFTWARE.
|
|
|
|
#pragma once
|
|
#include "base.hpp"
|
|
#include "Transform.hpp"
|
|
|
|
namespace easy2d
|
|
{
|
|
class Unit
|
|
: public ObjectBase
|
|
{
|
|
public:
|
|
Unit();
|
|
|
|
virtual ~Unit();
|
|
|
|
// »ñÈ¡×ø±ê
|
|
virtual const Point& GetPosition() const { return transform_.position; }
|
|
|
|
// »ñÈ¡ºáÏòËõ·Å±ÈÀý
|
|
virtual float GetScaleX() const { return transform_.scale.x; }
|
|
|
|
// »ñÈ¡×ÝÏòËõ·Å±ÈÀý
|
|
virtual float GetScaleY() const { return transform_.scale.y; }
|
|
|
|
// »ñÈ¡ºáÏò´íÇнǶÈ
|
|
virtual float GetSkewX() const { return transform_.skew.x; }
|
|
|
|
// »ñÈ¡×ÝÏò´íÇнǶÈ
|
|
virtual float GetSkewY() const { return transform_.skew.y; }
|
|
|
|
// »ñÈ¡Ðýת½Ç¶È
|
|
virtual float GetRotation() const { return transform_.rotation; }
|
|
|
|
Transform const& GetTransform() const { return transform_; }
|
|
|
|
// ÉèÖúá×ø±ê
|
|
void SetPositionX(
|
|
float x
|
|
);
|
|
|
|
// ÉèÖÃ×Ý×ø±ê
|
|
void SetPositionY(
|
|
float y
|
|
);
|
|
|
|
// ÉèÖÃ×ø±ê
|
|
void SetPosition(
|
|
const Point & point
|
|
);
|
|
|
|
// ÉèÖÃ×ø±ê
|
|
virtual void SetPosition(
|
|
float x,
|
|
float y
|
|
);
|
|
|
|
// ÒÆ¶¯
|
|
void MoveBy(
|
|
float x,
|
|
float y
|
|
);
|
|
|
|
// ÒÆ¶¯
|
|
void MoveBy(
|
|
const Point & vector
|
|
);
|
|
|
|
// ÉèÖúáÏòËõ·Å±ÈÀý
|
|
// ĬÈÏΪ 1.0
|
|
void SetScaleX(
|
|
float scale_x
|
|
);
|
|
|
|
// ÉèÖÃ×ÝÏòËõ·Å±ÈÀý
|
|
// ĬÈÏΪ 1.0
|
|
void SetScaleY(
|
|
float scale_y
|
|
);
|
|
|
|
// ÉèÖÃËõ·Å±ÈÀý
|
|
// ĬÈÏΪ (1.0, 1.0)
|
|
virtual void SetScale(
|
|
float scale_x,
|
|
float scale_y
|
|
);
|
|
|
|
// ÉèÖÃËõ·Å±ÈÀý
|
|
// ĬÈÏΪ 1.0
|
|
void SetScale(
|
|
float scale
|
|
);
|
|
|
|
// ÉèÖúáÏò´íÇнǶÈ
|
|
// ĬÈÏΪ 0
|
|
void SetSkewX(
|
|
float skew_x
|
|
);
|
|
|
|
// ÉèÖÃ×ÝÏò´íÇнǶÈ
|
|
// ĬÈÏΪ 0
|
|
void SetSkewY(
|
|
float skew_y
|
|
);
|
|
|
|
// ÉèÖôíÇнǶÈ
|
|
// ĬÈÏΪ (0, 0)
|
|
virtual void SetSkew(
|
|
float skew_x,
|
|
float skew_y
|
|
);
|
|
|
|
// ÉèÖÃÐýת½Ç¶È
|
|
// ĬÈÏΪ 0
|
|
virtual void SetRotation(
|
|
float rotation
|
|
);
|
|
|
|
virtual void SetTransform(
|
|
Transform const& transform
|
|
);
|
|
|
|
// »ñÈ¡¶þά±ä»»¾ØÕó
|
|
virtual math::Matrix const& GetTransformMatrix();
|
|
|
|
protected:
|
|
virtual void UpdateMatrix();
|
|
|
|
protected:
|
|
bool dirty_transform_;
|
|
Transform transform_;
|
|
math::Matrix matrix_cached_;
|
|
};
|
|
}
|