22. dubna 2012 23:19
I am trying to use the BasicShapes::CreateBox function. So in the Direct 3D Tutorial, lesson 5, in Direct3DTutorial.cpp, I replace:
shapes->CreateCube( &m_vertexBuffer, &m_indexBuffer, nullptr, &m_indexCount );
shapes->CreateBox(1.0f, &m_vertexBuffer, &m_indexBuffer, nullptr, &m_indexCount );
Now clearly the camera position is going to have to change, I assume (given there is no example that uses this) that the camera should be placed in the centre,
so tried to do that in Direct3DTutorial::Update:
m_camera->SetViewParameters( float3(0, 0.5f, 0), float3(0, 0, 0), float3(0, 1, 0) );
However, I get nothing displaying on the screen. I have tried a few different combinations for the camera position and still get nothing.
What have I missed? Where does the camera need to go to use this sample code? Since this is part of the tutorial, would be very useful if there were an example, for those of us who are not experts in DirectX.
23. dubna 2012 18:02I would recommend backing up a bit and starting with a good introductory text on DirectX. Any book on Direct3D 10 or Direct3D 11 is going to apply fully to Metro style development using the DirectX 11 API, with the exception of some of the logic around Present and ICoreWindow. It would give you a much better grounding in modifying these samples.
- Navržen jako odpověď Jeff SandersMicrosoft Employee, Moderator 25. dubna 2012 11:59
28. dubna 2012 23:55
The reason nothing shows is because you have placed the camera inside the box. Since the GPU culls backface triangles by default, all the triangles of your box are culled. In other words, no matter what direction your camera is pointed, if it is located inside the box, it will be looking at the back sides of any triangle.
You may want to back your camera away from the box a bit to be able to see it.
The CreateCube creates a cube that is centered on the world origin and is 1 unit wide, high, and deep. The CreateBox method creates a box thet is 2 units tall, wide, and deep. So you have to back the camera away from the box in order to see it.
m_camera->SetViewParameters( float3(0, 1.0f, 5.0f), float3(0, 0, 0), float3(0, 1, 0) );
7. května 2012 19:09
Sorry it's taken a while to get around to answering your response. I want to be inside the box - that's the point of being a box, I presume. If I want to be outside it then the cube is perfectly fine for that particular situation. I have tried to turn off culling of blackface triangles, but unfortunately I have still been unable to see anything at all. That was one of the advantages of the WPF 3-D model, even if you're in the wrong place you could always have an idea as to where you were and then move the model or the camera or whatever.
7. května 2012 22:39
So you want a 'skybox' then?
Generally 2-sided objects are extremely expensive for 3D rendering, so you really should not turn off culling if at all possible.
7. května 2012 22:44
Haven't heard it referred to as a skybox, but if this is what you're referring to:
The interior of a box with six sides, with a texture on them, yes, that's what I'm looking for. I assumed on the basis of the fact that there is a different box and cube function in BasicShapes that the box is designed to do something similar to what I want.
Yes, I understand about culling, it's just a matter of trying to figure out where the content I'm trying to paint has turned up. Once I've got everything displaying properly that I would turn that off.