Jmuulian

Members
  • Content count

    91
  • Joined

  • Last visited

Community Reputation

126 Neutral

About Jmuulian

  • Rank
    Member
  1. That solution suits my needs quite well. Many thanks!
  2. Hi all. Slightly tricky one here. I have a template class that has more than one template argument, for example: template< class X, int N > class Foo { public: int GetValue() const; }; Now, say that I want to specialize GetValue so that it returns, say, 69 for a template argument of N = 5, but returns 42 for all other values of N. For example: Foo< char, 3 > foo1; foo1.GetValue(); // Returns 42. Foo< double, 17 > foo2; foo2.GetValue(); // Returns 42. Foo< bool, 5 > foo3; foo3.GetValue(); // Returns 69. One way that would work is to specialize the entire class for N = 5 and again for all other values, so as to provide two separate implementations of the class. For example: template< class X, int N > class Foo { public: int GetNumber() const { return 42; } }; template< class X > class Foo< X, 5 > { public: int GetNumber() const { return 69; } }; But I want to avoid this approach because while it works well for this simple example class with only one function, I am in practice trying to specialize a member function on a much larger class with many functions that would be unchanged by the specialization. Thus, I need a method to specialize only the member function in question, without duplicating the rest of class Foo. As far as I can determine, specializing the member function only works if it has a single template parameter, like so: template< int N > class Foo { public: int GetNumber() const { return 42; } }; template < int N > int Foo< N >::GetNumber() const { return 42; } template < > int Foo< 5 >::GetNumber() const { return 69; } Can anyone explain how I can apply this logic to the case of multiple template arguments? The following code, by way of example, does not compile. template< class X, int N > class Foo { public: int GetNumber() const { return 42; } }; template < class X, int N > int Foo< X, N >::GetNumber() const { return 42; } template < class X > int Foo< X, 5 >::GetNumber() const { return 69; } Any help would be greatly appreciated.
  3. Problems using D3DXWeldVertices().

    As it turns out, this problem is still present. Although D3DXWeldVertices is now creating a new output adjacency buffer, this buffer is still not what I'm expecting. The mesh I'm testing with should not have any unjoined triangle edges once the duplicate vertices are removed. So my assumption is that D3DXWeldVertices is either failing to detect all the duplicate vertices, or it isn't updating the adjacency information properly. I've tried just about every valid configuration of flags and parameters, and can't get it to work. Any suggestions? Thanks.
  4. Problems using D3DXWeldVertices().

    Yeah, I've considered that, but my understanding of the D3DXWELDEPSILONS_WELDALL flag is that it removes non-positional vertex components from the welding process: Quote:D3DXWELDEPSILONS_WELDALL Weld together all vertices that are at the same location. Using this flag avoids an epsilon comparison between vertex components.
  5. Problems using D3DXWeldVertices().

    Here's an update: The adjacency buffer I pass into D3DXWeldVertices is created using ID3DXMesh::GenerateAdjacency() using the same position epsilon parameter passed into D3DXWeldVertices. The documentation states that if the pAdjacencyIn parameter to D3DXWeldVertices is NULL, the function will call ID3DXMesh::GenerateAdjacency() for you, using your supplied position epsilon value. Yet when I pass NULL instead of generating it myself, the function appears to work correctly. The test function now returns OK.
  6. Hey all. I'm trying to eliminate duplicate (co-located) vertices from a given ID3DXMesh, and then update the mesh's triangle adjacency buffer to match the optimized mesh. So I've tried using the D3D9 function D3DXWeldVertices, but it doesn't seem to do anything. I've specified appropriate epsilon values for the position, and yet the input adjacency buffer is equal to the output adjacency buffer. I suspect that I'm missing something about how this function is supposed to work, so if anyone can set me straight I'd appreciate it. Here's the end of a function I'm using to test D3DXWeldVertices: std::vector< uint > newAdjacency; newAdjacency.resize(pMesh->GetNumFaces() * 3); D3DXWELDEPSILONS epsilons; ZeroMemory(&epsilons, sizeof(D3DXWELDEPSILONS)); epsilons.Position = 0.01f; if (FAILED(D3DXWeldVertices(pMesh, D3DXWELDEPSILONS_WELDALL, &epsilons, (const DWORD *)&adjacency[0], (DWORD *)&newAdjacency[0], NULL, NULL))) return FAIL; for (uint n = 0; n < pMesh->GetNumFaces() * 3; ++n) { if (adjacency[n] != newAdjacency[n]) { return OK; } } return FUNCTION_COMPLETED; The above code is executed and returns FUNCTION_COMPLETED, so D3DXWeldVertices is not failing, yet its output adjacency buffer is identical to its input adjacency buffer.
  7. Silly 2D array question

    Allocate like this: array = new int[numCols * numRows]; Retrieve like this: int value = array[row * numCols + col];
  8. I only skimmed over your actual article, as I'm reading this from work, so ignore me if I draw the same conclusions as you have. You would benefit by including an abstract introduction/conclusion clearly stating your answer to the question raised. Quote:When does an algorithm turn alive I'm going to rephrase your question: "When does the complexity and/or sophistication of an algorithm become sufficent so as to be considered alive?" I suggest that this question is misleading. Life, or consciousness (which is what we're really discussing here) should, IMHO, not be considered in terms of a binary distinction; things are not merely conscious or unconscious. Rather, consciousness should be defined as a spectrum. Ants at one end, Humans at the other. The more complex the algorithm, the better it performs, the higher on the scale it goes. As an excersise, rank the following objects in terms of consciousness: Human, Flower, Ant, Elevator, Screwdriver, Eliza, HAL 9000. Note first that a Flower is certainly alive, but has little consciousness. The Elevator has a basic Input/Process/Output loop - taking button presses, engaging machinery, etc. Here's my list, in ascending order of consciousness: Screwdriver, Flower, Elevator, Ant, Eliza, HAL 9000, Human. In my experience, a lot of people want to do something like this - [] denotes equal precedence: [Elevator, Screwdriver, Eliza, HAL 9000, Flower], [Ant, Human] The Philosophy of Mind is a debate that has been going on forever, but in my opinion, if you hold that there is no "ghost in the shell", then it makes no sense to start talking about consciousness as a binary distinction.
  9. Am i doomed to failure?

    Hi rimmer91. I absolutely agree that you are not doomed to fail. Maths can be learnt, like anything else. What you need to do is learn to enjoy maths. This is not as hard or ridiculous as it may seem. Your interest in games programming provides you with the enthusiasm you need to kick off an interest in maths. Start from the beginning, and take it slow. When you learn some new mathematical theory, try and imagine how it would apply to game programming. Start writing programs, implementing any new maths concepts you learn. Try and get a hold of some maths books from a game programming perspective; this would help you to understand the applications of maths in game programming. The main point is to remember that maths does not have to be a chore. Most game programmers don't learn about maths because they have to, many (myself included) are fascinated the things you can do with maths, if you know how. Here are some books that may help you: http://www.amazon.com/exec/obidos/tg/detail/-/1584502770 http://www.amazon.com/exec/obidos/tg/detail/-/1584500379 http://www.amazon.com/exec/obidos/tg/detail/-/155860863X http://www.amazon.com/exec/obidos/tg/detail/-/159200038X
  10. The Continuous World of Dungeon Siege, by Scott Bilas of Gas Powered Games
  11. No problem [wink] The reason you didn't need the trigonometric calculations is because they're already being performed when the rotation matricies are built: Rotation matrix around X given x_angle: 0, 0, 0, 0 0, cos(x_angle), sin(x_angle), 0 0, -sin(x_angle, cos(x_angle), 0 0, 0, 0, 1 Rotation matrix around Y given y_angle: cos(y_angle), 0, -sin(y_angle), 0 0, 1, 0, 0 sin(y_angle), 0, cos(y_angle), 0 0, 0, 0, 1
  12. Yeah, LilBudyWizer is right. The trigonometric calculations during input are unnecesary. During input, increase/decrease the angle around X and Y angles linearly. The Z angle should remain 0. If DirectInput_Key_State(DX_KEY_PAGE_DOWN) Then 'Look Down Camera_Angle_X += Camera_Speed_X * Time_Delta; End If Then, multiply your matrices in order of Y, X. Remember that you no longer have a Z rotation, so there will be no roll.
  13. This effect may be a result of your ordering of matrix operations. Assuming Y is up, your resulting transformation matrix should equal Y * X * Z, in that order.
  14. Random vector in cone

    If I understand the problem correctly, you want to generate a vector from two random angles to vary the inital velocity of a particle generated by the cone emitter. Given the two radii of your cone, rx and ry, define your random variation angles, vx and vy. Note that -rx < vx < rx and -ry < vy < ry. Now, given a vector v, the normalised direction of the cone from the apex, your resulting vector is the normalised sum of v and [sin(vx), sin(vy), cos(vx)]. I don't have time to double check this but I'm pretty sure it should work.
  15. Quaternion to Euler angles

    As far as I know, there is no accurate method of returning euler angles from quaternions. There are a few methods out there but usually contain hacks and will not always work perfectly. My advice is to avoid converting back to euler altogether.