Jump to content
  • Advertisement

GlennNZ

Member
  • Content Count

    26
  • Joined

  • Last visited

Community Reputation

133 Neutral

About GlennNZ

  • Rank
    Member
  1. Thanks for the feedback guys. Those two ideas look a lot more promising than what I was going to use.
  2. I have a 3D scene with a lot of Mobiles (basically world objects that move all the time) and I'm trying to figure out the best way to organise them so as to speed up collision detection. I'm leaning towards using a kd tree to divide my game world up into a binary tree of nodes, and then adding each mobile to a node. - If there is an overlap between the mobile's bounding sphere and multiple nodes, then they go in a parent node. - Every time a mobile moves, a check is required to see if it is still in its current node, and moved to a new node if required. - A collision detection test with a mobile (mobA), would require a check between mobA and all the mobiles that are in the same node as mobA and all the mobiles that are in parent nodes. This is as about as good as I can think of, but am really keen to get some advice before I pour some hours into this. Alternatively I was thinking about using - Quad trees - Perhaps not using the kd-tree nodes as 'buckets' of mobiles but instead making each mobile a kd-tree node, so that mobiles have child mobiles. I figured this would get crazy complex when mobiles moved and the kd-tree would have to get entire branches re-added to the tree. I see there are lots of good articles on collisions between two objects, but I can't find much in the way of better organising a world of moving objects. I did find: http://www.gamedev.net/community/forums/topic.asp?topic_id=434610 Cheers for any tips.
  3. As a follow up; courtesy of one of the guys at forums.devshed.com, I have a solution. I should have added typename before HandlersMap::iterator it = mHandlers.find(id); so that I get typename HandlersMap::iterator it = mHandlers.find(id); and typename HandlersMap::iterator it = mHandlers.begin(); The devshed link is here
  4. I'm running the risk of hijacking my own thread, but it seems that it isn't just VS 2008 EE that doesn't like Sarah's sigslot code. g++ (linux and mac) also doesn't like it, but I suspect for different reasons. However, I noticed that if I use code from an article at code project (http://www.codeproject.com/KB/cpp/CppEvents.aspx), I get similar compile problems. Unfortunately my knowledge of templates and why they would cause such issues is beyond me, hence why I'm here. The error is relating to what the std::map contains, which is more templated code. Quote: sigslot_test.h: In member function ‘bool CppEvent1<ReturnT, ParamT>::detach(CppEventHandler)’: sigslot_test.h:58: error: expected `;' before ‘it’ The code looks like the following. #include <iostream> #include <map> using namespace std; typedef int CppEventHandler; template <typename ReturnT, typename ParamT> class EventHandlerBase1 { public: virtual ReturnT notify(ParamT param) = 0; }; template <typename ListenerT, typename ReturnT, typename ParamT> class EventHandler1 : public EventHandlerBase1<ReturnT, ParamT> { typedef ReturnT (ListenerT::*PtrMember)(ParamT); ListenerT* mObject; PtrMember mMember; public: EventHandler1(ListenerT* object, PtrMember member) : mObject(object), mMember(member) { } ReturnT notify(ParamT param) { return (mObject->*mMember)(param); } }; template <typename ReturnT, typename ParamT> class CppEvent1 { typedef std::map<int, EventHandlerBase1<ReturnT, ParamT> *> HandlersMap; HandlersMap mHandlers; int mCount; public: CppEvent1() : mCount(0) { } template <typename ListenerT> CppEventHandler attach(ListenerT* object, ReturnT (ListenerT::*member)(ParamT)) { typedef ReturnT (ListenerT::*PtrMember)(ParamT); mHandlers[mCount] = (new EventHandler1<ListenerT, ReturnT, ParamT>(object, member)); mCount++; return mCount-1; } bool detach(CppEventHandler id) { HandlersMap::iterator it = mHandlers.find(id); if (it == mHandlers.end()) return false; delete it->second; mHandlers.erase(it); return true; } ReturnT notify(ParamT param) { HandlersMap::iterator it = mHandlers.begin(); for (; it != mHandlers.end(); it++) { it->second->notify(param); } return true; } }; int main() { cout << "hello and welcome to yet another coding adventure\n"; } I know there are other sigslot libraries out there, (like http://s11n.net/sigslot/) but it would be nice to know the solution to this compile issue. Cheers.
  5. Thanks spookycat, that's it exactly. I can now finally wire these GUI buttons up with something a bit more elegant than my existing code. (then back to figuring out how all those templates work.) Thanks again.
  6. Line 419; the line that looks like: typedef sender_set::const_iterator const_iterator; I've also tried doing #define SIGSLOT_PURE_ISO
  7. I'm trying to compile an app with the the sigslot.h included in (http://sigslot.sourceforge.net/). However, I'm under the impression the Visual Stuio 2008 EE doesn't like it very much. Quote: Error 6 error C2146: syntax error : missing ';' before identifier 'const_iterator' Error 9 error C2146: syntax error : missing ';' before identifier 'const_iterator' Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int Error 10 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int The closest I get to someone getting a solution to this is here. http://www.gamedev.net/community/forums/topic.asp?topic_id=399191&forum_id=21&gforum_id=0 close but not close enough. Does anyone have the solution, or can offer another alternative that is as simple as what sigslot seems? (Not Boost please). Thanks.
  8. I'm starting to wonder if I am over engineering my chasing camera. What I want is a camera node to follow behind a helicopter in third person. This camera will always be (approximately) behind the helicopter. I'm wondering if I need to use SLERP to interpolate between two orientations of the camera (as it moves between two positions). I see the merits in using SLERP if I have two well defined points in the world with a start and end orientation to interpolate between, but I can't see this being useful in my situation. The reason is because if the helicopter is always moving, the start orientation and end orientation are going to be quite close. This would mean there is very little to interpolate between. This would mean there is no t value. The only way I can see a t value coming into use is if the camera moved a lot slower than the helicopter. i.e. say the helicopter moved from (0,0) facing forward to (1, 1) facing right in the space of 1 frame, however, the camera can only move 0.1 a frame. That would mean that t = 0.1 / sqrt(2). That's all good if the helicopter stayed at (1,1) so that the camera could catch up, but what happens if it keeps moving? Say by the next frame the helicopter is at (2, 2). Does that mean that when using SLERP, initial orientation is what the orientation was earlier when t = 0.1. It just seems that until the camera catches up, t will never get to 1. I'm kind of using you guys as a sounding board. It helps me think a bit better about the problem. Cheers. So yes, any insight is welcome.
  9. GlennNZ

    How to build mission files.

    I was hoping to make it easier for non coders to make their own missions, thus I figured some kind of file parsing of structured data such as XML would be a good idea. It could just be a flat file. I'd rather not have to define mission objects in code. I suppose events and actions made in response to events are all predefined. Meaning that the code to execute will be reused by different missions, although given different parameters. i.e. a PLAY_SOUND action is always executed the same, but it uses a different file to play. I suppose the question is, what is the most appropriate way of a mission designer to specify what file to play? [qoute]One simple approach would be to make each level a single lua script, which initialises all the objects, and also sets up callback functions for events (object destroyed, time elapsed, ...).[/quote] Couldn't these callback just be defined in C++? After all, it's just the attributes given to the method that change. Or is this for more complex responses to events or perhaps a way of easily changing the response to an event without having to recompile the application?
  10. I've been making a game which is of a style similar to Desert/Jungle Strike; the third person isometric helicopter shooter. We've made it 3D as a homebrew project for PSP. However, now that we can fly around and blow tanks and things up, I've gotten stuck as to how to proceed with certain aspects. There are two main problem: 1. What is the best way to load mission data 2. How do I structure the game (game engine) so that certain events in the game are responded to by certain actions as defined in the mission file. In regards to #1 I had this idea of constructing an XML file which described the mission, such as initial unit locations and positions, what structures were on the map, what the enemies' objectives were etc. That xml file would also describe what action to take if a certain event happened (#2). Say "building 1" gets blown up, then I want to play a one off audio clip when it happens. Basically, certain 'events' in the game need to be matched with an 'action' as defined in the mission file. It all got kind of messy when I tried to plan how to adapt my C++ code. I figured all events that happen in the game would 'broadcast' a message by sending what event had occurred and some accompanying data. Some mission object would listen to the events being broadcast, and respond to the ones that it cared about. The response would be the actions as defined in the xml. This then raised the question of how to represent the different actions in the xml because they tended to have different attributes. i.e. playing an audio clip required only a path to some audio, whereas, deploying a new unit to the map required unit name, position, orientation etc. Then I remembered about scripting and Lua. I don't want to risk investing too much time into Lua if it doesn't solve my current problems of defining mission files. Basically data to describe the mission is important for turning the game into a show and tell item into something that is slightly more meaningful. The problem is that no resources I've found about Lua have made a solution to my problem really obvious. Admittedly, I haven't invested too much time into it as yet, so I figured what better way to get some ideas from people other than the guys at work, than to post at GDNet. I hope that was all clear, basically I'm trying to find some better methods of defining missions, respond to game events, and whether scripting is the answer. Cheers
  11. Quote:Original post by davek20 The only thing that comes to mind is that the the number of vertices is more than 255 (the amount in an unsigned byte). I think I had a similar problem when I was making VBOs, I ran out of indices and it turned into triangle soup and decided to bump it up to unsigned ints (although I think I could have used unsigned shorts). 5 gold stars for you davek20; that was exactly the problem. Funny that, because I had wondered if my .obj loader issues were because of a size limit to a vertex array. I didn't realise I was causing size constraint. (Note to self: ubyte isn't as big as you think it is). Thanks for the help.
  12. I'm having difficulties figuring out why my .obj loader produces data that I can use to render with GL_TRIANGLES but can't with vertex arrays. I get an array of normals and vertices and the number of indices so that I can render my object like so... glBegin(GL_TRIANGLES); for (int i=0; i<mNumIndices; i++) { glNormal3f(mNormals[3*i], mNormals[3*i+1], mNormals[3*i+2]); glVertex3f(mVertices[3*i], mVertices[3*i+1], mVertices[3*i+2]); } glEnd(); But if I try and render using a vertex array, I can only render simple objects like a cube or a dodecahedron. More complex models look like triangle soup, with missing faces and other oddities. glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glVertexPointer(3, GL_FLOAT, 0, mVertices); glNormalPointer(GL_FLOAT, 0, mNormals); glDrawElements(GL_TRIANGLES, mNumIndices, GL_UNSIGNED_BYTE, mIndices); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); mIndices is just {0,1,2,3,4...} because every vertex in the .obj file is regarded as unique. Does anyone have some ideas as to how I've mucked this up. Cheers
  13. GlennNZ

    How to calculate deflection shooting?

    Quote:Original post by alvaro I don't see the typo on the other thread. I said (s^2-(v.v))*t^2 - (2*((A-B).v))*t - (A-B).(A-B) = 0 Sorry, I misinterpreted the brackets. Thanks for the help. I'm in awe of some of the techniques you've used; most notably where instead of having to deal with (A-B+tv).(A-B+tv), you just stuck the A-B in brackets which made everything so much simpler. I had completely forgotten about the quadratic formula which makes finding the values of t simpler (I mention this for the sake of anyone else reading this thread). I would still like to know where erissian was heading with N. I was trying to do this way originally but got stuck at that point. Regardless, I can make some progress with coding now. [Edited by - GlennNZ on April 26, 2008 3:40:59 AM]
  14. GlennNZ

    How to calculate deflection shooting?

    Thanks for the feedback. This is a difficult thing to search for because the key words are unclear. I call it 'deflection shooting' whereas the link that alvaro has pointed to calls it 'target leading'. Of course, my search on google ends up with flight sim related sites. I'm under the impression that both of your two methods stated (alvaro and errisian), take a slightly different strategy. Alvaro's seems to use the distance of vectors and not use a variable to represent the unknown velocity of the bullet. I've filled up lots of pad paper but I'm pretty sure I get Alvaro's strategy up to point. I get t2( (v.v) - s2) + 2t(v.(A-B)) + (A-B).(A-B) = 0 where I'm assuming there was a typo in linked thread, but unfortunately I don't see how to sift out the two answers for t. I suppose I've never had to deal with so many dots before when dealing with parametrics. (this is using the variables used in the other thread). And in regards to errisian's strategy; I understand how N is calculated, but how can I use that knowledge to calculate the two values of t? If PB = PE + (vN)t and N = as stated above, then I get... PB = PE + ((PP - PE) / t + VP)t = PP - VPt Do I go from here? [Edited by - GlennNZ on April 25, 2008 7:22:10 AM]
  15. I was hoping this was going to be a simple simultaneous equation but it got more difficult than I expected. I have a 3D helicopter game where enemy bots shoot at the playable helicopter. I would like to get some accuracy by making the AI perform 'deflection shooting' so that the bullets have a greater chance of hitting. I'm struggling to do it on paper, and even if I got that far, I don't think I'd know how to translate that into code because there is all this math that gets done in my head. Here is what I know - The initial position of the helcopter (H_0) - The velocity of the helicopter (H_v) - The initial position of the enemies bullets (B_0) - The magnitude of the velocity of the bullets (B_m) What I need to calculate is the velocity (magnitude + direction)(B_v) of the bullets fired at the helicopter so that the helicopter and the bullets meet at the same point. The equation for calculating final position using and init pos and velocity is p = p_0 + vt so... H_0 + H_v * t = B_0 + B_v * t This stuff is really hard to demonstrate with ASCII, but I was trying to do it on paper where H_0 = (1,2) H_v = (1,1) B_0 = (5,1) B_v = ? (but magnitude = 2) I was trying to do simulatenous equations but I got in an awful tangle. Should I be using matrices? Cheers for any help.
  • 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!