• Content count

  • Joined

  • Last visited

Community Reputation

280 Neutral

About flammable

  • Rank
  1. Hey,   The simplest method is using: ISceneCollisionManager::getSceneNodeFromScreenCoordinatesBB This method only takes bounding boxes into consideration though, if you need more precision you should probably use  line3d<f32> ray = colmgr->getRayFromScreenCoordinates(device->getCursorControl()->getPosition(), camera); This returns a ray which goes though the camera and points to where the cursor is pointing, then use: ISceneCollisionManager::getSceneNodeAndCollisionPointFromRay to find the first scene node intersecting this ray   links: http://irrlicht.sourceforge.net/forum/viewtopic.php?t=38725 http://irrlicht.sourceforge.net/docu/classirr_1_1scene_1_1_i_scene_collision_manager.html
  2. How to send notification in Facebook API!

    You might want to have a look at this thread: http://stackoverflow.com/questions/12266593/how-to-use-new-client-side-facebook-notifications-api
  3. Thanks for your replies. That's alot of usefull information. Seperating dynamic and static nodes is something I'm going to work on.   Thank you guys!
  4. Hey,   I could use some of your input on a problem I'm having (I'm using Java).   I'm writing a Node class which keeps track of the transformation of objects in my game world. This class contains position, rotation and scale fields for getting and setting the objects transformation and a transformation matrix for quick and easy calculations. The problem lies in the fact that this matrix must be updated to match the current transformation every frame, but only when necessary. If the transformation of the node has not changed I would like not to recalculate the transformation matrix. As scene's in my game consist of a mixure of static and dynamic objects I feel such a optimisation can be worthwhile.   Well... in C++ this would easily be solved by a construction like: class Node { private: Vector position; bool isDirty; public: void setPosition(const Vector& p) { position = p; isDirty = true; } void move(const Vector& p) { position += p; isDirty = true; } const Vector& getPosition() const { return position; } void update() { if (isDirty) recalculate(); } } However in Java you can't have const references thus making it possible to do: node.getPosition().set(0, 0). This makes the approach using a isDirty flag quite inpractical. Now I'm looking into other solutions:   Still use the isDirty flag and let the getPosition() method set the isDirty flag to true aswell. This would work and is quite easy but would also lead to some unnecessary recalculation of the transformation matrix. Use the implementation as above and make it a rule not to modify the value returned by getPosition. This could also work but is not at all safe and will lead to untraceable bugs if you forget the rule. Store the previous transformation state of the node and do a comparison with the current one to see if recalculation is needed. I'm not really a fan of this solution as it makes the Node class quite a lot bigger and introduces a lot of 'epsilon comparisons' to the update method. Store a hashcode of the previous transformation state and compare this to the hashcode of the current transformation. I'm not sure about this one either. It introduces extra calculation in cases where the transformation matrix needs to be updated and there is a risk of a 'hashcode collision' which would lead to completely untraceable bugs (I have no idea what the chance on this is though) Just recalculate the transformation matrix every frame. I was hoping you guys might have an other solution or have some opinions about the solutions I came up with.   Thanks in advance.
  5. 2 c++ problems

    Thanks for the quick replies . [member='panic'] your solution worked and my second problem is now solved [member='NightCreature83'] your post was a big ohhhh... "I should have known" moment, I understand what the problem is know, guess I keep things as they are now. Thanks again.
  6. Hey, I'm having two problems while trying to make a game (I'm using Visual Studio 2010 Express) [b]1) Trouble with renaming a namespace:[/b] What I'm trying to do is put all classes in an namespace of an library I'm using into my own namespace, so I don't have to work with different namespaces. what i'm doing is: [code]namespace Engine { using namespace sf; } // namespace Engine = sf; doesn't work because the namespace already exists[/code] But If I do this I get all kinds of errors about types that are not convertable when using templates (smart pointers). Like: [code] error C2440: 'initializing' : cannot convert from 'boost::shared_ptr<T>' to 'boost::shared_ptr<T>' with [ T=sf::RenderWindow ] and [ T=Engine::RenderWindow ][/code]I do understand why this error occurs but is there a work around or do I have to use 2 namespaces? [b]2) A bad combination of inheritance, polymorphism and void pointers.[/b] I have a listener class with callback functions which other classes inherit from, using virtual functions the overridden function is called, quite standard. But the catch is: The physics engine I'm using stores userdata as void* pointers, what I try to do is store the listener in the userdata (as void*) and then cast it to the listener class pointer and call the callback function but that where it goes wrong. This is the simplified problem: [code] class Listener { public: virtual void onEvent() = 0; }; class MyListener : public Listener { public: virtual void onEvent() {}; }; int main() { MyListener* listener = new MyListener(); PhysicsBody.userData = static_cast<void*>(listener); do things } void onEvent(PhysicsBody body) { Listener* listener = static_cast<Listener*>(body.userData); listener->onEvent(); // Runtime error about memory violation; // dynamic_cast<Listener*>(body.userData) // gives a compilation error } [/code] I'm guessing the error is caused because the casting to void* discards the runtime information about the pointer and then when you cast it back try to use it again. But the question is what to do about it? I'm quite clueless and there don't seem to be any solution without completely redesign my programming. Thanks in advance.
  7. Inheritance and base class pointers

    I don't know how your actual design looks like but the most simple solution would be to include sortval in your base class (this is probably where you are looking for). class A { public: string Name; int Sortval; // You could also make a virtual set and get methods: virtual int getSortval() {return Sortval;} virtual void setSortval(int sortval) {Sortval = sortval;} }; class B : public A{ public: }; class C : public A{ public: }; A* Test = new C; std::cout << Test->Sortval << '\n'; I hope this solution fits in your design (but if you want to sort your container every value needs to contain a sortval, so probably yes). Another solution (which is I think more complicated than necessary) is to create a struct which holds a sortval and a pointer to the base class, like this: struct Value // or a class doesn't matter { int Sortval; A* Pointer; }; Value First = {1, new B}; Value Second = {2, new C}; But I would definitely prefer the first solution.
  8. Hey, I got 2 questions regarding design pattern related to game programming. All of my previous projects we're a complete mess (the programming part) but they we're quite small so it was manageble (but it was absolutely no joy to work with). Now I'm planning to make a more complicated game and I want to keep it manageable. I found a power-point about the design of game which was quite good but because there was no speech I think I missed some points. 1) My first question is about a queue design: According to the power-point it is better to let all the game entities communicate with each other through a Queue. something like: Bad: Player < ---- > Enemy (and a lot more of entities like: bullets, pick ups etc) Good: Player <---> Queue <----> Enemy Well indeed the queue design looks nicer but I don't understand how it should be implemented. What does the player "say" to the queue and what does the queue "say" to the enemy (for example)? 2) The second question is about the model view controller pattern. I understand (mostly) how it works but how is it used in a game context? A PlayerModel keeps the position of the player, a PlayerView draws a model at that position and a PlayerController changes the positon when the user pushes a key? But what if the game logic needs the model of the player to determine if the player is visible for an enemy? (I now realise that my question makes clear I don't understand how the MVC pattern works) 3) Can you think of some open-source projects I can take a look at to get a idea of how these things are done? Thanks in advance. ps: I know this post has a "Write games not engines" factor.
  9. I don't know much about networking but I've found some things you migth want to read: link 1 link 2 link 3 (gamedev thread) the basic idea of many server-client based games is: a server keeps the state of the world, clients send events to the server (e.g. button pressed), server sends updates to the clients one in a [a certain timestep]. There are more approaches to this problem, all with there own advanteges. There are also some techniques that can be used to improve the client-server system such as interpolation. (btw: perfect synchronization does not exist, all you can do is cover up that you are somewhat behind) <- this last statement is not entirely true, sorry (see next post by Antheus) [Edited by - flammable on August 10, 2010 7:12:06 AM]
  10. -You could first render the sky with depth writing disabled. By not writing any depth, all object rendered after the sky will be in front of it. - Or just make the sky shpere/box/drome very very large. ps: glDepthMask(bool flag) is the function you need to disable/enable depth writing (at least in openGL 1.0/2.0 don't know about 3+). (true is enable write, false is disable)
  11. The Unreal Engine is a graphics engine: You basicly say to it: draw this model on that position and draw a explosion here (somewhat simplified :P). Unreal Development Kit is a development kit: A free version of the Unreal Engine. Unreal tounament: Is a game made with the Unreal Engine :). And a suggestion: Pick one language + one engine/sdk and stick with it :) and pick something (relatively) simple. And one more thing: start simple, making a tetris game is harder than it looks. I hope this helps :) [Edited by - flammable on June 21, 2010 12:27:43 PM]
  12. C++ templates

    [edit] mmm Metsan was just a little bit faster with the same answer :) [/edit] This FAQ covers the question what causes your problem and (probably more important) how you can avoid it: the FAQ
  13. Collision from above?

    The very easy approche is to look at the y values of the centers of the rects. if the center of A is say 50 units higher than B when colliding the top and bottom must be touching. void onCollision(const Rect& A, const Rect& B) { if (A.Center.y > B.Center.y + A_CERTAIN_OFFSET) { // A's bottom collides with B's top! do something! } } offcourse this is not a very high-tech solution but sometimes it can be enough. ps: I don't know much about SDL_Rect and they'll probably don't have a center attribute right away but calculating it can't be hard :)
  14. putting friend class B; anywhere in the declaration of class A will make every private/protected member accessible (only) for class B. is that what you need? ps: there are some things with the friend "relationship" you should know of and I can't find a good tutorial/paper anywhere so I'll try to recall them myself: 1) It's a one-way "relationship" if B is a friend of A, A isn't a friend of B. 2) classes that inherit from B are not friend with A (not 100% sure though). 3) you can also only declare functions as friend: friend void doFoo(int); friend int B::justAFunction();
  15. Thanks, I see now that I misunderstood the extern concept, that explains alot. I know what a singleton is and you're right it's probably better go for singletons. Thanks