CollisionBoxComponent::CollisionBoxComponent(GameObject& aGameObject, eCollisionGroup aCollisionGroup, const Vector2<float>& someDimensions) : CollisionComponent(aGameObject, aCollisionGroup)
{
	myDimensions = someDimensions;
	Line<float> aLine;

	Vector2<float> position1(-myDimensions.myX / 2, -myDimensions.myY / 2);
	Vector2<float> position2(-myDimensions.myX / 2, myDimensions.myY / 2);
	Vector2<float> position3(myDimensions.myX / 2, myDimensions.myY / 2);
	Vector2<float> position4(myDimensions.myX / 2, -myDimensions.myY / 2);

	aLine.InitWith2Points(position1, position2);
	myLineVolume.AddLine(aLine);

	aLine.InitWith2Points(position2, position3);
	myLineVolume.AddLine(aLine);

	aLine.InitWith2Points(position3, position4);
	myLineVolume.AddLine(aLine);

	aLine.InitWith2Points(position4, position1);
	myLineVolume.AddLine(aLine);

	myParent->SetValue<CollisionBoxComponent*>("CollisionBoxComponent", this);
	//mySprite = ResourceManager::GetInstance()->GetSprite("../Data/Gfx/debugBox.png", { someDimensions.x, someDimensions.y }, { someDimensions.x / 2.f, someDimensions.y / 2.f });
}
示例#2
0
/* Find some moves for the board; starts with a simple approach (finding
 * singles), and if no moves found, starts using more involved strategies
 * until a move is found. The more advanced strategies can mask states
 * in the board, making this an efficient mechanism, but difficult for
 * a human to understand.
 */
static
int
allmoves( void )
{
    int i, n;

    rb->yield();

    n = findmoves( );
    if( 0 < n )
        return n;

    for( i = 0 ; i < 9 ; ++i )
    {
        count_set_digits( i, idx_row );
        pairs( i, idx_row );

        count_set_digits( i, idx_column );
        pairs( i, idx_column );

        count_set_digits( i, idx_block );
        pairs( i, idx_block );
    }
    n = findmoves( );
    if( 0 < n )
        return n;

    for( i = 0 ; i < 9 ; ++i )
    {
        block( i );
        common( i );
        position2( i );
    }
    return findmoves( );
}
GeneralConfig::GeneralConfig()
 : ConfigMode(_("General Configuration")),
   m_uiSnowLbl(_("Show UI Snow:")),
   m_fpsLbl(_("Display FPS:")),
   m_coursePercentageLbl(_("Display Progress Bar:")),
   m_langListLbl(_("Language:")),
   m_langListBox(240)
{
	std::map<std::string, std::string> languages=
		ppogl::Translation::getInstance().getLanguages();
	
	std::map<std::string, std::string>::iterator iter;
	ppogl::ListBox<std::string>::Iterator langit;

	if(languages.empty()){	
		PP_WARNING("Language list is empty");
	}else{
		for (iter=languages.begin();iter != languages.end(); ++iter){
			langit = m_langListBox.addElement((*iter).second,(*iter).first);
			if((*iter).first==PPConfig.getString("ui_language")){
				m_langListBox.setSelected(langit);
			}
		}
	}
		
	ppogl::Vec2d position(40,350);
	ppogl::Vec2d position2(600,350);

	m_langListLbl.setPosition(position);
	m_langListBox.setPosition(position2);
	m_langListBox.alignment.right();
	
	position.y()-=40;
	position2.y()-=40;
	
	m_uiSnowLbl.setPosition(position);
	m_uiSnowBox.setPosition(position2);
	m_uiSnowBox.alignment.right();
	m_uiSnowBox.setSelected(PPConfig.getBool("ui_snow"));
	
	position.y()-=40;
	position2.y()-=40;
	
	m_fpsLbl.setPosition(position);	
	m_fpsBox.setPosition(position2);
	m_fpsBox.alignment.right();
	m_fpsBox.setSelected(PPConfig.getBool("display_fps"));
	
	position.y()-=40;
	position2.y()-=40;
	
	m_coursePercentageLbl.setPosition(position);
	m_coursePercentageBox.setPosition(position2);
	m_coursePercentageBox.alignment.right();
	m_coursePercentageBox.setSelected(PPConfig.getBool("display_course_percentage"));
}
示例#4
0
	void CSimPetriDoc::AdjustElementsOnGrid(const std::vector<CElement*>& selection, CElement* mouseObject, const Point& pointer)
	{
		Point position1(mouseObject->GetBoundRect().X,
			mouseObject->GetBoundRect().Y);

		//Ajustement de l'objet en déplacement sur la grille
		//suivant la position du pointeur
		mouseObject->AdjustOnGrid(&pointer);

		Point position2(mouseObject->GetBoundRect().X,
			mouseObject->GetBoundRect().Y);

		//Déplacement de tous les éléments
		Size size(position2.X - position1.X, position2.Y - position1.Y);
		for(auto it = selection.begin(); it!=selection.end(); ++it)
			if(*it != mouseObject)
				(*it)->Move(size);
	}
