![]() |
OpenSiv3D
v0.6.5
C++20 framework for creative coding
|
2D 物理演算のワールドに存在する物体 More...
#include <P2Body.hpp>
Public Member Functions | |
SIV3D_NODISCARD_CXX20 | P2Body () |
デフォルトコンストラクタ More... | |
P2BodyID | id () const noexcept |
物体の ID を返します。 More... | |
bool | isEmpty () const noexcept |
物体がワールドに存在しないかを返します More... | |
operator bool () const noexcept | |
物体がワールドに存在するかを返します。 More... | |
void | release () |
物体をワールドから明示的に削除します。 More... | |
P2Body & | addLine (const Line &localPos, OneSided oneSided, const P2Material &material={}, const P2Filter &filter={}) |
線分の部品を物体に追加します。 More... | |
P2Body & | addLineString (const LineString &localPos, OneSided oneSided, const P2Material &material={}, const P2Filter &filter={}) |
連続する複数の線分の部品を物体に追加します。 More... | |
P2Body & | addClosedLineString (const LineString &localPos, OneSided oneSided, const P2Material &material={}, const P2Filter &filter={}) |
連続する複数の線分(終点と始点を結ぶ)の部品を物体に追加します。 More... | |
P2Body & | addCircle (const Circle &localPos, const P2Material &material={}, const P2Filter &filter={}) |
円の部品を物体に追加します。 More... | |
P2Body & | addCircleSensor (const Circle &localPos, const P2Filter &filter={}) |
円形のセンサー部品を物体に追加します。 More... | |
P2Body & | addRect (const RectF &localPos, const P2Material &material={}, const P2Filter &filter={}) |
長方形の部品を物体に追加します。 More... | |
P2Body & | addTriangle (const Triangle &localPos, const P2Material &material={}, const P2Filter &filter={}) |
三角形の部品を物体に追加します。 More... | |
P2Body & | addQuad (const Quad &localPos, const P2Material &material={}, const P2Filter &filter={}) |
凸な四角形の部品を物体に追加します。 More... | |
P2Body & | addPolygon (const Polygon &localPos, const P2Material &material={}, const P2Filter &filter={}) |
多角形の部品を物体に追加します。 More... | |
P2Body & | addPolygons (const MultiPolygon &localPos, const P2Material &material={}, const P2Filter &filter={}) |
複数の多角形の部品を物体に追加します。 More... | |
P2Body & | setSleepEnabled (bool enabled) noexcept |
bool | getSleepEnabled () const noexcept |
P2Body & | setAwake (bool awake) noexcept |
bool | isAwake () const noexcept |
P2Body & | setPos (double x, double y) noexcept |
P2Body & | setPos (Vec2 pos) noexcept |
P2Body & | moveBy (double x, double y) noexcept |
P2Body & | moveBy (Vec2 v) noexcept |
P2Body & | setAngle (double angle) noexcept |
P2Body & | rotateBy (double angle) noexcept |
P2Body & | setTransform (double x, double y, double angle) noexcept |
P2Body & | setTransform (Vec2 pos, double angle) noexcept |
P2Body & | applyForce (Vec2 force) noexcept |
P2Body & | applyForce (Vec2 force, Vec2 offset) noexcept |
P2Body & | applyForceAt (Vec2 force, Vec2 pos) noexcept |
P2Body & | applyLinearImpulse (Vec2 force) noexcept |
P2Body & | applyLinearImpulse (Vec2 force, Vec2 offset) noexcept |
P2Body & | applyLinearImpulseAt (Vec2 force, Vec2 pos) noexcept |
P2Body & | applyTorque (double torque) noexcept |
P2Body & | applyAngularImpulse (double torque) noexcept |
Vec2 | getPos () const noexcept |
物体のワールド座標 (cm) を返します。 More... | |
double | getAngle () const noexcept |
物体の回転角度(ラジアン)を返します。 More... | |
std::pair< Vec2, double > | getTransform () const noexcept |
P2Body & | setVelocity (Vec2 v) noexcept |
Vec2 | getVelocity () const noexcept |
物体の現在の速度 (cm/s) を返します。 More... | |
P2Body & | setAngularVelocity (double omega) noexcept |
double | getAngularVelocity () const noexcept |
物体の現在の角速度 (rad/s) を返します。 More... | |
P2Body & | setDamping (double damping) noexcept |
double | getDamping () const noexcept |
P2Body & | setAngularDamping (double damping) noexcept |
double | getAngularDamping () const noexcept |
P2Body & | setGravityScale (double scale) noexcept |
double | getGravityScale () const noexcept |
double | getMass () const noexcept |
物体の重量 (kg) を返します。 More... | |
double | getInertia () const noexcept |
P2Body & | setBodyType (P2BodyType bodyType) noexcept |
P2BodyType | getBodyType () const noexcept |
P2Body & | setFixedRotation (bool fixedRotation) noexcept |
物体の回転の無効・有効を設定します(デフォルトは有効) More... | |
bool | isFixedRotation () const noexcept |
物体の回転が有効であるか、現在の設定を返します。 More... | |
const P2Body & | draw (const ColorF &color=Palette::White) const |
物体のすべての部品を描画します。 More... | |
const P2Body & | drawFrame (double thickness=1.0, const ColorF &color=Palette::White) const |
物体のすべての部品の枠を描画します。 More... | |
const P2Body & | drawWireframe (double thickness=1.0, const ColorF &color=Palette::White) const |
物体のすべての部品をワイヤフレーム表示します。 More... | |
size_t | num_shapes () const noexcept |
物体が持つ部品の個数を返します。 More... | |
P2Shape & | shape (size_t index) |
const P2Shape & | shape (size_t index) const |
const std::shared_ptr< P2Shape > & | getPtr (size_t index) const noexcept |
template<class PShape , std::enable_if_t< std::is_base_of_v< P2Shape, PShape >> * = nullptr> | |
std::shared_ptr< PShape > | as (size_t index) const |
物体の部品を P2Shape を継承するクラスのポインタとして返します。 More... | |
2D 物理演算のワールドに存在する物体
P2Shape
) から構成されます。 SIV3D_NODISCARD_CXX20 s3d::P2Body::P2Body | ( | ) |
デフォルトコンストラクタ
P2Body& s3d::P2Body::addCircle | ( | const Circle & | localPos, |
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
円の部品を物体に追加します。
P2Circle
の部品を物体に追加します。 localPos | 物体のワールド座標から見たローカルでの形状の座標 (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
円形のセンサー部品を物体に追加します。
P2Circle
の部品を物体に追加します。 localPos | 物体のワールド座標から見たローカルでの形状の座標 (cm) |
filter | センサーの干渉フィルタ |
P2Body& s3d::P2Body::addClosedLineString | ( | const LineString & | localPos, |
OneSided | oneSided, | ||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
連続する複数の線分(終点と始点を結ぶ)の部品を物体に追加します。
P2LineString
の部品を物体に追加します。 localPos | 物体のワールド座標から見たローカルでの形状の座標 (cm) |
oneSided | 線分の片側(右に向かうときの上側)のみ干渉するか |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body& s3d::P2Body::addLine | ( | const Line & | localPos, |
OneSided | oneSided, | ||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
線分の部品を物体に追加します。
P2Line
の部品を物体に追加します。 localPos | 物体のワールド座標から見たローカルでの形状の座標 (cm) |
oneSided | 線分の片側(右に向かうときの上側)のみ干渉するか |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body& s3d::P2Body::addLineString | ( | const LineString & | localPos, |
OneSided | oneSided, | ||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
連続する複数の線分の部品を物体に追加します。
P2LineString
の部品を物体に追加します。 localPos | 物体のワールド座標から見たローカルでの形状の座標 (cm) |
oneSided | 線分の片側(右に向かうときの上側)のみ干渉するか |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body& s3d::P2Body::addPolygon | ( | const Polygon & | localPos, |
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
多角形の部品を物体に追加します。
P2Polygon
の部品を物体に追加します。 localPos | 物体のワールド座標から見たローカルでの形状の座標 (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body& s3d::P2Body::addPolygons | ( | const MultiPolygon & | localPos, |
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
複数の多角形の部品を物体に追加します。
P2Polygon
の部品を物体に追加します。 localPos | 物体のワールド座標から見たローカルでの形状の座標 (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body& s3d::P2Body::addQuad | ( | const Quad & | localPos, |
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
凸な四角形の部品を物体に追加します。
P2Quad
の部品を物体に追加します。 localPos | 物体のワールド座標から見たローカルでの形状の座標 (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body& s3d::P2Body::addRect | ( | const RectF & | localPos, |
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
長方形の部品を物体に追加します。
P2Rect
の部品を物体に追加します。 localPos | 物体のワールド座標から見たローカルでの形状の座標 (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body& s3d::P2Body::addTriangle | ( | const Triangle & | localPos, |
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
三角形の部品を物体に追加します。
P2Triangle
の部品を物体に追加します。 localPos | 物体のワールド座標から見たローカルでの形状の座標 (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
|
noexcept |
torque |
force | |
offset |
force | |
offset |
force | |
pos |
|
noexcept |
torque |
std::shared_ptr<PShape> s3d::P2Body::as | ( | size_t | index | ) | const |
物体のすべての部品を描画します。
color | 色 |
const P2Body& s3d::P2Body::drawFrame | ( | double | thickness = 1.0 , |
const ColorF & | color = Palette::White |
||
) | const |
物体のすべての部品の枠を描画します。
thickness | 線の太さ(ピクセル) |
color | 色 |
const P2Body& s3d::P2Body::drawWireframe | ( | double | thickness = 1.0 , |
const ColorF & | color = Palette::White |
||
) | const |
物体のすべての部品をワイヤフレーム表示します。
thickness | 線の太さ(ピクセル) |
color | 色 |
|
noexcept |
物体の回転角度(ラジアン)を返します。
|
noexcept |
|
noexcept |
物体の現在の角速度 (rad/s) を返します。
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
物体の重量 (kg) を返します。
|
noexcept |
物体のワールド座標 (cm) を返します。
|
noexcept |
index |
|
noexcept |
|
noexcept |
|
noexcept |
物体の現在の速度 (cm/s) を返します。
|
noexcept |
物体の ID を返します。
|
noexcept |
|
noexcept |
物体がワールドに存在しないかを返します
|
noexcept |
物体の回転が有効であるか、現在の設定を返します。
|
noexcept |
x | |
y |
|
noexcept |
物体が持つ部品の個数を返します。
|
explicitnoexcept |
物体がワールドに存在するかを返します。
void s3d::P2Body::release | ( | ) |
物体をワールドから明示的に削除します。
|
noexcept |
angle |
|
noexcept |
angle |
|
noexcept |
damping |
|
noexcept |
omega |
|
noexcept |
awake |
|
noexcept |
bodyType |
|
noexcept |
damping |
|
noexcept |
物体の回転の無効・有効を設定します(デフォルトは有効)
fixedRotation | 回転を有効にするか |
|
noexcept |
scale |
|
noexcept |
x | |
y |
|
noexcept |
enabled |
|
noexcept |
x | |
y | |
angle |
P2Shape& s3d::P2Body::shape | ( | size_t | index | ) |
index |
const P2Shape& s3d::P2Body::shape | ( | size_t | index | ) | const |
index |