So this week we worked on getting things moving around. In my case, you could use "aswd" (lower case) to move both triangles around.
The first intuitive thing that could help could be thinking over to decide which engine structure to apply for future. I finally took the component approach which kind of intentionally mimic Unity. I have GameObject which contains position and name info. It also keeps a list of possible components. Every component keeps a reference of the GameObject to which it is added. Renerable inherits from component class and keeps a static list of renderable components. It calls every renderable component to set effect (if necessary), set uniform position obtained from GameObject reference, and then draw mesh. Controller is another child class of component. WSAD controller used for triangles inherits from controller class which keeps a list of all controller component waiting to be called in update just like renderable components. As two separate controller is added to each triangle, time class is refactored into class whose instance is kept with controller instance to measure time separately.
During refactoring, forward declaration is preferred in order to save compile time as well as avoid circular dependency. Meanwhile, I was unfortunately that I met the weird bug that d3d9xshader is could not be found during building. Forward declaration also works for solving this problem.
During refactoring, forward declaration is preferred in order to save compile time as well as avoid circular dependency. Meanwhile, I was unfortunately that I met the weird bug that d3d9xshader is could not be found during building. Forward declaration also works for solving this problem.
Compared to vertex data, uniforms are variables that could be modified during frame to affect graphic effects. Vertex data is more "fixed" data that used to express all-time constant such as relative position of vertex from the center of gameobjects. The benefit of using uniform for representing offset is that we could change relatively fewer parameters compared to changing all vertex data. In future assignments, uniforms will also be added to fragment shader to manipulate color effects.
Here's a copy of executable:
Here's a copy of executable:
assignment07.zip |