void CWsGraphicShareBase::DoTestDrawGraphicCompareL(TPtrC aShare)
	{
	// UID of the shared graphic
	TUid uid1 = {0x12000021};
	TWsGraphicId twsGraphicId1(uid1);

	_LIT8(KTestData,"HelloWorld");
	
	CFbsBitmap bitmap1;
	CFbsBitmap mask1;
	
	TSize screenSize = iScreen->SizeInPixels();
	User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0));
	mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode());
	
		CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1);
	
	// divide the screen into two equal rectangles
	TRect position1(0,0,screenSize.iWidth/2,screenSize.iHeight);
	TRect position2(screenSize.iWidth/2,0,screenSize.iWidth,screenSize.iHeight);
	
	// draw the new graphic and attempt to draw the shared graphic
	iGc->Activate(*iWin);
	iWin->Invalidate();
	iWin->BeginRedraw();
	iGc->Clear(position1);
	iGc->Clear(position2);

	iGc->DrawWsGraphic(bTest->Id(),position1,KTestData);
	iGc->DrawWsGraphic(twsGraphicId1.Uid(),position2,KTestData);

	iGc->Deactivate();	
	iWin->EndRedraw();
	
	iWs.Flush();
	iWs.Finish();
	// compare the graphic in both positions
	if (aShare==_L("false"))
		Test(!iScreen->RectCompare(position1,position2));
	else
		Test(iScreen->RectCompare(position1,position2));	
		
	delete bTest;
	}
