Beispiel #1
0
// If the dragger is to detect for collision between the moving object
// and the rest of the world, set up the appropriate collision models.
void IvObjectDragger::CheckCollision(bool flag)
{
    _checkCollision = flag;
    ItemPtr selectedItem = GetSelectedItem();
    if (_checkCollision && !!selectedItem) {
        // synchronize the collision model transform
        KinBodyItemPtr pbody = boost::dynamic_pointer_cast<KinBodyItem>(selectedItem);
        if( !!pbody ) {
            EnvironmentMutex::scoped_try_lock lock(_penv->GetMutex());
            if( !!lock ) {
                int prevoptions = _penv->GetCollisionChecker()->GetCollisionOptions();
                _penv->GetCollisionChecker()->SetCollisionOptions(CO_Contacts);
                CollisionReportPtr preport(new CollisionReport());
                if( pbody->GetBody()->CheckSelfCollision(preport) ) {
                    RAVELOG_VERBOSE(str(boost::format("self-collision %s\n")%preport->__str__()));
                    _SetColor(COLLISION_COLOR);
                }
                else if( _penv->CheckCollision(KinBodyConstPtr(pbody->GetBody()), preport)) {
                    // if there is a collision, revert to the original transform
                    RAVELOG_VERBOSE(str(boost::format("collision %s\n")%preport->__str__()));
                    _SetColor(COLLISION_COLOR);
                }
                else {
                    _SetColor(CHECK_COLOR);
                }
                _penv->GetCollisionChecker()->SetCollisionOptions(prevoptions);
            }
        }
    }
}
Beispiel #2
0
IvJointDragger::~IvJointDragger()
{
    _SetColor(_normalColor);
    if( _trackball != NULL )
        _trackball->removeMotionCallback(_MotionHandler, this);
    if( _pLinkNode != NULL ) {
        if(_draggerRoot != NULL )
            _pLinkNode->removeChild(_draggerRoot);
        if (_bHilitJoint)
            _pLinkNode->removeChild(_material);
    }
}
Beispiel #3
0
IvObjectDragger::~IvObjectDragger()
{
    _SetColor(_normalColor);

    _transformBox->removeMotionCallback(_MotionHandler, this);
    if( _draggerRoot != NULL ) {
        ItemPtr selectedItem = GetSelectedItem();
        if( !!selectedItem ) {
            selectedItem->GetIvRoot()->removeChild(_draggerRoot);
        }
    }
}
Beispiel #4
0
/*!
@brief テクスチャの描画
@par   関数説明
テクスチャを描画する。始点は中央。
@param txnum テクスチャ番号。
@param dx 描画x座標。
@param dy 描画y座標。
@param rx 読み込みx座標。
@param ry 読み込みy座標。
@param w 読み込み幅。
@param h 読み込み高さ。
@return 0=成功。
@return 1=テクスチャ番号が不正。
@return 2=テクスチャがない。
@return 3=テクスチャセットに失敗。
@return 4=テクスチャ設定に失敗。
@return 5=頂点ストリームの設定に失敗。
@return 6=レンダリングに失敗。
*/
int DirectXDraw9::DrawTextureC( unsigned int txnum, int dx, int dy, int rx, int ry, int w, int h, int flag )
{
	if ( txnum >= texmax )//if( txnum >= texmax )
	{
		//テクスチャ番号が不正
		return 1;
	}

	_SetUV( (float)dxtex[ txnum ].width, (float)dxtex[ txnum ].height, rx, ry, w, h, flag );
	_SetColor( dxtex[ txnum ].vcolor );
	_DrawTextureC( (float)dx, (float)dy, (float)w, (float)h );
	return EndDrawTexture( dxtex[ txnum ].tex );
}
Beispiel #5
0
//テクスチャの4点を相対座標で自由に決めて描画する
int DirectXDraw9::DrawTextureRelativeVertex( unsigned int txnum, int rx, int ry, int w, int h, double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, int flag )
{
	if ( txnum >= texmax )
	{
		//テクスチャ番号が不正
		return 1;
	}

	_SetUV( (float)dxtex[ txnum ].width, (float)dxtex[ txnum ].height, rx, ry, w, h, flag );
	_SetColor( dxtex[ txnum ].vcolor );
	_DrawTextureVertex( (float)x0, (float)y0, (float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3 );
	return EndDrawTexture( dxtex[ txnum ].tex );
}
Beispiel #6
0
//テクスチャを回転拡大描画する
int DirectXDraw9::DrawTextureRotateScaleAngleC( unsigned int txnum, int dx, int dy, int rx, int ry, int w, int h, int sw, int sh, double angle, int flag )
{
	if ( txnum >= texmax )
	{
		//テクスチャ番号が不正
		return 1;
	}

	_SetUV( (float)dxtex[ txnum ].width, (float)dxtex[ txnum ].height, rx, ry, w, h, flag );
	_SetColor( dxtex[ txnum ].vcolor );
	_DrawTextureRotateScale( (float)( sw * 0.5 ), (float)( sh * 0.5 ), (float)dx, (float)dy, AngleToRadian( angle ), (float)sw, (float)sh );
	return EndDrawTexture( dxtex[ txnum ].tex );
}
Beispiel #7
0
//テクスチャを回転拡大描画する
int DirectXDraw9::DrawTextureRotateScaleC( unsigned int txnum, int dx, int dy, int rx, int ry, int w, int h, double scale, double rad, int flag )
{
	if ( txnum >= texmax )
	{
		//テクスチャ番号が不正
		return 1;
	}

	_SetUV( (float)dxtex[ txnum ].width, (float)dxtex[ txnum ].height, rx, ry, w, h, flag );
	_SetColor( dxtex[ txnum ].vcolor );
	_DrawTextureRotateScale( (float)( w * scale * 0.5 ), (float)( h * scale * 0.5 ), (float)dx, (float)dy, rad, (float)( w * scale ), (float)( h * scale ) );
	return EndDrawTexture( dxtex[ txnum ].tex );
}
Beispiel #8
0
// テクスチャを回転拡大描画する
int DirectXDraw9::DrawTextureRotateScale( unsigned int txnum, int dx, int dy, int rx, int ry, int w, int h, int cx, int cy, int dw, int dh, double rad, int drawflag )
{
	if ( txnum >= texmax )
	{
		//テクスチャ番号が不正
		return 1;
	}

	_SetUV( (float)dxtex[ txnum ].width, (float)dxtex[ txnum ].height, rx, ry, w, h, drawflag );
	_SetColor( dxtex[ txnum ].vcolor );
	_DrawTextureRotateScale( (float)cx, (float)cy, (float)dx, (float)dy, rad, (float)dw, (float)dh );
	return EndDrawTexture( dxtex[ txnum ].tex );
}
Beispiel #9
0
// Set up collision models for the moving subtree of nodes and the rest of the world.
void IvJointDragger::CheckCollision(bool flag)
{
    _checkCollision = flag;
    ItemPtr selectedItem = GetSelectedItem();
    if (_checkCollision && !!selectedItem) {
        KinBodyItemPtr pbody = boost::dynamic_pointer_cast<KinBodyItem>(selectedItem);

        if( !!pbody ) {
            EnvironmentMutex::scoped_try_lock lock(_penv->GetMutex());
            if( !!lock ) {
                int prevoptions = _penv->GetCollisionChecker()->GetCollisionOptions();
                _penv->GetCollisionChecker()->SetCollisionOptions(CO_Contacts);
                if (_penv->CheckCollision(KinBodyConstPtr(pbody->GetBody())) || pbody->GetBody()->CheckSelfCollision()) {
                    _SetColor(COLLISION_COLOR);
                }
                else {
                    _SetColor(CHECK_COLOR);
                }
                _penv->GetCollisionChecker()->SetCollisionOptions(prevoptions);
            }
        }
    }
}
Beispiel #10
0
void _HYGraphicPane::SetColor  (_HYColor c)
{
	color = c;
	_SetColor (c);
}