Jump to content
  • Advertisement

Morrandir

Member
  • Content count

    235
  • Joined

  • Last visited

Community Reputation

304 Neutral

About Morrandir

  • Rank
    Member
  1. Hi! The issue essentially is that you have the implementation of those functions in your .h file. In C++ every .cpp file is a separate translation unit, which means it gets compiled separately to an object file (source_name.obj) which are then linked together during the linking phase. In your example, the functions implemented in pick.h get compiled into both MainApp.obj and main.obj, because they are part of both translation units (they are included in both .cpp files), so they show up as duplicates during the linking phase. To fix this, move your implementation code into a .cpp file (e.g. pick.cpp). Then it will get compiled to a separate object file and MainApp.obj and main.obj will only reference it. Hope this clears some thing up
  2. Morrandir

    progressive mesh

    Hi! Progressive meshes are a way of adjusting level of detail in a granular way. So, instead of having e.g. 3 different versions of the same mesh (e.g. 500, 2500, 5000 triangles) like in static LOD, you have only one and you can set it to any detail level (e.g. 3145 triangles, or whatever number suits you at that moment). They're used together with some decimation algorithm that can simplify meshes. It's not a technique that can be used to add detail to a mesh. For that, you might want to look into tessalation and subdivision.
  3. Morrandir

    3D FPS: Bullet Collision Detection

    Ray casting means testing if a ray intersects an object. In this case you create a ray starting form the bullet position, in the direction it is traveling in, and test for collision with all geometry in the scene (respectively with their bounding boxes). I'm not too well versed in XNA, but it seems you can use BoundingSphere.Intersects(Ray ray) for the testing. Also, for testing if this really is the problem, try to decrease the bullet speed dramatically, so that there is no chance for a bullet to skip an enemy, than shoot it at a stationary enemy and see if the collision registers. Ideally you should also draw the bullet and enemy bounding spheres so you can inspect them visually.
  4. Morrandir

    3D FPS: Bullet Collision Detection

    Hi! I would say your problem is the bullet is moving too fast for this simple collision detection to work. The bullet is in front of a character in one frame, and already behind it in the next, so the collision never registers. A simple way of fixing this is in addition to the bounding sphere test, doing a raycast forward from the bullet to check for objects the bullet is about to hit. If they are closer than the distance the bullet moves in one frame, a hit should occur.
  5. Morrandir

    Surfaces in SDL Maybe SDL_Flip()

    First thing that comes to mind is you should be checking screen and image for invalid value after their assignment. If SDL_SetVideoMode or IMG_Load fails, you end up with invalid surfaces. P.S. for posting code, use [ source ] [ /source ] tags (without the spaces)
  6. Morrandir

    very stuck with understand picking d3d

    The picking ray is a ray from the eye position through the position you clicked on the screen into the scene. It can be represented by an origin and a direction. The origin is the eye position, the direction is the vector between the eye position and the point clicked on the screen. You need the coordinates of the origin and the ray direction in worldspace to be able to construct the ray and check for intersections with objects (worldspace is like a common frame of reference, objects are transformed to worldspace by the modeling transform). You already have the eye position in world space - it's the translation component of your view matrix m. That is what the following part states: vPickRayOrig.x = m._41; vPickRayOrig.y = m._42; vPickRayOrig.z = m._43; Now you need to get the ray direction in worldspace. m is your view matrix. It is used to transform worldspace coordinates to screenspace coordinates. Here, you need to do the opposite - transform the screenspace coordinates back into worldspace. This equates to multiplying the direction vector with the inverse of the view matrix. If a matrix is orthogonal, it's inverse is the same as it's transpose. This is what the following states: vPickRayDir.x = v.x*m._11 + v.y*m._21 + v.z*m._31; vPickRayDir.y = v.x*m._12 + v.y*m._22 + v.z*m._32; vPickRayDir.z = v.x*m._13 + v.y*m._23 + v.z*m._33; where v is the ray direction in screenspace, vPickRayDir is the ray direction in worldspace, and [m._11 m._21 m._31] [m._12 m._22 m._32] [m._13 m._23 m._33] is the transpose of upper-left 3x3 part of the view matrix. Why only the upper-left 3x3 part? MichaBen's post contains the answer from a linear algebra point of view. Here's another, more down-to-earth view: a direction vector has no position, only an orientation, so transposing it doesn't make any sense. The only transformation that applies is rotation, and the upper 3x3 part of the view matrix contains the rotation. EDIT: view direction was a misleading name choice, changed it to ray direction [Edited by - Morrandir on June 14, 2009 1:12:52 PM]
  7. Read the comments in the sources for explanation: // main.cpp // you might want to double-check which of these headers you really need: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <string> #include "SDL.h" #include "SDL_image/SDL_image.h" #include "Engine.h" int main(int argc, char *argv[]) { int done = 0; // um, why would you need both the instance AND a pointer to it? Engine myGraphics; // Engine *graphics; // graphics = &myGraphics; // I don't see any reason to make these global, so I moved them here: SDL_Surface *screen = NULL; SDL_Surface *background = NULL; background = graphics.load_image("//Users//Admin1//Documents//TestGame//Images//background.png"); graphics.apply_surface(0,0, background, screen); while ( !done ) { /* Check for events */ // no need for this to be global, also it's good practice to declare // variables as close to their use as possible SDL_Event event; while ( SDL_PollEvent(&event) ) { switch (event.type) { case SDL_MOUSEMOTION: break; case SDL_MOUSEBUTTONDOWN: break; case SDL_KEYDOWN: /* Any keypress quits the app... */ case SDL_QUIT: done = 1; break; default: break; } } SDL_Flip(screen); } /* Clean up the SDL library */ SDL_Quit(); return(0); }
  8. Morrandir

    constructors and copy constructors

    Quote:Original post by MadMax1992 what is the copy assignment operator? is that: void operator = (ThisClass bla); or is it something else? Close: ThisClass& operator= (const ThisClass& other); EDIT: mistake in the return type
  9. Morrandir

    Point-Based Physics Tutorials

    Neat tutorial, good introduction to the topic and I liked the hands-on approach, definitely better than all theory, or all code with some comments thrown in. Maybe a short discussion on calculating proper timesteps wouldn't have hurt, since that's the only thing missing from it for someone to be able to incorporate some basic physics simulation into their own project based on the tutorial. But I guess there's plenty of material available on that topic already. This one didn't contain too much news for me personally, but I'm looking forward to the fluid simulation tutorial, was planning on learning about that eventually, and a tutorial will give me a nice jumpstart :) Keep up the good work!
  10. Morrandir

    constructors and copy constructors

    Quote:Original post by Manpreet Quote:Original post by DevFred 1. You can copy user-defined types without invoking the copy constructor: Foo a = b; // this calls the copy constructor a = b; // this calls the copy assignment operator Yes Yes its all coming back!! I read this in a book 3 months back that you can copy values of an object to another by directly using the '=' operator "BUT IT SHOULD NOT BE USED WHEN THE CLASS DECLARATION HAS A POINTER AS A DATA MEMBER!" Thanx for waking me up :D No, if the class has a pointer as a member and copying the pointer when copying the object is not the correct behavior (which is very often the case), you should write your own operator= and copy constructor.
  11. Morrandir

    Vector manipulation

    Quote:Original post by JamesCobras Can i have example code? JamesCobras Sure: #include <list> int main() { std::list<int> myList; myList.push_back(5); myList.push_back(3); myList.push_back(2); // here myList contains {5,3,2} int front = myList.front(); // here front contains 5 myList.pop_front(); // here myList contains {3,2} return 0; } Easy as pie.
  12. Morrandir

    Vector manipulation

    I would use a linked list in this case (such as std::list), which allows easy access from both ends. Just add to the end and remove from the beginning. You don't need random access and don't do iteration through the container, so it will behave well performance wise too.
  13. Morrandir

    Using Goto, Why is it Such a Taboo?

    There are cases when goto can be an elegant solution to a problem (although I've never had to resort to it)... however this is not one of them. This is what exceptions are for. Use them (assuming this is C++)
  14. Morrandir

    Rendering flow density field

    In that case, I would probably go with a particle system + blur. It would give the gaseous part a nice sense of 'flow', even on a still image. You can do a simple blur by blending together colors over 2-3 frames of an animation. If you won't need animation at all, maybe you could 'cheat' a little, and not use a particle system (which would be the tough part to code). Instead you could use a static image, e.g. colored dots distributed evenly, and blur that directionally. Basically for each point, look at the velocity, choose the blur kernel most appropriate for the direction, do convolution. This is off the top of my head, so you'd need to experiment a bit to make it look just right, but has promise and is super easy to code.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!