Advertisement

Move Triangle in DirectX 11.1

Started by March 17, 2015 08:39 PM
1 comment, last by Tom Sloper 9 years, 9 months ago

I'm beginner in DirectX 11.1 programming and I followed DirectXTutorial Website until here: http://directxtutorial.com/Lesson.aspx?lessonid=111-4-5 (I've written that code on hwnd or Win32 Structure instead of WinRT)

would you please help me about how I can move that triangle using arrows key ? am I have to move them using plus and minus vertex variable ? how to write the vertex buffer ? how to use vertex shader to transform my triangle positions ?

Thanks :)

This is stuff you should be looking up so I'm not going to detail extensively, however.

Usually to move things in a 3d world you modify the world transform for each object. You should have learned the basic idea already that the vertex shader(among other things) is essentially responsible for determining the final position of each vertex. It does that by multiplying the vertex position by the world-view-projection matrix, which is a matrix created by multiplying the world transform(essentially the position, rotation, scaling of the object in the world relative to the world origin) by the view and projection matrices(you can look that up.)

Hence to move the triangle you would change the world matrix, moving it in either direction based on which of your keys are hit. Usually you don't want to physically modify the vertices for each object. For a triangle that might seem strange but think of if your triangle was a model with 10k vertices. Moving each one by hand would be quite a nightmare.

Usually your most simplistic shader will take inputs for either the WVP matrix or the seperate matrices and combine them inside the shader, the difference lying in where you want to do the computation, on the cpu or on the gpu.

Advertisement
Question is being discussed in DirectX form. Closed.

-- Tom Sloper -- sloperama.com

This topic is closed to new replies.

Advertisement