示例#6
0
/// Tests the Constructors
/// @return True if all tests were executed, false if not
bool PositionTestSuite::TestCaseConstructor()
{
    //------Last Checked------//
    // - Jan 18, 2005
    
    // TEST CASE: Default Constructor
    {
        Position position;
        TEST(wxT("Default Constructor"),
            (position.m_position == Position::DEFAULT_POSITION) &&
            (position.m_beaming == Position::DEFAULT_BEAMING) &&
            (position.GetDurationType() == 8) &&
            (position.m_data == Position::DEFAULT_DATA)
        );
    }
    
    // TEST CASE: Primary Constructor
    {
        Position position(12,4,2);
        TEST(wxT("Primary Constructor"),
            (position.GetPosition() == 12) &&
            (position.m_beaming == 0) &&
            (position.GetDurationType() == 4) &&
            (position.IsDoubleDotted())
        );
    }
    
    // TEST CASE: Copy Constructor
    {
        Position position(12,4,2);
        Position position2(position);
        TEST(wxT("Copy Constructor"),
            (position == position2)
        );
    }
    
    return (true);
}
CollisionBoxComponent::CollisionBoxComponent(GameObject& aGameObject, eCollisionGroup aCollisionGroup, const Vector2<float>& someDimensions, const Vector2<float>& aCenterPosition) : CollisionComponent(aGameObject, aCollisionGroup, aCenterPosition)
{
	myDimensions = someDimensions;
	Line<float> aLine;

	Vector2<float> position1(-myDimensions.myX / 2, -myDimensions.myY / 2);
	Vector2<float> position2(-myDimensions.myX / 2, myDimensions.myY / 2);
	Vector2<float> position3(myDimensions.myX / 2, myDimensions.myY / 2);
	Vector2<float> position4(myDimensions.myX / 2, -myDimensions.myY / 2);

	aLine.InitWith2Points(position1, position2);
	myLineVolume.AddLine(aLine);

	aLine.InitWith2Points(position2, position3);
	myLineVolume.AddLine(aLine);

	aLine.InitWith2Points(position3, position4);
	myLineVolume.AddLine(aLine);

	aLine.InitWith2Points(position4, position1);
	myLineVolume.AddLine(aLine);
	myParent->SetValue<CollisionBoxComponent*>("CollisionBoxComponent", this);

}
//=========================================
// Main Program
//=========================================
task main()
{
	initializeRobot();
	waitForStart();									// wait for FCS to tell us to go!
	if(done)
	{
		StartTask(lightDiagnostic);
	}

	if(calibrate != 2)							// GYRO calibration hasn't been run during the wait time
	{
		gyroCalTime = 3;							// so setup the default calibrate time
		calibrate = 1;								// start the calibration going
		while(calibrate != 2)					// and wait for it to complete before moving the robot
		{
			EndTimeSlice();
		}
	}
	constHeading = 0;								// reset the GYRO headings to eliminate any drift while we waited
	relHeading = 0;									// same thing for relative heading


	wait1Msec(Start_Delay*1000);		// implement the user configurable delay before moving
	PlaySound(soundBeepBeep);				// tell everyone we're about to start going

	step = MissionNumber*100;				// this records the actual mission number that we ran within the data log file
	LogData=true;										// start saving data to the log file

	servo[wrist] = WRIST_CLOSED;
	servo[shoulder] = SHOULDER_DOWN;
	servo[right_servo] = RIGHT_GRIPPER_START;
	servo[left_servo] = LEFT_GRIPPER_START;

	switch(MissionNumber)						// now go run whichever mission we have been asked to run
	{
		//================================================
		// start on the right side of the blue dispenser delivers to IR
		//================================================
	case 1:

		IRside = position1();//go here

		if(IRside < -75) column = 1;
		else if(IRside < -25) column = 2;
		else column = 3;

		wait1Msec(800);

		switch(column)
		{
		case 1://left
			diagnosticBeeps(1);
			leftPeg();
			break;

		case 2://center
			diagnosticBeeps(2);
			centerPeg();
			break;

		case 3://right
			diagnosticBeeps(3);
			rightPeg();
			break;
		}
		switch(fieldRed)
		{
		case STOP:
			StopRobot();
			break;

		case RED:
			redReturn();
			break;

		case BLUE:
			blueReturn();
			break;
		}
		break;
		//================================================
		// CENTER PEG
		//================================================

	case 2:
		position1();
		centerPeg();

		switch(fieldRed)
		{
		case STOP:
			StopRobot();
			break;

		case RED:
			redReturn();
			break;

		case BLUE:
			blueReturn();
			break;
		}

		break;
		//================================================
		// LEFT PEG
		//================================================

	case 3:

		position1();
		leftPeg();

		switch(fieldRed)
		{
		case STOP:
			StopRobot();
			break;

		case RED:
			redReturn();
			break;

		case BLUE:
			blueReturn();
			break;
		}
		break;
		//================================================
		// RIGHT PEG
		//================================================

	case 4:

		position1();
		rightPeg();

		switch(fieldRed)
		{
		case STOP:
			StopRobot();
			break;

		case RED:
			redReturn();
			break;

		case BLUE:
			blueReturn();
			break;
		}
		break;
		//================================================
		// IR SECOND POSITION
		//================================================
	case 5:

		IRside = position2();//go here

		if(IRside < -75) column = 1;
		else if(IRside < -25) column = 2;
		else column = 3;

		wait1Msec(800);

		switch(column)
		{
		case 1://left
			diagnosticBeeps(1);
			leftPeg();
			break;

		case 2://center
			diagnosticBeeps(2);
			centerPeg();
			break;

		case 3://right
			diagnosticBeeps(3);
			rightPeg();
			break;
		}
		switch(fieldRed)
		{
		case STOP:
			StopRobot();
			break;

		case RED:
			redReturn();
			break;

		case BLUE:
			blueReturn();
			break;
		}
		break;
		//================================================
		// CENTER PED SECOND POSITION
		//================================================
	case 6:

		position2();
		centerPeg();

		break;

		//================================================
		// LEFT PEG SECOND POSITION
		//================================================
	case 7:

		position2();
		leftPeg();
		break;

		//================================================
		// RIGHT PED SECOND POSITION
		//================================================

	case 8:

		position2();
		rightPeg();

		break;

		//================================================
		// DEFENSE RIGHT
		//================================================

	case 9:

		GyroSonar_moveV2(0, BACK, 100, 124, -60,true, true, CONSTANT);
		GyroTime_moveV2(700,-50,true,true,REL);
		GyroTimeS_moveV2(1800,40,true,true,false,true);

		break;

		//================================================
		// DEFENSE LEFT
		//================================================

	case 10:

		GyroSonar_moveV2(0, BACK, 100, 124, -60,true, true, CONSTANT);
		GyroTime_moveV2(700,-50,true,true,REL);
		GyroTimeS_moveV2(1800,-40,true,true,false,true);

		break;

		//================================================
		// OPPONENT IR
		//================================================

	case 11:
		for (int i=0;i<90;i++)
		{SetDrive(i,50,i);
			wait1Msec(30);
		}
		StopRobot();
		wait1Msec(30000);
		break;

		//================================================
		// OPPONENT CENTER
		//================================================

	case 12:
		opponentRight();
		centerPeg();
		break;

		//================================================
		// OPPONENT LEFT
		//================================================

	case 13:
		opponentRight();
		rightPeg();
		break;

		//================================================
		// OPPONENT RIGHT
		//================================================

	case 14:
		opponentRight();
		leftPeg();
		break;
		//================================================
		// OPPONENTL IR
		//================================================

	case 15:
		opponentLeft();
		leftPeg();
		break;
		//================================================
		// OPPONENTL CENTER
		//================================================

	case 16:
		opponentLeft();
		centerPeg();
		break;
		//================================================
		// OPPONENTL LEFT
		//================================================

	case 17:
		opponentLeft();
		rightPeg();
		break;
		//================================================
		// OPPONENTL RIGHT
		//================================================

	case 18:
		opponentLeft();
		leftPeg();
		break;
		//================================================
		// See Opponent test
		//================================================

	case 19:
		sawOpponent = GyroSonar_moveV2(0, BACK, 100, 112, -50,true, true, CONSTANT);
		StopRobot();
		if(sawOpponent) diagnosticBeeps(6);
		break;
		//================================================
		// See Opponent test2
		//================================================

	case 20:
		sawOpponent = GyroSonar_moveV2(0, BACK, 100, 112, -50,true, true, CONSTANT);
		StopRobot();
		if(sawOpponent) diagnosticBeeps(6);
		break;
	}

	LogData=false;		// stop logging IR data and close the file
	StopRobot();
}
示例#9
0
 double
 System::maxTimestep(int i)
 {
    Distance d;
    const Object mainObject = objectlist[i];
    int k;
    if (i == 0)
    {
       k=1;
    }
    else
    {
       k=0;
    }
    Object tempObject = objectlist[k];
    arma::Col<double> position1(3), position2(3);
    arma::Col<double> mainVel = mainObject.getVelocity();

    position1 = mainObject.getPosition();
    position2 = tempObject.getPosition();

    double R = d.twoObjects(position1, position2);
    arma::Col<double> tempVel = tempObject.getVelocity()-mainVel;
    double V = std::sqrt(arma::dot(tempVel,tempVel));
    double maxTime;
    if (V>1e-16)
    {
       maxTime = R/V;
    }
    else
    {
       maxTime = R/1e-16;
    }
    double temptime;

    for (int j = 1; j < numberOfObject; ++j)
    {
       if (j!=i)
       {
          tempObject = objectlist[j];
          position2 = tempObject.getPosition();
          R = d.twoObjects(position1, position2);
          tempVel = tempObject.getVelocity()-mainVel;
          V = std::sqrt(arma::dot(tempVel,tempVel));
          if (V>1e-16)
          {
             maxTime = R/V;
          }
          else
          {
             maxTime = R/1e-16;
          }
          temptime = R/V;
          if (temptime<maxTime)
          {
             maxTime = temptime;
          }
       } //end if
    } //end for
    return maxTime;
 }
