Solano

Members
  • Content count

    46
  • Joined

  • Last visited

Community Reputation

185 Neutral

About Solano

  • Rank
    Member

Personal Information

  • Location
    Bulgaria
  1. But this wind is weeping just a little.
  2. Here is an article about sphere-sphere intersection test. Check it out if you want to understand why the following code will work even for fast moving spheres: [url="http://www.gamedev.net/page/resources/_/technical/math-and-physics/simple-bounding-sphere-collision-detection-r1234"]http://www.gamedev.n...detection-r1234[/url] [code] BOOL bSphereTest(CObject3D* obj1, CObject3D* obj2) { //Initialize the return value *t = 0.0f; // Relative velocity D3DVECTOR dv = obj2->prVelocity - obj1->prVelocity; // Relative position D3DVECTOR dp = obj2->prPosition - obj1->prPosition; //Minimal distance squared float r = obj1->fRadius + obj2->fRadius; //dP^2-r^2 float pp = dp.x * dp.x + dp.y * dp.y + dp.z * dp.z - r*r; //(1)Check if the spheres are already intersecting if ( pp < 0 ) return true; //dP*dV float pv = dp.x * dv.x + dp.y * dv.y + dp.z * dv.z; //(2)Check if the spheres are moving away from each other if ( pv >= 0 ) return false; //dV^2 float vv = dv.x * dv.x + dv.y * dv.y + dv.z * dv.z; //(3)Check if the spheres can intersect within 1 frame if ( (pv + vv) <= 0 && (vv + 2 * pv + pp) >= 0 ) return false; //tmin = -dP*dV/dV*2 //the time when the distance between the spheres is minimal float tmin = -pv/vv; //Discriminant/(4*dV^2) = -(dp^2-r^2+dP*dV*tmin) return ( pp + pv * tmin > 0 ); } [/code]
  3. The wind ... is troubled today.
  4. Hello to all! I am making a simple 3D Strategy game resembling Starcraft and Warcraft 3. For this game I want to develop a terrain editor. I want my terrain editor to have the same functionality as the Warcraft III terrain with which I can create terrain like that in the picture below. [img]http://www.upurload.com/files/d7eaabc01fac646b6ad392901b712b66.png[/img] This is an example terrain created with the Warcraft III Editor. I did some research and managed to find some information on how the editor works. [quote] The Warcraft III Terrain editor is tile based. Each tile can have its own texture, as well as different height for each of its four points. The are two major tile types. Normal (flat) tiles which are just a plain heightmap, and cliff tiles which are composed of complex geometry. [/quote] Before I start building the terrain editor I started thinking about the different aspects of such an editor and found my self with a few questions: [i] 1.) The whole terrain will be represented by a single Vertex Buffer. This buffer will be recreated every time the camera moves and contain only the visible vertices of the terrain. is this possible and will it pull too much strain on the video card? What are other possibilities? Should I use LOD for a 3D strategy game which has a top-down view tilted 45 degrees on the Y axes? (Like the picture)[/i] 2.) [i]I will create a single large texture for every terrain type. (Grass, Stone, etc...) and then use alpha maps to blend them together and apply over the terrain then use another texture with multi-texturing to add detail. Is this a good solution? Will I be able to achieve good quality texturing if I build a big texture for the whole terrain? Is it better to create many small textures? Should I devide the terrain into small parts each having its own textures and vertex buffer and then just do a simple check of the position of the camera to remove the non visible parts of the terrain?[/i] 3.) [i]How will I be able to achieve square hills like the picture? What I am thinking of using is having a quad of the terrain, which are parts of hills do be subdivided and then displaced using a heighmap texture ( to make the hill look like there are rocks sticking out). Is it better to just create a mesh for a hill (tillable) and then where there's a hill I simply render the mesh ontop? What other possible ways are there? [/i] I think that's all. I hope someone can answer my questions Thank you for your time! -hentailoli
  5. The simplest possible way to do bounding-sphere test is to measure the (squared) distance between the two objects in question and to compare the result with the (squared again) sum of their radii. The reason we use the squared distances is to avoid the costly square-root calculation. The code will look something like this: [code] bool collide::collision(float x1, float z1, float radius1, float x2, float z2, float radius2) { float vecx = x1 - x2; float vecy = y1 - y2; float vecz = z1 - z2 float dist = vecx * vecx + vecy * vecy + vecz * vecz; float minDist = radius1 - radius2; return dist <= minDist * minDist; } [/code] Keep in mind that if your spheres are moving too fast they will pass through each other.
  6. Oh thanks that I always wondered why people use .inl and .inc files, but never actually researched it. Well you can close the topic now.
  7. Thanks for the fast response. Isn't this breaking the good programming practice of separating the definition and implementation? I will move my code, but its definitely something I wish could be done different
  8. Hello guys. I am making a memory manager and I have stumbled onto a very weird problem. I am making a new template class like so CWStackAllocator.h [code] namespace CWolf { template <class T> class CWStackAllocator { public: // Constants enum { CW_DEFAULT_SIZE = 100, // Error constants CW_ERR_UNABLE_TO_ALLOCATE = 0 }; /** The allocated memory is stored in the form of a double linked list. This structure represents a node in that list. */ struct CW_ELEMENT { T data; CW_ELEMENT *pPrev; CW_ELEMENT *pNext; }; /** A marker showing the top of the stack. You can only roll back to a marker. */ typedef uint32_t Marker; /** Default constructor. @param stackSize - Optional paramater. It tells the initial stack size. */ explicit CWStackAllocator(uint32_t stackSize = CW_DEFAULT_SIZE); /** Default destructor. Frees all of the memory used by the allocator. Called automatically. */ virtual ~CWStackAllocator(); /** This function allocates a new block of the given size from stack top. @param size - the size of the chunk which to allocate */ T* MemAlloc(uint32_t size); /** Get a marker to the top of the stack @return Marker - top of the stack */ Marker MemGetMarker(); /** Rolls the stack back to a previous marker @param marker - marker showing where to roll back to */ void MemFreeToMarker(Marker marker); /** Clears the entire stack (rolls the stack back to zero). */ void MemClear(); private: protected: CW_ELEMENT *m_pFirstFree; CW_ELEMENT *m_pFirstUsed; uint32_t m_MaxElements; CW_ELEMENT *m_pMemory; }; } [/code] [code] #include "CWStackAllocator.h" namespace CWolf { template<class T> CWStackAllocator<T>::CWStackAllocator(uint32_t stackSize) : m_MaxElements(stackSize), m_pFirstUsed(0) { // Allocate enough memory for the maximum number of elements char *pMemory = new char[m_MaxElements * sizeof(CW_ELEMENT)]; // Handle problems // TODO (hentailoli#) Implement CWException if (pMemory == 0) throw CW_ERR_UNABLE_TO_ALLOCATE; // Cast the memory to our internal format //m_pMemory = (CW_ELEMENT*) pMemory; m_pMemory = dynamic_cast<CW_ELEMENT*>(pMemory); // Set the free list first pointer m_pFirstFree = m_pMemory; // Clear the memory (is this really needed?) memset(m_pMemory, 0, sizeof(CW_ELEMENT) * m_MaxElements); // Point at first element CW_ELEMENT *pElement = m_pFirstFree; // We don't have a previous element since this is the first one pElement.pPrev = 0; pElement.pNext = pElement + 1; // Set the double linked free list for(uint32_t i = 1; i < m_MaxElements; i++) { pElement->pPrev = pElement - 1; pElement->pnext = pElement + 1; pElement ++; } // We don't have a next element pElement.pNext = 0; } template <class T> CWStackAllocator<T>::~CWStackAllocator() { } } [/code] Now the code compiles without a problem. I wanted to test if the constructor works so I created a file, added a main function [code] #include <iostream> #include "CWStackAllocator.h" using namespace std; using namespace CWolf; int main() { CWStackAllocator<int> test; cout << "Hello world!" << endl; return 0; } [/code] But now when I try to compile I get the following errors: [quote] 1>main.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CWolf::CWStackAllocator<int>::~CWStackAllocator<int>(void)" (??1?$CWStackAllocator@H@CWolf@@UAE@XZ) referenced in function _main 1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall CWolf::CWStackAllocator<int>::CWStackAllocator<int>(unsigned int)" (??0?$CWStackAllocator@H@CWolf@@QAE@I@Z) referenced in function _main 1>c:\...\MemoryManager.exe : fatal error LNK1120: 2 unresolved externals [/quote] Any idea why this is happening?
  9. [quote name='weeska' timestamp='1345144983' post='4970304'] [quote name='mhagain' timestamp='1345141289' post='4970282'] Even if so, they shouldn't be doing it at runtime. [/quote] Sure, there's no need recreating a vbo over and over. But where's the problem deleting the array once the vbo is set up? [/quote] I agree. Why would you keep two versions of the same data(one in system memory, other in video memory)? It's the same for textures. You will be needing the data if you plan to animate though.
  10. No actually I didn't. I do have an android device, but will try it out later and edit with the results.
  11. Hmm I am not entirely sure that if the reason is multiple threads the code will crash. I usually get a GL_INVALID_OPERATION. Why don't you actually check if DeviL is loading the file correctly. By that I mean check the raw data. Also try to use DeviL's functions for loading textures to OpenGL.
  12. This article will help you get started with the sprites: [url="http://www.gamedev.net/page/resources/_/technical/opengl/rendering-efficient-2d-sprites-in-opengl-using-r2429"]http://www.gamedev.net/page/resources/_/technical/opengl/rendering-efficient-2d-sprites-in-opengl-using-r2429[/url] You will find this series of tutorials very helpful: [url="http://www.codeproject.com/Articles/27219/TetroGL-An-OpenGL-Game-Tutorial-in-C-for-Win32-Pla"]http://www.codeproject.com/Articles/27219/TetroGL-An-OpenGL-Game-Tutorial-in-C-for-Win32-Pla[/url]
  13. I second BitMaster. Just use glew. [url="http://glew.sourceforge.net/"]http://glew.sourceforge.net/[/url]
  14. A quick google search resulted in the following site -> [url="http://fly.cc.fer.hr/~unreal/theredbook/chapter11.html"]http://fly.cc.fer.hr/~unreal/theredbook/chapter11.html[/url] It has example code + very detailed explanation
  15. Ok the new link is working. I tested the engine and found it really easy to compile. The documentation, although in Russian is very detailed and well structure. The engine is very easy to use and very lightweight. The 3ds max plugin is a nice feature. +1 from me!