|
|
(6 intermediate revisions by the same user not shown) |
Line 12: |
Line 12: |
| GitHub Repository: [https://github.com/DanVentura DanVentura@github] | | GitHub Repository: [https://github.com/DanVentura DanVentura@github] |
| | | |
− | <h1>OSD600</h1> | + | <h1>Course Work</h1> |
− | <h4>Firefox Build</h4>
| + | Due to increased content, and in the interest of organization, I've seperated my courses into individual pages: |
− | [http://dsventura.blogspot.com/2011/01/osd600-building-firefox-4-minefield.html Building Firefox 4 - Minefield]
| |
− | <h2>0.1</h2>
| |
− | <h4>Processing.js</h4>
| |
− | [https://processing-js.lighthouseapp.com/projects/41284/tickets/946-unexpected-result-when-converting-char-to-str 946-Converting Char to String]
| |
| | | |
− | [https://github.com/DanVentura/processing-js/commit/87db5dc6558dc71e7f67f95467814b3219414533 Source] | + | [http://zenit.senecac.on.ca/wiki/index.php/DsventuraOSD600 OSD600] |
− | <h4>Popcorn.js</h4>
| |
− | <strike>[https://webmademovies.lighthouseapp.com/projects/63272/tickets/127-make-it-easier-to-specify-subtitles 127-Make it easier to specify subtitles]</strike>
| |
| | | |
− | <strike>[https://github.com/DanVentura/popcorn-js/tree/bug127/plugins/subtitle Source]</strike>
| + | [http://zenit.senecac.on.ca/wiki/index.php/DsventuraGAM670 GAM670] |
− | | |
− | Note: this bug is invalid, however I created subtitle unit tests in the process. (popcorn.subtitle.unit.js and popcorn.subtitle.unit.html)
| |
− | | |
− | [https://webmademovies.lighthouseapp.com/projects/63272-popcornjs/tickets/305-create-unit-tests-for-subtitle-lowerthird-plugins 305-Create Unit tests for subtitle plugin]
| |
− | | |
− | [https://github.com/DanVentura/popcorn-js/commit/8a887407f773a151867953aec25217e2571a9cf2 Source]
| |
− | <h2>0.2</h2>
| |
− | <h4>Popcorn.js</h4>
| |
− | [https://webmademovies.lighthouseapp.com/projects/63272/tickets/321-create-pluginsindexhtml 321-Create plugins/index.html]
| |
− | | |
− | [https://github.com/DanVentura/popcorn-js/blob/t321b/plugins/index.html Source]
| |
− | | |
− | [https://webmademovies.lighthouseapp.com/projects/63272/tickets/331-create-a-facebook-plugin 331-Create a Facebook plugin]
| |
− | | |
− | [https://github.com/DanVentura/popcorn-js/tree/t331/plugins/facebook Source]
| |
− | | |
− | <h1>GAM670 - XAnimation</h1>
| |
− | <h2>Source Code</h2>
| |
− | [http://matrix.senecac.on.ca/~dsventura/animations-mergedTo28-Off-Screen-Rendering.zip MeshHierarchy, MeshStructs and XObject] | |
− | | |
− | Note: add xObject code to Object.h and Object.cpp
| |
− | <h2>Overview</h2>
| |
− | Animation in DirectX9 can be done using .X files. The .X extension refers to a file containing a Microsoft proprietary format for exported 3D models. This format is similar to COLLADA, except the file parsing is handled by DirectX internally. To export a model in .X format in 3Ds MAX, I used a plugin from PandaSoft called the Panda DirectX Max exporter (link on last page).
| |
− | | |
− | | |
− | Once exported, the file contains information each object and maintains their hierarchical relationships between each object. Each object has a frame container and a mesh container. The frame contains information for positioning, while the mesh contains mesh related information such as: bones, textures, etc. To perform skeletal information, the frames must be arranged in an inheritance hierarchy so that the frame's matrix transformations would be relative to it's parent, respectively (Figure 1).
| |
− | | |
− | [[Image:FrameMeshHierarchyExample.png]]
| |
− | | |
− | (*Source - http://www.toymaker.info/Games/html/load_x_hierarchy.html)
| |
− | | |
− | '''Figure 1:''' Inheritance hierarchy consisting of a body and two arms. (“Left Arm Frame” would be a shoulder or joint. The name in this diagram may be misleading)
| |
− | | |
− | | |
− | This hierarchy would be established in 3Ds MAX through linking. For more information on how to use bones and make skeletal animations in 3Ds MAX, refer to the references.
| |
− | | |
− | In order to properly load this information, we first need to do a little inheritance of some structs to make our lives easier (refer to MeshStructs.h). We need to extend D3DXMESHCONTAINER and D3DXFRAME with some extra data so we can support skinning. Basically, skinning is a technique where you combine the frame (bone) and mesh (skin) matrices so that the mesh's vertex positions will be altered depending on the frame's movement; making the mesh stretch and contract like actual skin. For more information on skinning, refer to the “X File Hierarchy Loading” link in references.
| |
− | | |
− | | |
− | Once we have extended the structures, we have to implement the ID3DXAllocateHierarchy interface to support the extra information we've put into these structures and load the file properly. These functions are called internally as the D3DXloadMeshHierarchyFromX function parses the .X file. (refer to MeshHierarchy.h)
| |
− | | |
− | | |
− | To put all of this into the framework, we create an XObject class which is derived from Object. This will hold model information as well as the animation controller. It will also hold information that allows us to change animation sets and the speed of the animation. (refer to XObject.h)
| |
− | <h2>Putting It Into The Framework</h2>
| |
− | <h3>Configuration.h</h3>
| |
− | Assuming you put your animations into ../../resources/animations, put this into config:
| |
− | <pre>#define ANIMATION_DIRECTORY L"resources\\animations"</pre>
| |
− | The utilities function will handle going up 2 directory levels.
| |
− | <h3>Display.cpp</h3>
| |
− | Pass the display device to XObject (Display::setup()):
| |
− | <pre>XObject::connectDevice(d3dd);</pre>
| |
− | <h3>Utilities.cpp</h3>
| |
− | to be added...
| |
− | <h3>Object</h3>
| |
− | 1. Throw this into the header file:
| |
− | <pre>#include "MeshHierarchy.h"</pre>
| |
− | 2. Make a default contructor for Object. Textures and what-not are handled already. (Note: May want to change parameters if, for example, you want to make a non-opaque XObject)
| |
− | <pre>
| |
− | Object::Object(Colour c) : category(OPAQUE_OBJECT), graphic(NULL), texture(NULL),
| |
− | material(NULL), shine(NULL) {
| |
− | if (!coordinator)
| |
− | error(L"Object::00 Couldn\'t access the Scene Coordinator");
| |
− | else if(!coordinator->add(this))
| |
− | error(L"Object::01 Couldn\'t add object to the Scene Coordinator");
| |
− | }
| |
− | </pre>
| |
− | <h2>Known Issues</h2>
| |
− | <h3>CreateFrame() and CreateMeshContainer</h3>
| |
− | In both CreateFrame and CreateMeshContainer, name was never set in the original code. If you were to implement this code yourself, make sure you set the frame or mesh container's name to the Name parameter. Forgetting to do this will make the animation controller always return NULL from the D3DXLoadMeshHierarchyFromX call.
| |
− | <pre>
| |
− | // for CreateFrame
| |
− | if(Name){
| |
− | newFrame->Name = new char[strlen(Name)+1];
| |
− | strcpy(newFrame->Name, Name);
| |
− | newFrame->Name[strlen(Name)] = 0;
| |
− | }
| |
− | </pre>
| |
− | <h3>DestroyFrame() and DestroyMeshContainer()</h3>
| |
− | <pre>
| |
− | if(meshContainer->Name)
| |
− | delete []meshContainer->Name;
| |
− | </pre>
| |
− | <h3>XObject::Draw()</h3>
| |
− | This line used to be in the draw function:
| |
− | <pre>
| |
− | static DWORD lastTime=timeGetTime();
| |
− | </pre>
| |
− | The problem arose when I put multiple instances of XObject in design. Due to the static keyword, this variable would be shared among all of the animated objects. The first animation would run smoothly, while any animations added afterwords would be extremely slow. This is because this variable tells the function when the last time it drew the object's state along the animation time-line, and each object's time-line is different. To fix this, I made last time a data member and initialized it to 0 in the constructor.
| |
− | <h3>Scene.cpp - ViewingFrustum()</h3>
| |
− | I have no idea why, but I kept getting errors from these lines:
| |
− | <pre>
| |
− | float far = context->get(GF_FR_FAR);
| |
− | float near = context->get(GF_FR_NEAR);
| |
− | </pre>
| |
− | All I did was remove these variables and put the values where they are used. In other words I did this:
| |
− | <pre>
| |
− | plane[0] = new Plane(heading, - n_p - context->get(GF_FR_NEAR));
| |
− | plane[1] = new Plane(-heading, n_p + context->get(GF_FR_FAR) );
| |
− | </pre>
| |
− | Out of all the errors I've encountered, I have no explanation for this one :S
| |
− | <h2>References</h2>
| |
− | <h4>Panda Exporter (32-bit)</h4>
| |
− | [http://www.andytather.co.uk/Panda/Files/3dsmax2011/PandaDirectXMaxExporter_x86_6.2011.71.0.zip http://www.andytather.co.uk/Panda/Files/3dsmax2011/PandaDirectXMaxExporter_x86_6.2011.71.0.zip]
| |
− | <h4>XAnimator - Source code and Reference</h4>
| |
− | Ditchburn, Keith. “X File Hierarchy Loading”. Toymaker.
| |
− | | |
− | <[http://www.toymaker.info/Games/html/load_x_hierarchy.html http://www.toymaker.info/Games/html/load_x_hierarchy.html]>
| |
− | <h4>Skeletal Animation in 3Ds MAX Tutorial</h4>
| |
− | 3dcognition. “Super Simple Humanoid Character Skeleton using Bones in 3ds Max”. YouTube.
| |
− | | |
− | <[http://www.youtube.com/ http://www.youtube.com/]>
| |