Learning XNA 3.0 phần 7

bạn sẽ có để có thể sửa đổi ma trận xem. Trong thực tế, chứ không phải là sửa đổi ma trận xem, bạn sẽ được xây dựng lại ma trận mỗi khung. Hãy nhớ rằng các ma trận xem là bao gồm một vị trí vector, vector một hướng, và vector một lên. Bằng cách tạo ra các biến lớp học cấp cho mỗi của những vector, | Don t be too scared by this code. It looks a bit different than what you re used to in XNA but we ll explore each section of the code here so you can figure out what it s doing. First let s look at the first three lines of the file float4X4 World float4X4 View float4X4 Projection These three lines represent global variables in this file. All three variables are 4 X 4 matrices they correspond to the world the camera view and the camera projection. These terms should be pretty familiar to you by now because they are the same world view and projection that you ve used in previous examples in this book when drawing in 3D. Look Familiar Remember where you ve used the world view and projection variables in the past You used them to set the World View and Projection properties of the BasicEffect class. The following code sets those variables and it should be similar to what you have in the Draw method of your BasicModel class in the source code you completed in Chapter 12 foreach BasicEffect be in GetWorld You re seeing the same World Projection and View variables in this HLSL file. It makes sense when you think about it. Remember that when drawing in 3D everything in XNA uses I . Until now you ve been using the BasicEffect class which provides you with a way to draw well basic effects without having to know the underlying workings of HLSL. Behind the scenes though even the BasicEffect class is using HLSL. Now that you re looking at branching out and using HLSL instead of the BasicEffect class it probably won t surprise you to see some of the same properties you ve used in the BasicEffect class show up in the HLSL file itself. Variables that are in this global space can be set from your XNA code. You ll see more about how to do that later when you apply this code to an actual project. When using an HLSL file in XNA one of the first things to do

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.