• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About charisma_tubagus

  • Rank
  1. A* with Binary Heap error

    The parent object pointers have been initialized in a particular method. Inside my AStarHeap project you can inspect the codes and debug.
  2. A* with Binary Heap error

    Hi, I am facing a lot of problem when reading assembly language. This is the print screen of debugging with Assembly language. It got an error on this particular line. [img]http://img256.imageshack.us/img256/6742/debugginginassembly2.png[/img]
  3. A* with Binary Heap error

    Phew...that's a nasty debugging skill I should have. I wil try to revise my Microprocessor Programming concept and theory for this matter. Let me get back to you once I got 'something' from it. Thanks. [img]http://public.gamedev.net//public/style_emoticons/default/mellow.png[/img]
  4. A* with Binary Heap error

    [img]http://img850.imageshack.us/img850/3345/astarerrormemoryviolati.png[/img] That's what I got the error when debugging. Anyway that I can understand this message?
  5. A* with Binary Heap error

    Hi, You were right, it does something to do with NULL pointer. Have you tried to create VS 2010 project and copy my source codes? You will see the error looks something like the image attached.[img]http://img9.imageshack.us/img9/1476/astarnullpointererror.png[/img]
  6. A* with Binary Heap error

    Hi, I have just started learning A* and I did successfully to implement with std::vector in C++. However, when I am integrating my Binary Heap implementation, I have problems with POINTER etc and I have spent much time to debug but still could not get a solution of it. May I ask for a little help? PROBLEM: Whenever I want to access the parent pointer it will give me run time error. The same algorithm (A*) runs smoothly when I am using std::vector. Inside my CellNode.h [CODE] void Print(){ cout << "Cell Node id : " << m_id << " ("<<m_xcoord << " , " << m_zcoord << ")" <<" F = "<< getF() << " G = " << getG() << " H = " << getH(); if ( parent != 0){ cout << "Cell Node Parent id " << parent->m_id << endl; } else{ cout << endl; } } [/CODE] It enters the if condition but it doesn't have any parent reference. I am pretty much confused with this. In the implementation I am using Visual Studio 2010 and OpenGL as the graphics rendering. Any kind of help is much appreciated.. Thanks. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
  7. Hi I have tried to implement Binary Heap(Min priority queue) using C++ Templates. But when I test it inside my main program, it cannot compile. Do you have any idea? [b]File : BHeap.h [/b] [CODE] /* This is a class implementation of Binary Heap to optimize A* It has O(log n) for insertion and deletion to the heap with sorting capability */ #ifndef BHEAP_H #define BHEAP_H #include <iostream> #include <string> using namespace std; template<class T> class BHeap { public: BHeap() : DEFAULT_SIZE(100){ data = new T[DEFAULT_SIZE]; m_capacity = DEFAULT_SIZE; m_count = 0; } ~BHeap(){ delete [] data; } int size() const{ return m_count; } bool isEmpty() const{ return m_count == 0; } void setCapacity(int newCapacity){ if ( newCapacity > m_capacity){ //allocate new capacity T *newData = new T[newCapacity]; memcpy_s(newData, newCapacity, data, m_count); m_capacity = newCapacity; //copy old data to new data data = newData; delete [] newData; } } void Add(T item); void DownHeap(); void UpHeap(); T Peek(); T Remove(); private: const int DEFAULT_SIZE; T *data; //array of data in the heap int m_count; //count the number of element in the heap int m_capacity; //to indicate the current capacity in the heap bool sorted; //boolean variable to test whether it is sorted int Child1(int idx){ return (idx << 1) + 1; //Child 1 index = (2 * parentIndex) + 1 } int Child2(int idx){ return (idx << 1) + 2; //Child 2 index = (2 * parentIndex ) +2 } int Parent(int idx){ return (idx - 1 ) >> 1; //Parent index = (childIndex -1 ) / 2 } //void EnsureSort(); }; //#include "BHeap.cpp" #endif [/CODE] [b]File: BHeap.cpp[/b] [CODE] #include "BHeap.h" //template<typename T> //BHeap<T>::BHeap() : DEFAULT_SIZE(100) //{ // data = new T[DEFAULT_SIZE]; // m_capacity = DEFAULT_SIZE; // m_count = 0; //} // //template<typename T> //BHeap<T>::~BHeap() //{ // delete [] T; //} template<class T> T BHeap<T>::Peek(){ return data[0]; } template<class T> void BHeap<T>::Add(T item){ if ( m_count == m_capacity){ setCapacity(2 * m_capacity); } data[m_count] = item; UpHeap(); m_count++; } template<class T> void BHeap<T>::DownHeap(){ ///TODO: int currentIdx =0; int n; T item = data[currentIdx]; //we try to bubble down the root element while(true){ int child1, child2; child1 = Child1(currentIndex); child2 = Child2(currentIndex); //find the correct comparison index of child1 and child2 if ( child1 >= m_count) break; if ( child2 >= m_count) n = child1; else{ n = (data[child1] < data[child2] )? child1 : child2; } //swap nodes if necessary if ( item > data[n]){ //if item is greater than data[n] data[currentIndex] = data[n]; currentIndex = n; } else{ break; } } data[n] = item; } template<class T> void BHeap<T>::UpHeap(){ ///TODO: int childIndex = m_count; T item = data[childIndex]; int parentIndex = Parent(childIndex); while (parentIndex > -1 && item < data[parentIndex]) { data[childIndex] = data[parentIndex]; //Swap nodes childIndex = parentIndex; parentIndex = Parent(childIndex); } data[childIndex] = item; } template<class T> T BHeap<T>::Remove(){ if ( isEmpty()){ cout << "Heap is already empty " << endl; return NULL; } T v = Peek(); m_count--; data[0] = data[m_count]; data[m_count] = default(T); DownHeap(); return v; } [/CODE] [b]Problem: I cannot use the BHeap implementation:[/b] [CODE] #include <cstdlib> #include <time.h> using namespace std; #include "BHeap.h" int main(int argc, char *argv[]){ BHeap< int > heapInt; srand(time(NULL)); //Add random elements for(int i = 0 ; i < 10; i++){ int el = 1 + rand() %100; heapInt.Add( el); cout << "Element (inserted): "<< el << endl; } //Remove all elements while( heapInt.size() > 0){ int el = heapInt.Remove(); cout << "Element (removed): " << el << endl; } return 0; } [/CODE]
  8. Triangulation Reduction A* ( TRA* )

    Seems a new A* approach to me. When this idea was published on the paper? Would you like to give the link of reference from which you got this idea?
  9. Hmm..I haven't known Octree a quite well. Have you tried the Priority Queue or even simple vector?
  10. A* speed

    Hi, I am pretty new with A*. I have implemented one but somehow I face a weird path of A*. Would you like to help me? Thanks [img]http://img850.imageshack.us/img850/8779/weirdastarpath.png[/img]
  11. DirectX book and OpenGL book for beginners

    Thanks folks for the advice.
  12. FPS jumping movement

    Thanks. I'll try to make it. But, I want to ask if the player is in the air and currently going down, how to make it land on the platform?
  13. FPS jumping movement

    Quote:Original post by Numsgil Games use the idea of a "proxy" for players. Usually it's an incredibly simple shape, like just a capsule (by far the most common). Havok, for instance, provides some demos. Among them are several on character controllers. I'd recommend signing up for the free TryHavok license, getting your hands on the demos, and running through them to get an idea of how these sorts of things usually work. It really sort of "clicked" for me when I played with the demos and read the docs. For things like head shots, game studios usually add a ragdoll, which is basically an extremely simplified version of the render mesh. Things like dynamic boxes and bullets (ray casts) interact with the ragdoll. For character-character interactions (ie: pushing into another player) and character-static geometry interactions (climbing stairs, not going through walls, etc.), they use the character proxy. So there's actually a lot more going on under the hood for most games than you probably thought :) Thanks for the reply. But, I am sorry that I don't quite understand your advice. Please tell me what to do then. I am just a beginner in a game development.
  14. DirectX book and OpenGL book for beginners

    Quote:Original post by MichaBen Actually it isn't needed to learn DirectX or OpenGL at all to create games. Those APIs are used to create an engine, so if you are planning on writing an engine you will need them. However you can also use an existing engine, which in most cases is a lot easier and faster as well. Rendering engines like OGRE and Irrlicht will allow you to create 3D games without bothering with DirectX or OpenGL at all. When using such an engine you will still learn valuable things about how 3D graphics work, so when you pick up DirectX or OpenGL later it will probably be easier. I'm also interested in learning Ogre and already installed on my PC. But, I used to learn the basic of Allegro. Allegro and Ogre? Which one is better?
  15. DirectX book and OpenGL book for beginners

    Quote:Original post by jackolantern1 You could also learn XNA since you have C# experience. XNA is a bit higher-level layer on top of DirectX. You can more quickly write games for PC and XBox360 with XNA, and if you later decide to learn DirectX, it will be easier since XNA will teach you many of the concepts. Thanks for the advice. I got a hold of an XNA book right now. I also try to learn from creators.xna.com. I think XNA is a very good framework for developing games in C#.
  • Advertisement