示例#10
0
int main(int argc, char* argv[])
{
	ExplorationShared shared;
	EBehavior behavior(&shared);
	EBWaitIdle waitStart("Start");
	EBWaitIdle waitMotion1("ArmPositioning");
	EBWaitIdle waitMotion2("Turn1");
	EBWaitIdle waitMotion3("Turn2");
	EBWaitIdle waitMotion4("Turn3");
	EBWaitIdle waitMotion5("Turn4");
	EBWaitIdle waitMotion6("Turn5");
	EBWaitIdle waitMotion7("Final pos");
	EBWaitIdle waitMotion8("Going back to rest");
	EBWaitIdle endState1("end1");
	EBWaitIdle endState2("end2");

	EBWaitIdle stateInhibitHandTracking("Inhibit hand tracking");
	EBWaitIdle stateEnableHandTracking("Enable hand tracking");

	EBWaitIdle position1Wait("Position1 done");
	EBWaitIdle position2Wait("Position2 done");
	EBWaitIdle position3Wait("Position3 done");
	
	EBWaitDeltaT position2Train(6);
	EBWaitDeltaT position3Train(6);
	EBWaitDeltaT position4Train(6);

	EBWaitIdle position2("Waiting arm done");
	EBWaitIdle position3("Waiting arm done");
	EBWaitIdle position4("Waiting arm done");

	EBWaitIdle waitArmAck("Wait armAck");

	EBWaitDeltaT dT1(6);
	EBWaitDeltaT dT2(0.2);
	EBWaitDeltaT dT3OneSecond(3);

	EBWaitDeltaT dTHandClosing(0.1);
	EBWaitDeltaT waitArmSeemsToRest(5);
	EBBehaviorOutput	startTrain(YBVKFTrainStart);
	EBBehaviorOutput	startSequence(YBVKFStart);
	EBBehaviorOutput    stopTrain(YBVKFTrainStop);
	EBBehaviorOutput    stop(YBVKFStop);
	EBSimpleOutput	forceOpen(YBVGraspRflxForceOpen);
	EBSimpleOutput  parkArm(YBVArmForceRestingTrue);
	
	// output: enable and disable hand tracking system
	EBEnableTracker		enableHandTracking;
	EBInhibitTracker	inhibitHandTracking;
		
	EBOutputCommand cmd1(YBVArmForceNewCmd, YVector(_nJoints, pos1));
	EBOutputCommand cmd2(YBVArmForceNewCmd, YVector(_nJoints, pos2));
	EBOutputCommand cmd3(YBVArmForceNewCmd, YVector(_nJoints, pos3));
	// EBOutputCommand cmd4(YBVArmForceNewCmd, YVector(_nJoints, pos4));
	// EBOutputCommand cmd5(YBVArmForceNewCmd, YVector(_nJoints, pos5));
//	EBOutputCommand cmd6(YBVArmForceNewCmd, YVector(_nJoints, pos6));
	EBOutputCommand cmd7(YBVArmForceNewCmd, YVector(_nJoints, pos7));
	EBOutputCommand cmd8(YBVArmForceNewCmd, YVector(_nJoints, pos8));
	EBOutputCommand cmd9(YBVArmForceNewCmd, YVector(_nJoints, pos9));
	EBOutputCommand cmd10(YBVArmForceNewCmd, YVector(_nJoints, pos10));

	EBSimpleInput armDone(YBVArmDone);
	EBSimpleInput handDone(YBVHandDone);
	EBSimpleInput start(YBVKFExplorationStart);
	EBSimpleInput start2(YBVGraspRflxClutch);
	EBSimpleInput armAck(YBVArmIssuedCmd);
	EBSimpleInput armNAck(YBVArmIsBusy);

	behavior.setInitialState(&waitStart);
	behavior.add(&start, &waitStart, &waitMotion1, &cmd1);
	behavior.add(&start2, &waitStart, &dTHandClosing, &enableHandTracking);
	behavior.add(NULL, &dTHandClosing, &waitArmAck, &cmd1);

	behavior.add(&armAck, &waitArmAck, &stateEnableHandTracking, &startSequence);
	behavior.add(&armNAck, &waitArmAck, &waitArmSeemsToRest, &inhibitHandTracking);
	behavior.add(NULL, &waitArmSeemsToRest, &waitStart, &forceOpen);
	behavior.add(NULL, &stateEnableHandTracking, &waitMotion1, &enableHandTracking);

	behavior.add(&armDone, &waitMotion1, &dT3OneSecond);
	// wait some extra time before issueing the startKF signal
	behavior.add(NULL, &dT3OneSecond, &dT1, &startTrain);
	
	// july 21/04
	behavior.add(NULL, &dT1, &waitMotion6);
	behavior.add(NULL, &waitMotion6, &position1Wait, &stopTrain);
	// position2
	behavior.add(NULL, &position1Wait, &position2, &cmd7);
	behavior.add(&armDone, &position2, &position2Train, &startTrain);
	behavior.add(NULL, &position2Train, &position2Wait, &stopTrain);
	//position3
	behavior.add(NULL, &position2Wait, &position3, &cmd8);
	behavior.add(&armDone, &position3, &position3Train, &startTrain);
	behavior.add(NULL, &position3Train, &position3Wait, &stopTrain);
	//position 4
	behavior.add(NULL, &position3Wait, &position4, &cmd9);
	behavior.add(&armDone, &position4, &position4Train, &startTrain);
	behavior.add(NULL, &position4Train, &stateInhibitHandTracking, &stopTrain);

	behavior.add(NULL, &stateInhibitHandTracking, &dT2);

	/*
	behavior.add(NULL, &dT1, &waitMotion2, &cmd2);
	// behavior.add(&armDone, &waitMotion1, &waitMotion2, &cmd2);
	behavior.add(&armDone, &waitMotion2, &waitMotion3, &cmd3);
	behavior.add(&armDone, &waitMotion3, &waitMotion4, &cmd4);
	behavior.add(&armDone, &waitMotion4, &waitMotion5, &cmd5);
	behavior.add(&armDone, &waitMotion5, &waitMotion6, &cmd6);

	behavior.add(&armDone, &waitMotion6, &dT2, &stopKF);
	*/
	behavior.add(NULL, &dT2, &waitMotion7, &cmd10);
	behavior.add(&armDone, &waitMotion7, &waitMotion8, &forceOpen);
	behavior.add(&handDone, &waitMotion8, &endState1, &parkArm);
	behavior.add(NULL, &endState1, &endState2, &inhibitHandTracking);
	behavior.add(NULL, &endState2, &waitStart, &stop);

	behavior.Begin();
	behavior.loop();

	return 0;
}
示例#11
0
/// Tests the Operators
/// @return True if all tests were executed, false if not
bool PositionTestSuite::TestCaseOperator()
{
    //------Last Checked------//
    // - Jan 18, 2005
    
    // TEST CASE: Assignment Operator
    {
        Position position(12,4,2);
        Position position2 = position;
        TEST(wxT("Operator="), 
            (position == position2)
        );
        
        // TEST CASE: Operator= (self-assignment)
        position = position;
        TEST(wxT("Operator= (self-assignment)"),
            (position == position)
        );
    }
    
    // TEST CASE: Equality Operator
    {
        Position position(12,4,2);
        Position position2(12,4,2);
        Position position3(13,4,2);
        Position position4(12,8,2);
        Position position5(12,4,1);
        Position position6(12,4,2);
        position6.SetIrregularGroupingTiming(3,2);
        Position position7(12,4,2);
        position7.SetPreviousBeamDurationType(16);
        Position position8(12,4,2);
        position8.SetBeamStart();
        Position position9(12,4,2);
        position9.SetFractionalLeftBeam();
        Position position10(12,4,2);
        position10.SetFractionalRightBeam();
        Position position11(12,4,2);
        position11.SetBeamEnd();
        Position position12(12,4,2);
        position12.SetDotted();
        Position position13(12,4,2);
        position13.SetRest();
        Position position14(12,4,2);
        position14.SetVibrato();
        Position position15(12,4,2);
        position15.SetWideVibrato();
        Position position16(12,4,2);
        position16.SetArpeggioUp();
        Position position17(12,4,2);
        position17.SetArpeggioDown();
        Position position18(12,4,2);
        position18.SetPickStrokeUp();
        Position position19(12,4,2);
        position19.SetPickStrokeDown();
        Position position20(12,4,2);
        position20.SetStaccato();
        Position position21(12,4,2);
        position21.SetMarcato();
        Position position22(12,4,2);
        position22.SetSforzando();
        Position position23(12,4,2);
        position23.SetTremoloPicking();
        Position position24(12,4,2);
        position24.SetPalmMuting();
        Position position25(12,4,2);
        position25.SetTap();
        Position position26(12,4,2);
        position26.SetAcciaccatura();
        Position position27(12,4,2);
        position27.SetTripletFeel1st();
        Position position28(12,4,2);
        position28.SetTripletFeel2nd();
        Position position29(12,4,2);
        position29.SetLetRing();
        Position position30(12,4,2);
        position30.SetFermata();
        Position position31(12,4,2);
        position31.SetIrregularGroupingStart();
        Position position32(12,4,2);
        position32.SetIrregularGroupingMiddle();
        Position position33(12,4,2);
        position33.SetIrregularGroupingEnd();
        Position position34(12,4,2);
        position34.SetVolumeSwell(Dynamic::off, Dynamic::mp, 1);
        Position position35(12,4,2);
        position35.SetTremoloBar(Position::invertedDip, 1, 12);
        
        TEST(wxT("Operator== - position == position"), (position == position2));
        TEST(wxT("Operator== - position != position"),
            !(position == position3));
        TEST(wxT("Operator== - position != position 2"),
            !(position == position4));
        TEST(wxT("Operator== - position != position 3"),
            !(position == position5));
        TEST(wxT("Operator== - position != position 4"),
            !(position == position6));
        TEST(wxT("Operator== - position != position 5"),
            !(position == position7));
        TEST(wxT("Operator== - position != position 6"),
            !(position == position8));
        TEST(wxT("Operator== - position != position 7"),
            !(position == position9));
        TEST(wxT("Operator== - position != position 8"),
            !(position == position10));
        TEST(wxT("Operator== - position != position 9"),
            !(position == position11));
        TEST(wxT("Operator== - position != position 10"),
            !(position == position12));
        TEST(wxT("Operator== - position != position 11"),
            !(position == position13));
        TEST(wxT("Operator== - position != position 12"),
            !(position == position14));
        TEST(wxT("Operator== - position != position 13"),
            !(position == position15));
        TEST(wxT("Operator== - position != position 14"),
            !(position == position16));
        TEST(wxT("Operator== - position != position 15"),
            !(position == position17));
        TEST(wxT("Operator== - position != position 16"),
            !(position == position18));
        TEST(wxT("Operator== - position != position 17"),
            !(position == position19));
        TEST(wxT("Operator== - position != position 18"),
            !(position == position20));
        TEST(wxT("Operator== - position != position 19"),
            !(position == position21));
        TEST(wxT("Operator== - position != position 20"),
            !(position == position22));
        TEST(wxT("Operator== - position != position 21"),
            !(position == position23));
        TEST(wxT("Operator== - position != position 22"),
            !(position == position24));
        TEST(wxT("Operator== - position != position 23"),
            !(position == position25));
        TEST(wxT("Operator== - position != position 24"),
            !(position == position26));
        TEST(wxT("Operator== - position != position 25"),
            !(position == position27));
        TEST(wxT("Operator== - position != position 26"), 
            !(position == position28));
        TEST(wxT("Operator== - position != position 27"),
            !(position == position29));
        TEST(wxT("Operator== - position != position 28"),
            !(position == position30));
        TEST(wxT("Operator== - position != position 29"),
            !(position == position31));
        TEST(wxT("Operator== - position != position 30"),
            !(position == position32));
        TEST(wxT("Operator== - position != position 31"),
            !(position == position33));
        TEST(wxT("Operator== - position != position 32"),
            !(position == position34));
        TEST(wxT("Operator== - position != position 33"),
            !(position == position35));
    }
    
    // Inequality Operator
    {
        Position position(12,4,2);
        Position position2(12,4,2);
        Position position3(13,4,2);
        Position position4(12,8,2);
        Position position5(12,4,1);
        Position position6(12,4,2);
        position6.SetIrregularGroupingTiming(3,2);
        Position position7(12,4,2);
        position7.SetPreviousBeamDurationType(16);
        Position position8(12,4,2);
        position8.SetBeamStart();
        Position position9(12,4,2);
        position9.SetFractionalLeftBeam();
        Position position10(12,4,2);
        position10.SetFractionalRightBeam();
        Position position11(12,4,2);
        position11.SetBeamEnd();
        Position position12(12,4,2);
        position12.SetDotted();
        Position position13(12,4,2);
        position13.SetRest();
        Position position14(12,4,2);
        position14.SetVibrato();
        Position position15(12,4,2);
        position15.SetWideVibrato();
        Position position16(12,4,2);
        position16.SetArpeggioUp();
        Position position17(12,4,2);
        position17.SetArpeggioDown();
        Position position18(12,4,2);
        position18.SetPickStrokeUp();
        Position position19(12,4,2);
        position19.SetPickStrokeDown();
        Position position20(12,4,2);
        position20.SetStaccato();
        Position position21(12,4,2);
        position21.SetMarcato();
        Position position22(12,4,2);
        position22.SetSforzando();
        Position position23(12,4,2);
        position23.SetTremoloPicking();
        Position position24(12,4,2);
        position24.SetPalmMuting();
        Position position25(12,4,2);
        position25.SetTap();
        Position position26(12,4,2);
        position26.SetAcciaccatura();
        Position position27(12,4,2);
        position27.SetTripletFeel1st();
        Position position28(12,4,2);
        position28.SetTripletFeel2nd();
        Position position29(12,4,2);
        position29.SetLetRing();
        Position position30(12,4,2);
        position30.SetFermata();
        Position position31(12,4,2);
        position31.SetIrregularGroupingStart();
        Position position32(12,4,2);
        position32.SetIrregularGroupingMiddle();
        Position position33(12,4,2);
        position33.SetIrregularGroupingEnd();
        Position position34(12,4,2);
        position34.SetVolumeSwell(Dynamic::off, Dynamic::mp, 1);
        Position position35(12,4,2);
        position35.SetTremoloBar(Position::invertedDip, 1, 12);
        
        TEST(wxT("Operator!= - position == position"),
            !(position != position2));
        TEST(wxT("Operator!= - position != position"),
            (position != position3));
        TEST(wxT("Operator!= - position != position 2"),
            (position != position4));
        TEST(wxT("Operator!= - position != position 3"),
            (position != position5));
        TEST(wxT("Operator!= - position != position 4"),
            (position != position6));
        TEST(wxT("Operator!= - position != position 5"),
            (position != position7));
        TEST(wxT("Operator!= - position != position 6"),
            (position != position8));
        TEST(wxT("Operator!= - position != position 7"),
            (position != position9));
        TEST(wxT("Operator!= - position != position 8"),
            (position != position10));
        TEST(wxT("Operator!= - position != position 9"),
            (position != position11));
        TEST(wxT("Operator!= - position != position 10"),
            (position != position12));
        TEST(wxT("Operator!= - position != position 11"),
            (position != position13));
        TEST(wxT("Operator!= - position != position 12"),
            (position != position14));
        TEST(wxT("Operator!= - position != position 13"),
            (position != position15));
        TEST(wxT("Operator!= - position != position 14"),
            (position != position16));
        TEST(wxT("Operator!= - position != position 15"),
            (position != position17));
        TEST(wxT("Operator!= - position != position 16"),
            (position != position18));
        TEST(wxT("Operator!= - position != position 17"),
            (position != position19));
        TEST(wxT("Operator!= - position != position 18"),
            (position != position20));
        TEST(wxT("Operator!= - position != position 19"),
            (position != position21));
        TEST(wxT("Operator!= - position != position 20"),
            (position != position22));
        TEST(wxT("Operator!= - position != position 21"),
            (position != position23));
        TEST(wxT("Operator!= - position != position 22"),
            (position != position24));
        TEST(wxT("Operator!= - position != position 23"),
            (position != position25));
        TEST(wxT("Operator!= - position != position 24"),
            (position != position26));
        TEST(wxT("Operator!= - position != position 25"),
            (position != position27));
        TEST(wxT("Operator!= - position != position 26"),
            (position != position28));
        TEST(wxT("Operator!= - position != position 27"),
            (position != position29));
        TEST(wxT("Operator!= - position != position 28"),
            (position != position30));
        TEST(wxT("Operator!= - position != position 29"),
            (position != position31));
        TEST(wxT("Operator!= - position != position 30"),
            (position != position32));
        TEST(wxT("Operator!= - position != position 31"),
            (position != position33));
        TEST(wxT("Operator!= - position != position 32"),
            (position != position34));
        TEST(wxT("Operator!= - position != position 33"),
            (position != position35));
    }
    
    return (true);
}
示例#12
0
PointToPlaneDemo::PointToPlaneDemo(hkDemoEnvironment* env)
:	hkDefaultPhysicsDemo(env)
{

	//
	// Setup the camera
	//
	{
		hkVector4 from(5.0f, 2.0f, 10.0f);
		hkVector4 to  (2.0f, 0.0f,  0.0f);
		hkVector4 up  (0.0f, 1.0f,  0.0f);
		setupDefaultCameras( env, from, to, up );
	}

	//
	// Create the world
	//
	{
		hkpWorldCinfo info;
		info.setupSolverInfo(hkpWorldCinfo::SOLVER_TYPE_4ITERS_MEDIUM); 
		info.setBroadPhaseWorldSize( 100.0f );
		info.m_enableDeactivation = false;
		m_world = new hkpWorld( info );
		m_world->lock();

				// Register the single agent required (a hkpBoxBoxAgent)
		hkpAgentRegisterUtil::registerAllAgents( m_world->getCollisionDispatcher() );

		//
		// Create constraint viewer
		//
		m_debugViewerNames.pushBack( hkpConstraintViewer::getName() );
		hkpConstraintViewer::m_scale = 1.0f;
	
		setupGraphics();
	}

	//
	// Create vectors to be used for setup
	//
	hkVector4 halfSize (0.5f, 0.5f, 0.5f);
	hkVector4 position1(0.f,0.f,0.f);
	hkVector4 position2(3.0f,-0.5f,0.f);
	
	//
	// Create Box Shape
	//
	hkpBoxShape* boxShape;
	{
		boxShape = new hkpBoxShape( halfSize , 0 );
	}

	//
	// Create fixed rigid body
	//
	hkpRigidBody* fixedBody;
	{
		hkpRigidBodyCinfo info;
		info.m_position = position1;
		info.m_shape = boxShape;
		info.m_motionType = hkpMotion::MOTION_FIXED;
		fixedBody = new hkpRigidBody(info);
		m_world->addEntity(fixedBody);
		fixedBody->removeReference();	
	}

	//
	// Create movable rigid body
	//
	hkpRigidBody* moveableBody;
	{

		hkpRigidBodyCinfo info;
		info.m_position = position2;
		info.m_shape = boxShape;
		
			// Compute the box inertia tensor
		hkpMassProperties massProperties;
		info.m_mass = 10.0f;
		hkpInertiaTensorComputer::computeBoxVolumeMassProperties(halfSize, info.m_mass, massProperties);
		info.m_inertiaTensor = massProperties.m_inertiaTensor;
		info.m_centerOfMass = massProperties.m_centerOfMass;
		info.m_motionType = hkpMotion::MOTION_BOX_INERTIA;

		moveableBody = new hkpRigidBody(info);
		m_world->addEntity(moveableBody);
		moveableBody->removeReference();	
	}

	//
	//	Cleanup shared shape references
	//
	boxShape->removeReference();
	boxShape = HK_NULL;

	
	//
	// Create point to plane constraint
	// 
	{
		hkpPointToPlaneConstraintData* plane = new hkpPointToPlaneConstraintData();

		hkVector4 up(0.0f, 1.0f, 0.0f);

		// Create constraint
		hkVector4 pivotW; pivotW.setAdd4(position2, hkVector4(-0.5f, 0.5f, 0.5f));
		plane->setInWorldSpace(moveableBody->getTransform(), fixedBody->getTransform(), pivotW, up);

		//
		//	Create and add the constraint
		//
		{
			hkpConstraintInstance* constraint = new hkpConstraintInstance( moveableBody, fixedBody, plane );
			m_world->addConstraint(constraint);
			constraint->removeReference();
		}		

		plane->removeReference();  
	}

	m_world->unlock();
}
示例#13
0
void GadgetBeamWeapon::render( RenderContext &context, 
					const Matrix33 & frame, 
					const Vector3 & position )
{
	NounGadget::render( context, frame, position );

	// render the beam
	if ( useActive() && m_Target.valid() && m_Duration > 0 )
	{
		Vector3 positionVS( context.worldToView( position ) );
		float fLength = length() * calculateModifier( MT_BEAM_RANGE );
		if (! context.sphereVisible( positionVS, fLength ) )
			return;

		Noun * pTarget = m_Target;
		Vector3 position2( pTarget->worldPosition() );			
		
		if ( ( ( position2 - worldPosition() ).magnitude() - pTarget->radius() ) > fLength )
			return;		
		
		if ( !checkFacing( position2 ) )
			return;

		int tailAlpha = 32;

		if ( m_Hit.valid() )
			tailAlpha = 128;

		Vector3 direction( pTarget->worldPosition() - position );
		Vector3 head( position );
		Vector3 tail( head + direction );

		// calculate the material wrap
		float h = 0.05f;
		float w = 10.0f;

		Material * pTracerMaterial = tracerMaterial();
		if ( pTracerMaterial != NULL )
		{
			h = pTracerMaterial->height();
			w = pTracerMaterial->width();
			Material::push( context, pTracerMaterial );
		}
		else
			Material::push( context, Color(255,0,0), true, PrimitiveMaterial::ADDITIVE );

		float u = (head - tail).magnitude() / w;

		const Vector3	N( 0,0, 0);
		const Vector3	Y( 0, h, 0 );
		const Vector3	X( h, 0, 0 );
		const Color		HC( 255,255,255,255 );
		const Color		TC( 255,255,255,tailAlpha );

		VertexL beamY[4] = 
		{
			VertexL( head + Y, N, HC, u, 0.0f ),
			VertexL( tail + Y, N, TC, 0.0f, 0.0f ),
			VertexL( tail - Y, N, TC, 0.0f, 1.0f ),
			VertexL( head - Y, N, HC, u, 1.0f ),
		};
		VertexL beamX[4] = 
		{
			VertexL( head + X, N, HC, u, 0.0f ),
			VertexL( tail + X, N, TC, 0.0f, 0.0f ),
			VertexL( tail - X, N, TC, 0.0f, 1.0f ),
			VertexL( head - X, N, HC, u, 1.0f ),
		};
		
		DisplayDevice * pDisplay = context.device();
		ASSERT( pDisplay );

		context.pushIdentity();
		PrimitiveTriangleFanDL::push( pDisplay, 4, beamY );
		PrimitiveTriangleFanDL::push( pDisplay, 4, beamX );
	}
}