Open main menu

CDOT Wiki β

Changes

User:Dsventura

1,076 bytes added, 09:49, 5 April 2011
added utilities function and updated scene problem info
<pre>XObject::connectDevice(d3dd);</pre>
<h3>Utilities.cpp</h3>
1. Add a prototype to be addediUtilities.h:<pre>void UpALevel(wchar_t* dir, int numOfLvls = 1);</pre>2. Include this in Utilities.cpp:<pre>#define WIN32_LEAN_AND_MEAN#include <windows.h> // for SetCurrentDirectory()</pre>3.Here's the Utilities.cpp function:<pre>void UpALevel(wchar_t* dir, int numOfLvls){ int i = 0;  for(int x = 0; x < numOfLvls; x++){ i = strlen(dir)-1; if(dir[i] == L'\\'){ dir[i] = NULL; i--; } for(i; dir[i] != L'\\'; i--) dir[i] = NULL; SetCurrentDirectory(dir); }}</pre>
<h3>Object</h3>
1. Make some virtual functions for iObject.h and Object.h to control the animation from Design.cpp. Controls include changing the animation set as well as the animation speed. From iObject.h:<pre>virtual void animateFaster() = 0;virtual void animateSlower() = 0;virtual void nextAnimation() = 0;virtual void previousAnimation() = 0;...extern "C"iObject* CreateXObject(wchar_t* filename);</pre>Also, make empty virtual functions for the Object class in Object.h 2. Throw this into the header fileObject.h:
<pre>#include "MeshHierarchy.h"</pre>
23. 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),
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 lastTime 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:found an error in Scene.cpp's ViewingFrustum constructor
<pre>
float far = context->get(GF_FR_FAR);
float near = context->get(GF_FR_NEAR);
</pre>
All I did was remove these variables Turns out far and put near are reserved names from waaay back. Visual Studio won't tell you that though... Throw an underscore at the end of the variable name to fix the values where they are usedproblem. In other words I did this:
<pre>
float far_ = context->get(GF_FR_FAR);float near_ = context->get(GF_FR_NEAR);...plane[0] = new Plane(heading, - n_p - context->get(GF_FR_NEAR)near_);plane[1] = new Plane(-heading, n_p + context->get(GF_FR_FAR) 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>
1
edit