hypernewbie

Members
  • Content count

    6
  • Joined

  • Last visited

Community Reputation

123 Neutral

About hypernewbie

  • Rank
    Newbie
  1. Swept AABB Collision Detection and Response

    Thanks heaps for the tutorial. Unfortunately the given swept AABB code is buggy. Sorry my following code has a slightly different naming scheme from the above (and is also in Java). Firstly, the code is missing these two lines before finding earliest / latest exit/entry points. This corrects the bug in the tutorial code where an axis non-entry due to overshooting can cover an entry on the other axis. if (entryY > 1.0f) entryY = -Float.MAX_VALUE; if (entryX > 1.0f) entryX = -Float.MAX_VALUE; // Find the earliest/latest times of collision. float entryTime = Math.max(entryX, entryY); float exitTime = Math.min(exitX, exitY); The no-collision check is also incorrect. The check given was: if (entryTime > exitTime) return 1.0f; if (entryX < 0.0f && entryY < 0.0f) return 1.0f; if (entryX > 1.0f || entryY > 1.0f) return 1.0f; First problem with this check is that it fails to catch the case where one axis overshoots, but the other axis undershoots eg. entryX < 0.0f but entryY > 1.0f. This should be a non-collision, but this code will register that as a collision.   Second problem with this check is that it does not correctly handle single-entry collisions at all. Undershooting single-entries collisions are incorrectly ignored, while overshooting single-entries non-collisions are incorrectly collided. The following image demonstrates a counter-example of two cases which should result in different collision results but are incorrectly treated the same in the tutorial code: The correct set of checks should instead be: //if (entryY > 1.0f) entryY = -Float.MAX_VALUE; // From previous bug above. //if (entryX > 1.0f) entryX = -Float.MAX_VALUE; // From previous bug above. if (entryTime > exitTime) return 1.0f; // This check was correct. if (entryX < 0.0f && entryY < 0.0f) return 1.0f; if (entryX < 0.0f) { // Check that the bounding box started overlapped or not.     if (s.max.x < t.min.x || s.min.x > t.max.x) return 1.0f; } if (entryY < 0.0f) { // Check that the bounding box started overlapped or not.     if (s.max.y < t.min.y || s.min.y > t.max.y) return 1.0f; } After these bugs are corrected, the sweptAABB collision works fine. Hope this saves someone hours and hours of debugging  
  2. Anyway, from looking at other people's projects and randomly modifying random bits of bitsy code, I somehow managed to get the formula right. The formula for texture width and height are wrong, and the website has no mention of how lightmap texture coordinates are calculated. I'll post my findings here, just in case anyone comes across this page on google with the exact same problem I ran into: This info is for BSPv38, in other words Quake 2 BSP files, regarding lightmaps and loading and rendering them properly. I used openGL to do the rendering. Getting lightmap dimensions: Face structure gives the lightmap offset, but for some crazy reason, does not give the lightmap dimensions: you must calculate them yourself by going through every vertex, calculating their texture map U V co-ordinates and do stuff to them. So, first, you go through every vertex of the face, and calculate their UV co-ordinates (use the formulae on the website http://www.flipcode.com/archives/Quake_2_BSP_File_Format.shtml). u = x * u_axis.x + y * u_axis.y + z * u_axis.z + u_offset v = x * v_axis.x + y * v_axis.y + z * v_axis.z + v_offset Then, you get the results in two floats, u and v. FLOOR u and FLOOR v into two integers, floor_u and floor_v. Then, you check floor_u and floor_v against max_u and max_v and min_u and min_v (4 of them all integers), to get the maximum and minimum floor_u and floor_v variables seen so far. DO NOT GET MAXIMUM/MINIMUM u and v. We need maximum/minimum floor_u and floor_v. Then, you divide the min_u and max_u and min_v and max_v variables by 16, in FLOAT. If you are using C++, this means you will need to specifically typecast those 4 ints into float before dividing by 16. Then, you floor the two min_ variables and ceil the two max_ variables, get the difference between the two, add 1, and typecast the result back to an int. Here is my little bit of C++ code that does this step: _minU = (float)floor((float)(minU / 16.0)); _maxU = (float)ceil((float)(maxU / 16.0)); _minV = (float)floor((float)(minV / 16.0)); _maxV = (float)ceil((float)(maxV / 16.0)); LIGHTMAPW = (int)(_maxU - _minU + 1); LIGHTMAPH = (int)(_maxV - _minV + 1); Getting lightmap texture co-ordinates: This will generate a texture co-ordinate that's in the range 0.0 to 1.0, for opengl glTexCoord2f usage. Let's say we need to get the texture co-ordinates for a vertex. we first calculate the u and v for the texture map, the formula given above. Then, we get LIGHTMAPW and LIGHTMAPH , also given above We also need the minU and minV and maxU and maxV from above, the max/min floor_u and floor_v for all vertexes. Then, simply follow this formula: float MidPolyU = (minU + maxU) / 2.0; float MidPolyV = (minV + maxV) / 2.0; float MidTexU = LIGHTMAPW / 2.0; float MidTexV = LIGHTMAPH / 2.0; float lightmap_u = MidTexU + (u - MidPolyU) / 16.0; float lightmap_v = MidTexV + (v - MidPolyV) / 16.0; glTexCoord2f(lightmap_u/LIGHTMAPW ,lightmap_v/LIGHTMAPH ); As you can see, we get the co-ordinates and make them relative to the middle of the texture. Or something like that. Hopefully this will solve the problems for people who are trying to load quake2's BSP files and get stuck at trying to load the lightmaps, because nowhere on the face of the internet is there such a documentation of this and quake 2 source code takes a while to excavate into. Check six, HyperNewbie
  3. yes i can easily put bilinear filtering on, except it still looks "wrong" for some reason - my texture width/height calculations seem off, but I've followed that guide EXACTLY. I also don't understand the part about lightmap being max 16x16...I'm getting lightmaps that are much larger than 16x16 from the exact formula he has given on the site, the web page contradicts itself o.O Thanks, HyperNewbie
  4. Hey guys! I'm trying to write a quake 2 BSP loader, and everything works completely fine except for my lightmap...where I've come to a complete halt, much like this poor person: http://www.gamedev.net/community/forums/topic.asp?topic_id=17243 Is anyone floating around here thats run into the same problem? Half my lightmaps look good the other half of surfaces seem warped and retarded - like I've got the wrong dimensions or something. The general color of the lightmaps seem correct But I've followed http://www.flipcode.com/archives/Quake_2_BSP_File_Format.shtml and snooped around heaps, but I've only found people with the same problem, not solutions =( Here are comparison screenies: Here quake 2 screenshot with console command gl_lightmap 1: http://img523.imageshack.us/my.php?image=lightmap2.jpg Here is my engine's futil attempt at rendering the lightmap: (with tex filter turned off): http://img523.imageshack.us/my.php?image=lightmap1.jpg Also, it would be of great help if someone can point me to where quake 2 source stores each face's lightmap width/height, as I can just output that and compare. I've been digging through this q2source and keep getting lost o.O
  5. Vectra

    haha I'm a lazy person :P hmm I'll go figure how to post imgs on gamedev forums... oh, also, the real place I got the original concept from is the hacker minigame in Ratchet and Clank 3: Up Your Arnensal
  6. Vectra

    Vectra Vectra is an 2D unique arcade-style game that has very addictive gameplay. It features 2D game engine using 3D graphics powered by the well-known open source graphics library OpenGL. In Vectra, there is a cylinder with 8 rails leading towards you. Your shot can only shoot from the top rail, but the cylinder itself may be rotated to choose which rail to shoot on. Various types of cubes and electrospheres would appear and move towards you, and you just press the corresponding key or sometimes key combination to shoot the correct type of lazer. A wrong shot results in a slight penalty, to stop players from spamming keys. Quick Controls (just in case someone misses the help screen in-game): Left/Right Arrows - Rotate cylinder Z - Red X - Blue C - green For more advanced controls, click the "help" in the main menu. Screensots Websites http://vectra.sourceforge.net - Project website http://vectra.sourceforge.net/screenshot.html - Screenshots Download http://vectra.sourceforge.net/download.html http://downloads.sourceforge.net/vectra/vectra_110_zip.zip - Zip file System Requirements These requirements are somewhat untested and estimated. > 333Mhz or above x86 family Processor > Windows 98/2000/XP (although should work on any version of windows) > 32mb RAM (64 Recommended) > Video card with basic OpenGL support > Sound card recommended for audio > Keyboard If you have no idea which to download, download vectra_win32_installer.exe. [Edited by - hypernewbie on August 17, 2007 8:50:02 PM]
  7. electronic music - free

    Hello, i'm Xi Chen, "HyperNewbie", and i mostly make trance and sometimes other eletronic genres. my link is here anyone feel free to post me any comments, and you can use them in any way, just inform me where it ends up ;) hypernewbie[a_t]gmail(d0t)com