![]() |
OpenSiv3D
v0.6.5
C++20 framework for creative coding
|
2D 物理演算を行うワールド More...
#include <P2World.hpp>
Public Member Functions | |
SIV3D_NODISCARD_CXX20 | P2World (double gravity=980) |
2D 物理演算を行うワールドを作成します。 More... | |
SIV3D_NODISCARD_CXX20 | P2World (Vec2 gravity) |
2D 物理演算を行うワールドを作成します。 More... | |
void | update (double timeStep=Scene::DeltaTime(), int32 velocityIterations=6, int32 positionIterations=2) const |
2D 物理演算のワールドの状態を更新します。 More... | |
void | setSleepEnabled (bool enabled) |
ワールド内の物体がスリープ状態になることを許可・不許可を設定します(デフォルトでは許可)。 More... | |
bool | getSleepEnabled () const |
ワールド内の物体がスリープ状態になることを許可しているかの現在の設定を返します。 More... | |
void | setGravity (double gravity) |
重力加速度 (cm/s^2) を設定します。 More... | |
void | setGravity (const Vec2 &gravity) |
重力加速度 (cm/s^2) を設定します。 More... | |
Vec2 | getGravity () const |
現在の重力加速度の設定を返します。 More... | |
void | shiftOrigin (const Vec2 &newOrigin) |
ワールドの物体全ての座標 (cm) をシフトします。 More... | |
P2Body | createPlaceholder (P2BodyType bodyType, const Vec2 &worldPos) |
プレースホルダーとなる物体を作成します。 More... | |
P2Body | createLine (P2BodyType bodyType, const Vec2 &worldPos, const Line &localPos, OneSided oneSided=OneSided::No, const P2Material &material={}, const P2Filter &filter={}) |
線分を部品として持つ物体を作成します。 More... | |
P2Body | createLineString (P2BodyType bodyType, const Vec2 &worldPos, const LineString &localPos, OneSided oneSided=OneSided::No, const P2Material &material={}, const P2Filter &filter={}) |
連続する複数の線分を部品として持つ物体を作成します。 More... | |
P2Body | createClosedLineString (P2BodyType bodyType, const Vec2 &worldPos, const LineString &localPos, OneSided oneSided=OneSided::No, const P2Material &material={}, const P2Filter &filter={}) |
連続する複数の線分(終点と始点を結ぶ)を部品として持つ物体を作成します。 More... | |
P2Body | createCircle (P2BodyType bodyType, const Vec2 &worldPos, double r, const P2Material &material={}, const P2Filter &filter={}) |
円を部品として持つ物体を作成します。 More... | |
P2Body | createCircle (P2BodyType bodyType, const Vec2 &worldPos, const Circle &localPos, const P2Material &material={}, const P2Filter &filter={}) |
円を部品として持つ物体を作成します。 More... | |
P2Body | createCircleSensor (P2BodyType bodyType, const Vec2 &worldPos, double r, const P2Filter &filter={}) |
円形のセンサー部品を持つ物体を作成します。 More... | |
P2Body | createRect (P2BodyType bodyType, const Vec2 &worldPos, double size, const P2Material &material={}, const P2Filter &filter={}) |
正方形を部品として持つ物体を作成します。 More... | |
P2Body | createRect (P2BodyType bodyType, const Vec2 &worldPos, const SizeF &size, const P2Material &material={}, const P2Filter &filter={}) |
長方形を部品として持つ物体を作成します。 More... | |
P2Body | createRect (P2BodyType bodyType, const Vec2 &worldPos, const RectF &localPos, const P2Material &material={}, const P2Filter &filter={}) |
長方形を部品として持つ物体を作成します。 More... | |
P2Body | createTriangle (P2BodyType bodyType, const Vec2 &worldPos, const Triangle &localPos, const P2Material &material={}, const P2Filter &filter={}) |
三角形を部品として持つ物体を作成します。 More... | |
P2Body | createQuad (P2BodyType bodyType, const Vec2 &worldPos, const Quad &localPos, const P2Material &material={}, const P2Filter &filter={}) |
凸な四角形を部品として持つ物体を作成します。 More... | |
P2Body | createPolygon (P2BodyType bodyType, const Vec2 &worldPos, const Polygon &localPos, const P2Material &material={}, const P2Filter &filter={}) |
多角形を部品として持つ物体を作成します。 More... | |
P2Body | createPolygons (P2BodyType bodyType, const Vec2 &worldPos, const MultiPolygon &localPos, const P2Material &material={}, const P2Filter &filter={}) |
複数の多角形を部品として持つ物体を作成します。 More... | |
P2PivotJoint | createPivotJoint (const P2Body &bodyA, const P2Body &bodyB, const Vec2 &worldAnchorPos, EnableCollision enableCollision=EnableCollision::No) |
回転ジョイントを作成します。 More... | |
P2DistanceJoint | createDistanceJoint (const P2Body &bodyA, const Vec2 &worldAnchorPosA, const P2Body &bodyB, const Vec2 &worldAnchorPosB, double length, EnableCollision enableCollision=EnableCollision::No) |
距離ジョイントを作成します。 More... | |
P2SliderJoint | createSliderJoint (const P2Body &bodyA, const P2Body &bodyB, const Vec2 &worldAnchorPos, const Vec2 &normalizedAxis, EnableCollision enableCollision=EnableCollision::No) |
スライダージョイントを作成します。 More... | |
P2WheelJoint | createWheelJoint (const P2Body &bodyA, const P2Body &bodyB, const Vec2 &worldAnchorPos, const Vec2 &normalizedAxis, EnableCollision enableCollision=EnableCollision::No) |
ホイールジョイントを作成します。 More... | |
P2MouseJoint | createMouseJoint (const P2Body &body, const Vec2 &worldTargetPos) |
マウスジョイントを作成します。 More... | |
const HashTable< P2ContactPair, P2Collision > & | getCollisions () const noexcept |
物体の接触情報の一覧を返します。 More... | |
2D 物理演算を行うワールド
|
explicit |
2D 物理演算を行うワールドを作成します。
gravity | 重力加速度 (cm/s^2) |
|
explicit |
2D 物理演算を行うワールドを作成します。
gravity | 重力加速度のベクトル (cm/s^2) |
P2Body s3d::P2World::createCircle | ( | P2BodyType | bodyType, |
const Vec2 & | worldPos, | ||
const Circle & | localPos, | ||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
円を部品として持つ物体を作成します。
P2Circle
の部品を持ちます。 bodyType | 物体の種類 |
worldPos | 物体のワールド座標 (cm) |
localPos | worldPos から見たローカルでの形状の座標 (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body s3d::P2World::createCircle | ( | P2BodyType | bodyType, |
const Vec2 & | worldPos, | ||
double | r, | ||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
円を部品として持つ物体を作成します。
P2Circle
の部品を持ちます。 worldPos
です。 bodyType | 物体の種類 |
worldPos | 物体のワールド座標 (cm) |
r | 円形の部品の半径 (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body s3d::P2World::createCircleSensor | ( | P2BodyType | bodyType, |
const Vec2 & | worldPos, | ||
double | r, | ||
const P2Filter & | filter = {} |
||
) |
円形のセンサー部品を持つ物体を作成します。
P2Circle
の部品を持ちます。 bodyType | 物体の種類 |
worldPos | 物体のワールド座標 (cm) |
r | センサーの半径 (cm) |
filter | センサーの干渉フィルタ |
P2Body s3d::P2World::createClosedLineString | ( | P2BodyType | bodyType, |
const Vec2 & | worldPos, | ||
const LineString & | localPos, | ||
OneSided | oneSided = OneSided::No , |
||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
連続する複数の線分(終点と始点を結ぶ)を部品として持つ物体を作成します。
P2LineString
の部品を持ちます。 bodyType | 物体の種類(P2BodyType::Dynamic は指定不可) |
worldPos | 物体のワールド座標 (cm) |
localPos | worldPos から見たローカルでの形状の座標 (cm) |
oneSided | 線分の片側(右に向かうときの上側)のみ干渉するか |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2DistanceJoint s3d::P2World::createDistanceJoint | ( | const P2Body & | bodyA, |
const Vec2 & | worldAnchorPosA, | ||
const P2Body & | bodyB, | ||
const Vec2 & | worldAnchorPosB, | ||
double | length, | ||
EnableCollision | enableCollision = EnableCollision::No |
||
) |
距離ジョイントを作成します。
bodyA | 接続する物体 A |
worldAnchorPosA | 物体 A のジョイントのワールド座標 (cm) |
bodyB | 接続する物体 B |
worldAnchorPosB | 物体 B のジョイントのワールド座標 (cm) |
length | ジョイントの静止長 (cm) |
enableCollision | 接続した物体どうしの衝突を有効にするか |
P2Body s3d::P2World::createLine | ( | P2BodyType | bodyType, |
const Vec2 & | worldPos, | ||
const Line & | localPos, | ||
OneSided | oneSided = OneSided::No , |
||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
線分を部品として持つ物体を作成します。
P2Line
の部品を持ちます。 bodyType | 物体の種類(P2BodyType::Dynamic は指定不可) |
worldPos | 物体のワールド座標 (cm) |
localPos | worldPos から見たローカルでの形状の座標 (cm) |
oneSided | 線分の片側(右に向かうときの上側)のみ干渉するか |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body s3d::P2World::createLineString | ( | P2BodyType | bodyType, |
const Vec2 & | worldPos, | ||
const LineString & | localPos, | ||
OneSided | oneSided = OneSided::No , |
||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
連続する複数の線分を部品として持つ物体を作成します。
P2LineString
の部品を持ちます。 bodyType | 物体の種類(P2BodyType::Dynamic は指定不可) |
worldPos | 物体のワールド座標 (cm) |
localPos | worldPos から見たローカルでの形状の座標 (cm) |
oneSided | 線分の片側(右に向かうときの上側)のみ干渉するか |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2MouseJoint s3d::P2World::createMouseJoint | ( | const P2Body & | body, |
const Vec2 & | worldTargetPos | ||
) |
マウスジョイントを作成します。
body | 接続する物体 |
worldTargetPos | ターゲットのワールド座標 (cm) |
P2PivotJoint s3d::P2World::createPivotJoint | ( | const P2Body & | bodyA, |
const P2Body & | bodyB, | ||
const Vec2 & | worldAnchorPos, | ||
EnableCollision | enableCollision = EnableCollision::No |
||
) |
回転ジョイントを作成します。
bodyA | 接続する物体 |
bodyB | 接続する物体 |
worldAnchorPos | ジョイントのワールド座標 (cm) |
enableCollision | 接続した物体どうしの衝突を有効にするか |
P2Body s3d::P2World::createPlaceholder | ( | P2BodyType | bodyType, |
const Vec2 & | worldPos | ||
) |
プレースホルダーとなる物体を作成します。
bodyType | 物体の種類 |
worldPos | 物体のワールド座標 |
P2Body s3d::P2World::createPolygon | ( | P2BodyType | bodyType, |
const Vec2 & | worldPos, | ||
const Polygon & | localPos, | ||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
多角形を部品として持つ物体を作成します。
P2Polygon
の部品を持ちます。 bodyType | 物体の種類 |
worldPos | 物体のワールド座標 (cm) |
localPos | worldPos から見たローカルでの形状の座標 (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body s3d::P2World::createPolygons | ( | P2BodyType | bodyType, |
const Vec2 & | worldPos, | ||
const MultiPolygon & | localPos, | ||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
複数の多角形を部品として持つ物体を作成します。
P2Polygon
の部品を持ちます。 bodyType | 物体の種類 |
worldPos | 物体のワールド座標 (cm) |
localPos | worldPos から見たローカルでの形状の座標 (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body s3d::P2World::createQuad | ( | P2BodyType | bodyType, |
const Vec2 & | worldPos, | ||
const Quad & | localPos, | ||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
凸な四角形を部品として持つ物体を作成します。
P2Quad
の部品を持ちます。 bodyType | 物体の種類 |
worldPos | 物体のワールド座標 (cm) |
localPos | worldPos から見たローカルでの形状の座標 (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body s3d::P2World::createRect | ( | P2BodyType | bodyType, |
const Vec2 & | worldPos, | ||
const RectF & | localPos, | ||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
長方形を部品として持つ物体を作成します。
P2Rect
の部品を持ちます。 bodyType | 物体の種類 |
worldPos | 物体のワールド座標 (cm) |
localPos | worldPos から見たローカルでの形状の座標 (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body s3d::P2World::createRect | ( | P2BodyType | bodyType, |
const Vec2 & | worldPos, | ||
const SizeF & | size, | ||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
長方形を部品として持つ物体を作成します。
P2Rect
の部品を持ちます。 worldPos
です。 bodyType | 物体の種類 |
worldPos | 物体のワールド座標 (cm) |
size | 長方形の幅と高さ (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2Body s3d::P2World::createRect | ( | P2BodyType | bodyType, |
const Vec2 & | worldPos, | ||
double | size, | ||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
正方形を部品として持つ物体を作成します。
P2Rect
の部品を持ちます。 worldPos
です。 bodyType | 物体の種類 |
worldPos | 物体のワールド座標 (cm) |
size | 正方形の一辺の長さ (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2SliderJoint s3d::P2World::createSliderJoint | ( | const P2Body & | bodyA, |
const P2Body & | bodyB, | ||
const Vec2 & | worldAnchorPos, | ||
const Vec2 & | normalizedAxis, | ||
EnableCollision | enableCollision = EnableCollision::No |
||
) |
スライダージョイントを作成します。
bodyA | 接続する物体 A |
bodyB | 接続する物体 B |
worldAnchorPos | ジョイントのワールド座標 (cm) |
normalizedAxis | スライダーの方向の単位ベクトル |
enableCollision | 接続した物体どうしの衝突を有効にするか |
P2Body s3d::P2World::createTriangle | ( | P2BodyType | bodyType, |
const Vec2 & | worldPos, | ||
const Triangle & | localPos, | ||
const P2Material & | material = {} , |
||
const P2Filter & | filter = {} |
||
) |
三角形を部品として持つ物体を作成します。
P2Triangle
の部品を持ちます。 bodyType | 物体の種類 |
worldPos | 物体のワールド座標 (cm) |
localPos | worldPos から見たローカルでの形状の座標 (cm) |
material | 部品の材質 |
filter | 部品の干渉フィルタ |
P2WheelJoint s3d::P2World::createWheelJoint | ( | const P2Body & | bodyA, |
const P2Body & | bodyB, | ||
const Vec2 & | worldAnchorPos, | ||
const Vec2 & | normalizedAxis, | ||
EnableCollision | enableCollision = EnableCollision::No |
||
) |
ホイールジョイントを作成します。
bodyA | 接続する物体 A |
bodyB | 接続する物体 B |
worldAnchorPos | ジョイントのワールド座標 (cm) |
normalizedAxis | 軸の方向の単位ベクトル |
enableCollision | 接続した物体どうしの衝突を有効にするか |
|
noexcept |
物体の接触情報の一覧を返します。
Vec2 s3d::P2World::getGravity | ( | ) | const |
現在の重力加速度の設定を返します。
bool s3d::P2World::getSleepEnabled | ( | ) | const |
ワールド内の物体がスリープ状態になることを許可しているかの現在の設定を返します。
void s3d::P2World::setGravity | ( | const Vec2 & | gravity | ) |
重力加速度 (cm/s^2) を設定します。
gravity | 重力加速度のベクトル (cm/s^2) |
void s3d::P2World::setGravity | ( | double | gravity | ) |
重力加速度 (cm/s^2) を設定します。
setGravity(Vec2{ 0, gravity })
と同じです。 gravity | 重力加速度 (cm/s^2) |
void s3d::P2World::setSleepEnabled | ( | bool | enabled | ) |
ワールド内の物体がスリープ状態になることを許可・不許可を設定します(デフォルトでは許可)。
enabled | 許可する場合 true, 許可しない場合 false |
void s3d::P2World::shiftOrigin | ( | const Vec2 & | newOrigin | ) |
ワールドの物体全ての座標 (cm) をシフトします。
newOrigin | シフト量 (cm) |
void s3d::P2World::update | ( | double | timeStep = Scene::DeltaTime() , |
int32 | velocityIterations = 6 , |
||
int32 | positionIterations = 2 |
||
) | const |
2D 物理演算のワールドの状態を更新します。
timeStep | タイムステップ(秒) |
velocityIterations | 物体の衝突時の速度の補正の回数 |
positionIterations | 物体の衝突時の位置の補正の回数 |