本文整理汇总了C++中Matrix34::rotateX方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix34::rotateX方法的具体用法?C++ Matrix34::rotateX怎么用?C++ Matrix34::rotateX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix34
的用法示例。
在下文中一共展示了Matrix34::rotateX方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void Node::draw(
const Matrix44& pvm,
const Matrix34& parentWm,
const Vector3& lightVector,
const Vector3& lightColor,
const Vector3& ambient ) const {
Matrix34 wm;
wm.setTranslation( mTranslation );
wm.rotateY( mRotation.y );
wm.rotateX( mRotation.x );
wm.rotateZ( mRotation.z );
wm.scale( mScale );
wm.setMul( parentWm, wm );
if ( mBatch ){
mBatch->draw(
pvm,
wm,
lightVector,
lightColor,
ambient,
mColor );
}
//子へ受け継ぐ
for ( int i = 0; i < mChildNumber; ++i ){
ASSERT( mChildren[ i ] ); //0が入ってたら異常。
mChildren[ i ]->draw(
pvm,
wm,
lightVector,
lightColor,
ambient );
}
}
示例2: update
void Bullet::update( const Vector3& enemyPos ){
//敵の方に向ける。
Vector3 dir;
Vector3 p = *mModel->getPosition();
Vector3 a = *mModel->getAngle();
if ( mHoming ){
dir.setSub( enemyPos, *mModel->getPosition() ); //自分から敵へ
//Y軸角度はatan2( x, z )。
float ty = atan2( dir.x, dir.z );
//180度以上差があれば+-360度して逆回し
if ( ty - a.y > 180.f ){
ty -= 2.f * 180.f;
}else if ( a.y - ty > 180.f ){
ty += 2.f * 180.f;
}
//X軸角度はY/(X,Z)。
float zxLength = sqrt( dir.x * dir.x + dir.z * dir.z );
float tx = atan2( dir.y, zxLength );
//X軸角度はそもそも範囲が(-90,90)で180度以上離れることはない。そのままで良い。
float hx = mHomingX;
float hy = mHomingY;
//ホーミング範囲内ならそのものに
if ( tx - a.x < hx && a.x - tx < hx ){
a.x = tx;
}else if ( tx < a.x ){
a.x -= hx;
}else{
a.x += hx;
}
if ( ty - a.y < hy && a.y - ty < hy ){
a.y = ty;
}else if ( ty < a.y ){
a.y -= hy;
}else{
a.y += hy;
}
}
//おもろいのでz回転つけとくか
a.z += 20.0;
//角度更新
mModel->setAngle( a );
//位置はこの方向の回転行列で(0,0,1)を変換して足してやる
Vector3 v( 0.0, 0.0, mSpeed );
Matrix34 m;
m.setRotationY( a.y );
m.rotateX( -a.x );
m.mul( &v, v );
p += v;
mModel->setPosition( p );
++mCount;
if ( mCount >= mLife ){
mCount = -1;
}
}
示例3: draw
void Model::draw() const {
Matrix34 wm;
wm.setTranslation( mPosition );
wm.rotateY( mAngle.y );
wm.rotateX( mAngle.x );
wm.rotateZ( mAngle.z );
wm.scale( mScale );
GameLib::Graphics::Manager::instance().setWorldMatrix( wm );
mBatch->draw();
}
示例4: draw
void Model::draw( const Matrix44& pvm ) const {
Matrix34 wm;
wm.setTranslation( mPosition );
wm.rotateY( mAngle.y );
wm.rotateX( mAngle.x );
wm.rotateZ( mAngle.z );
wm.scale( mScale );
Matrix44 transform;
transform.setMul( pvm, wm );
mBatch->draw( transform );
}
示例5: draw
void Tree::draw(
const Matrix44& pvm,
const Vector3& lightVector,
const Vector3& lightColor,
const Vector3& ambient ) const {
Matrix34 wm;
wm.setTranslation( mPosition );
wm.rotateY( mAngle.y );
wm.rotateX( mAngle.x );
wm.rotateZ( mAngle.z );
wm.scale( mScale );
//根ノードへ渡す
if ( mNodes ){
mNodes[ 0 ].draw(
pvm,
wm,
lightVector,
lightColor,
ambient );
}
}
示例6: update
void Framework::update(){
WindowCreator wc = WindowCreator::instance();
if ( gFirst ){
const char* filename = wc.commandLineString();
if ( filename && filename[ 0 ] != '\0' ){
load( filename );
}
gFirst = false;
}else{
//ドラッグアンドドロップを処理する
int dropN = wc.droppedItemNumber();
if ( dropN > 0 ){
const char* filename = wc.droppedItem( 0 ); //0番以外無視
load( filename );
wc.clearDroppedItem(); //これを呼ぶとfilenameもこわれるので最後に。
}
}
//カメラ入力反映
Input::Manager im = Input::Manager::instance();
Input::Mouse mouse = im.mouse();
Input::Keyboard keyboard = im.keyboard();
if ( mouse.isOn( Input::Mouse::BUTTON_MIDDLE ) ){
Graphics::Manager().captureScreen( "capture.tga" );
}
//ビュー行列を作ろう
Vector3 eyePosition = gEyeTarget;
eyePosition.z += gEyeDistance;
Matrix34 rm;
rm.setRotationY( gAngleY );
rm.rotateX( gAngleX );
Vector3 tv( 0.f, 0.f, 1.f );
rm.mul( &tv, tv );
eyePosition.setMadd( gEyeTarget, tv, gEyeDistance );
Matrix34 zrm;
zrm.setRotationZ( gAngleZ );
Vector3 up( 0.f, 1.f, 0.f );
zrm.mul( &up, up );
Matrix34 vm;
vm.setViewTransform( eyePosition, gEyeTarget, up );
if ( gContainer ){
float x = static_cast< float >( mouse.velocityX() );
float y = static_cast< float >( mouse.velocityY() );
if ( mouse.isOn( Input::Mouse::BUTTON_LEFT ) && mouse.isOn( Input::Mouse::BUTTON_RIGHT ) ){ //両ボタンでZ回転
gAngleZ -= 0.2f * x;
gAngleZ -= 0.2f * y;
}else if ( mouse.isOn( Input::Mouse::BUTTON_LEFT ) ){ //左ボタン回転
gAngleX -= 0.2f * y;
if ( gAngleX > 89.9f ){
gAngleX = 89.9f;
}else if ( gAngleX < -89.9f ){
gAngleX = -89.9f;
}
gAngleY -= 0.5f * x;
}else if ( mouse.isOn( Input::Mouse::BUTTON_RIGHT ) ){ //右ボタン、注視点移動
Vector3 xv( vm.m00, vm.m01, vm.m02 );
xv *= x;
Vector3 yv( vm.m10, vm.m11, vm.m12 );
yv *= y;
gEyeTarget.madd( xv, -0.003f * gEyeDistance );
gEyeTarget.madd( yv, 0.003f * gEyeDistance );
}
int w = mouse.wheel();
if ( w < 0 ){
gEyeDistance *= 0.9f;
}else if ( w > 0 ){
gEyeDistance *= 1.1f;
}
}
//透視変換行列
Matrix44 pm;
pm.setPerspectiveTransform(
60.f,
static_cast< float >( width() ),
static_cast< float >( height() ),
gEyeDistance * 0.01f, gEyeDistance * 10.f );
//次にPVを作る
pm *= vm;
if ( keyboard.isOn( 'G' ) ){
gAngleX = gAngleY = gAngleZ = 0.f;
gEyeTarget = 0.f;
}
//ライトでもうごかそか
Graphics::Manager gm = Graphics::Manager::instance();
gm.setProjectionViewMatrix( pm );
gm.setLightingMode( LIGHTING_PER_PIXEL );
gm.enableDepthTest( true );
gm.enableDepthWrite( true );
gm.setLightColor( 0, Vector3( 1.f, 1.f, 1.f ) ); //白
gm.setLightColor( 1, Vector3( 1.f, 0.7f, 0.7f ) ); //赤
gm.setLightColor( 2, Vector3( 0.7f, 1.f, 0.7f ) ); //緑
gm.setLightColor( 3, Vector3( 0.7f, 0.7f, 1.f ) ); //青
gm.setAmbientColor( Vector3( 0.2f, 0.2f, 0.2f ) );
gm.setEyePosition( eyePosition );
float t = gEyeDistance * 0.4f;
//.........这里部分代码省略.........