コード例 #1
0
void PlayerObject::draw() {
	if (light >= 0) {
		GLfloat position[4];
		position[0] = getLocationX();
		position[1] = 3;
		position[2] = getLocationZ();
		position[3] = 1;
		glLightfv(light, GL_POSITION, position);
	}
	((Object*)this)->draw();
}
コード例 #2
0
ファイル: Cylinder.cpp プロジェクト: neilforrest/protohaptic
void CCylinder::drawHapticScene(bool primary_context)
{
	hlMaterialf(HL_FRONT_AND_BACK, HL_STIFFNESS, m_stiffness);
	hlMaterialf(HL_FRONT_AND_BACK, HL_DAMPING, m_dampening);
	hlMaterialf(HL_FRONT_AND_BACK, HL_STATIC_FRICTION, m_static_friction);
	hlMaterialf(HL_FRONT_AND_BACK, HL_DYNAMIC_FRICTION, m_dynamic_friction);

	if ( !m_customRendered )
	{
		if(primary_context)
			hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, m_shapeID);
		else
			hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, m_shapeID_1);

		drawGLScene();
		hlEndShape();
	}
	else
	{
		// Draw cylinder section
		if(primary_context)
			hlBeginShape(HL_SHAPE_CALLBACK, m_shapeID );
		else
			hlBeginShape(HL_SHAPE_CALLBACK, m_shapeID_1 );

		hlCallback(HL_SHAPE_INTERSECT_LS, 
			(HLcallbackProc) CHapticCylinder::intersectSurface, (void *) customCylinder);
		hlCallback(HL_SHAPE_CLOSEST_FEATURES, 
			(HLcallbackProc) CHapticCylinder::closestSurfaceFeatures, (void *) customCylinder);
		hlEndShape();

		// Draw disk A
		if(primary_context)
			hlBeginShape(HL_SHAPE_CALLBACK, diskAShape->GetShapeID () );
		else
			hlBeginShape(HL_SHAPE_CALLBACK, diskAShape->GetShapeID_1 ());

		diskATrans->makeIdentity ();

		diskATrans->multRight ( hduMatrix::createRotation ( 1, 0, 0, 0.5*PI ) );
		diskATrans->multRight ( hduMatrix::createTranslation ( 0, 0, 0.5 ) );

		diskATrans->multRight ( hduMatrix::createScale ( getSizeX(), getSizeY(), getSizeZ() ) );
		diskATrans->multRight ( getHduMatrix ( getRotation () ) );
		diskATrans->multRight ( hduMatrix::createTranslation ( getLocationX(), getLocationY(), getLocationZ () ) );

		hlCallback(HL_SHAPE_INTERSECT_LS, 
			(HLcallbackProc) CHapticDisk::intersectSurface, (void *) diskA);
		hlCallback(HL_SHAPE_CLOSEST_FEATURES, 
			(HLcallbackProc) CHapticDisk::closestSurfaceFeatures, (void *) diskA);
		hlEndShape();

		// Draw disk B
		if(primary_context)
			hlBeginShape(HL_SHAPE_CALLBACK, diskBShape->GetShapeID () );
		else
			hlBeginShape(HL_SHAPE_CALLBACK, diskBShape->GetShapeID_1 ());

		diskBTrans->makeIdentity ();

		diskBTrans->multRight ( hduMatrix::createRotation ( 1, 0, 0, -0.5*PI ) );
		diskBTrans->multRight ( hduMatrix::createTranslation ( 0, 0, -0.5 ) );

		diskBTrans->multRight ( hduMatrix::createScale ( getSizeX(), getSizeY(), getSizeZ() ) );
		diskBTrans->multRight ( getHduMatrix ( getRotation () ) );
		diskBTrans->multRight ( hduMatrix::createTranslation ( getLocationX(), getLocationY(), getLocationZ () ) );

		hlCallback(HL_SHAPE_INTERSECT_LS, 
			(HLcallbackProc) CHapticDisk::intersectSurface, (void *) diskB);
		hlCallback(HL_SHAPE_CLOSEST_FEATURES, 
			(HLcallbackProc) CHapticDisk::closestSurfaceFeatures, (void *) diskB);
		hlEndShape();
	}

}