ここで設定した色とテクスチャが、その後のdsDrawXx()関数での描画に適用されます。なおシミュレーションのステップごとに描画色は白、テクスチャは無効に再設定されます。
オブジェクトの描画色を設定します。
void dsSetColor ( float red, float green, float blue );
赤 (red)、緑 (green)、青 (blue) の3色を0.0~1.0の範囲で指定します。
void dsSetColorAlpha ( float red, float green, float blue, float alpha );
alphaは不透明度で、1.0で完全に不透明、0.0で完全に透明となります。
void dsSetTexture ( int texture_number );
texture_numberには、以下の定数から指定します。またテクスチャは現在の描画色に応じて着色されます。
enum DS_TEXTURE_NUMBER
{
DS_NONE = 0,
DS_WOOD,
DS_CHECKERED,
DS_GROUND,
DS_SKY,
};
void dsSetDrawMode ( int mode );
ポリゴンかワイヤーフレームのいずれで描画するかを指定します。指定には次の定数を使用します。
#define DS_POLYFILL 0 #define DS_WIREFRAME 1
void dsSetSphereQuality ( int n ); // 既定値=1
void dsSetCapsuleQuality ( int n ); // 既定値=3
曲面を持つオブジェクト (球とカプセル) の描画品質を設定します。品質を上げると描画速度が低下します。
| 種類 | 関数 |
|---|---|
球体 (Sphere)![]() |
void dsDrawSphere (
const float pos[ 3 ], // 中心の座標
const float R[ 12 ], // 姿勢
float radius // 半径
);
|
直方体 (Box)![]() |
void dsDrawBox (
const float pos[ 3 ], // 中心の座標
const float R[ 12 ], // 姿勢
const float sides[ 3 ] // 側面の長さ
);
|
カプセル (Capsule)![]() |
void dsDrawCapsule (
const float pos[ 3 ], // 中心の座標
const float R[ 12 ], // 姿勢
float length, // 長さ
float radius // 半径
);
|
円柱 (Cylinder)![]() |
void dsDrawCylinder (
const float pos[ 3 ], // 中心の座標
const float R[ 12 ], // 姿勢
float length, // 長さ
float radius // 半径
);
|
| 線 (Line) |
void dsDrawLine (
const float pos1[ 3 ], //
const float pos2[ 3 ] //
);
|
| 三角形 (Triangle) |
void dsDrawTriangle (
const float pos[ 3 ], // 中心の座標
const float R[ 12 ], // 姿勢
const float *v0, // 1番目の頂点
const float *v1, // 2番目の頂点
const float *v2, // 3番目の頂点
int solid // (0:ワイヤーフレームで描画)
);
|
| 凸形状 (Convex) |
void dsDrawConvex(
const float pos[ 3 ], // 中心の座標
const float R[ 12 ], // 姿勢
float *_planes, //
unsigned int _planecount, //
float *_points, //
unsigned int _pointcount, //
unsigned int *_polygons //
);
|
引数posはx、y、zでオブジェクトの中心を指定します。引数Rは、
| [ | R11 | R12 | R13 | 0 | ] |
| [ | R21 | R22 | R23 | 0 | ] |
| [ | R31 | R32 | R33 | 0 | ] |
のように配置された回転行列で、オブジェクトの姿勢を指定します。
倍精度で演算を行う場合のために、上記関数のfloat型の引数をdouble型に置き換えた関数が用意されています。
void dsDrawSphereD ( const double pos[3], const double R[12], const float radius ); void dsDrawBoxD ( const double pos[3], const double R[12], const double sides[3] ); void dsDrawCapsuleD ( const double pos[3], const double R[12], float length, float radius ); void dsDrawCylinderD ( const double pos[3], const double R[12], float length, float radius ); void dsDrawLineD ( const double pos1[3], const double pos2[3] ); void dsDrawTriangleD ( const double pos[3], const double R[12], const double *v0, const double *v1, const double *v2, int solid ); void dsDrawConvexD( const double pos[3], const double R[12], double *_planes, unsigned int _planecount, double *_points, unsigned int _pointcount, unsigned int *_polygons );
void dsSetViewpoint (
float xyz[ 3 ], // カメラの位置 (x, y, x)
float hpr[ 3 ] // カメラの方向 (heading, pitch, roll)
);
void dsGetViewpoint (
float xyz[ 3 ], // カメラの位置 (x, y, x)
float hpr[ 3 ] // カメラの方向 (heading, pitch, roll)
);