Directx 11 with rastertek

Tutorial 24: Clipping Planes 연습문제

코다람쥐 2022. 9. 22. 20:53

To Do Exercises

1. Recompile the code and you should get a triangle cut in half on the Y axis. Press escape to quit.

2. Load the cube model instead of the triangle model and turn off culling in the D3DClass. Set the cube to rotate and move the camera up a bit as well. You should see the cube cut in half and be able to see inside it now.

3. Change the clip plane to cull different parts of the cube on different heights and different planes.

 

1. 코드를 다시 컴파일하세요. 그러면 Y축으로 반이 잘린 삼각형을 얻을 수 있습니다. 종료하려면 ESC를 누르십시오.

2. 삼각형 대신 큐브 모델을 로드해보세요. 그리고 큐브를 보기위해 카메라를 조금 위로 올리고 큐브를 회전시켜보세요. 당신은 반이 잘린 큐브를 볼 수 있어야하고 그것의 내부를 볼 수 있습니다.

graphicsclass.cpp

bool GraphicsClass::Frame()
{
	// Set the position of the camera.
	m_Camera->SetPosition(0.0f, 2.0f, -10.0f);
    
	return true;
}

 

graphicsclass.cpp

bool GraphicsClass::RenderScene()
{
...........................생략...........................
		// Update the rotation variable each frame.
	rotation += (float)D3DX_PI * 0.005f;
	if (rotation > 360.0f)
	{
		rotation -= 360.0f;
	}

	D3DXMatrixRotationY(&worldMatrix, rotation);
...........................생략...........................
}

 

 

3.클리핑 평면을 바꾸어 다른 부분이 잘려지도록 해 보십시오.

graphicsclass.cpp

bool GraphicsClass::Render()
{
.............................생략.............................
	clipPlane = D3DXVECTOR4(-1.0f, -1.0f, 0.0f, 0.0f);
.............................생략.............................
}