void CPFA_qt_user_functions::DrawTargetRays() {
	//size_t tick = loopFunctions.GetSpace().GetSimulationClock();
	//size_t tock = loopFunctions.GetSimulator().GetPhysicsEngine("default").GetInverseSimulationClockTick() / 8;

	//if(tock == 0) tock = 1;

	//if(tick % tock == 0) {
		for(size_t j = 0; j < loopFunctions.TargetRayList.size(); j++) {
			DrawRay(loopFunctions.TargetRayList[j], loopFunctions.TargetRayColorList[j]);
		}
	//}
}
void CPFA_qt_user_functions::DrawPheromones() {

	Real x, y, weight;
	vector<CVector2> trail;
	CColor trailColor = CColor::GREEN, pColor = CColor::GREEN;

	for(size_t i = 0; i < loopFunctions.PheromoneList.size(); i++) {
		x = loopFunctions.PheromoneList[i].GetLocation().GetX();
		y = loopFunctions.PheromoneList[i].GetLocation().GetY();

		if(loopFunctions.DrawTrails == 1) {
			trail  = loopFunctions.PheromoneList[i].GetTrail();
			weight = loopFunctions.PheromoneList[i].GetWeight();

			if(weight > 0.25 && weight <= 1.0)        // [ 100.0% , 25.0% )
				pColor = trailColor = CColor::GREEN;
			else if(weight > 0.05 && weight <= 0.25)  // [  25.0% ,  5.0% )
				pColor = trailColor = CColor::YELLOW;
			else                                      // [   5.0% ,  0.0% ]
				pColor = trailColor = CColor::RED;

			CRay3 ray;
			size_t j = 0;

			for(j = 1; j < trail.size(); j++) {
				ray = CRay3(CVector3(trail[j - 1].GetX(), trail[j - 1].GetY(), 0.01),
							CVector3(trail[j].GetX(), trail[j].GetY(), 0.01));
				DrawRay(ray, trailColor, 1.0);
			}

			DrawCylinder(CVector3(x, y, 0.0), CQuaternion(), loopFunctions.FoodRadius, 0.025, pColor);
		} else {
			weight = loopFunctions.PheromoneList[i].GetWeight();

			if(weight > 0.25 && weight <= 1.0)        // [ 100.0% , 25.0% )
				pColor = CColor::GREEN;
			else if(weight > 0.05 && weight <= 0.25)  // [  25.0% ,  5.0% )
				pColor = CColor::YELLOW;
			else                                      // [   5.0% ,  0.0% ]
				pColor = CColor::RED;

			DrawCylinder(CVector3(x, y, 0.0), CQuaternion(), loopFunctions.FoodRadius, 0.025, pColor);
		}
	}
}
示例#3
0
int main()
{
    // Initialization
    //--------------------------------------------------------------------------------------
    int screenWidth = 800;
    int screenHeight = 450;

    InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking");

    // Define the camera to look into our 3d world
    Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};

    Vector3 cubePosition = { 0.0, 1.0, 0.0 };
    
    Ray ray;        // Picking line ray
    
    SetCameraMode(CAMERA_FREE);         // Set a free camera mode
    SetCameraPosition(camera.position); // Set internal camera position to match our camera position

    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
    //--------------------------------------------------------------------------------------

    // Main game loop
    while (!WindowShouldClose())        // Detect window close button or ESC key
    {
        // Update
        //----------------------------------------------------------------------------------
        UpdateCamera(&camera);          // Update internal camera and our camera
        
        if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
        {
            // NOTE: This function is NOT WORKING properly!
            ray = GetMouseRay(GetMousePosition(), camera);
            
            // TODO: Check collision between ray and box
        }
        //----------------------------------------------------------------------------------

        // Draw
        //----------------------------------------------------------------------------------
        BeginDrawing();

            ClearBackground(RAYWHITE);

            Begin3dMode(camera);

                DrawCube(cubePosition, 2, 2, 2, GRAY);
                DrawCubeWires(cubePosition, 2, 2, 2, DARKGRAY);

                DrawGrid(10.0, 1.0);
                
                DrawRay(ray, MAROON);

            End3dMode();
            
            DrawText("Try selecting the box with mouse!", 240, 10, 20, GRAY);

            DrawFPS(10, 10);

        EndDrawing();
        //----------------------------------------------------------------------------------
    }

    // De-Initialization
    //--------------------------------------------------------------------------------------
    CloseWindow();        // Close window and OpenGL context
    //--------------------------------------------------------------------------------------

    return 0;
}