# ajoling

Member

343

202 Neutral

• Rank
Member
1. ## Simple 2D BB vs BB response

Bob, that's what I tried, unfortunately the problems start to happen when the tile is crossing two tiles at once, and, if the player has a collision with an object, it will always be inside the object by both sides. So, assuming I have a box of: 128 width, 64 height (all tiles are AABB, never rotated!), the tile being centered on 64,32. Then, if I have the player stand on the top left corner, it would intersect Y, with a value of 1 or so, but the X axis is also colliding, giving avalue of something near -64 or 64, depending which side the player is standing on the tile. And that's the whole problem all the time, I just need the player to stay on top of the tile, and 'stop' against all others. Quote:Original post by oliii I'll point you towards a tutorial that seems to do what you need http://jnrdev.72dpiarmy.com/ I tried that an hour ago, but it didn't work for me, the player kept moving back to the top-left or bottom-right corner. My tiles aren't grid based, btw. Any more suggestions? My best working efforts have been with this: if (bounds1.xMin &gt; bounds2.xMin) { //Collision object is LEFT of player. //trace("left"); diffx = bounds2.xMax - bounds1.xMin; left = true; } else //if (bounds1.xMax &gt; bounds2.xMin) { //Collision object is right of player. //trace("right"); diffx = bounds2.xMin - bounds1.xMax; } if (bounds1.yMin &gt; bounds2.yMin) { //Collision object is above of player. //trace("bottom"); diffy = bounds2.yMax - bounds1.yMin; //trace(diffy); istop = [0]; } else (bounds1.yMax &gt; bounds2.yMin) { //Collision object is below of player. //trace("top "); diffy = bounds2.yMin - bounds1.yMax; istop = [1]; } it's getting a bit messy, but I have a deadline very very soon, and this problem is making me pull my hair out :(.
2. ## Simple 2D BB vs BB response

Hey everyone, I got myself in a nasty problem, which I cannot get fixed properly. While, in fact, it is probably extremely easy. The problem is this: I got a nice collision detection. I simply check if bounding boxes intersect. The player/monster vs. the static geometry. This is all fine. But, the actual collision response is giving me a problem. It's as if I cannot properly find the correct side of the collision, and react properly. I'm on a very tight time schedule, and have no time for implementing new complex collision detection code. All that matters right now is the correct handling of the collision. The player should be able to stay on top of most tiles. The problem is that the player can also stay on "Wall tiles" if he/she lands on a 'bad position'. I have googled a lot,tried newsgroups, this forum, but I cannot find an easy solution to this problem, while in fact it should be rediculously easy? what I have is: BB of object1 BB of object2 Velocity of the player/monster Note that the player can stay on two tiles at one time. Can anyone here offer me some help? Thanks.
3. ## [RTS AI] Road placement

Well, I guess a "brute force" would work, by casting rays down or something. (Otherwise I'd end up on the grid again). But yes, I need to determine where to place the buildings, next to a road or build a new road and place it next to it. Since the road is a lot smaller 'tile' I'm concerned that brute forcing it won't work. I guess I might give it a go though.
4. ## [RTS AI] Road placement

Hey everyone, I'm working on the AI of my RTS. I got some nice classes (managers) which should distribute the tasks of the AI. Not much code yet, though. My first priority ist ohave the AI build objects on a semi-decent place. Unfortunately, my buildings need to be placed (freely) next to a road. I can't figure out exactly the best method to do this though. What I have is: - Individual towns/cities, each with their own road network (kinda like transport tycoon) - Knowledge of the indivual road tiles. - Buildings placed in the town. There is no grid. Objects are placed freely in close proximity to the road. The goal is to: - Find a free spot ( on either side of the road) - (- Determine if it's tactical suitable, if not, find another spot) - Or build a road. now, building a road shouldn't be too much of a problem, I think. But the problem of how I would find a free space, while the town exists of more than just "one single road", because it has crossings and everything. While typing this (really helps sometimes, typing out the problem :P), I'm thinking of a virtual grid (the size of the road), and to 'fill in' the objects that have been placed. I guess I could search for an appropriate sized open block of tiles to find a suitable place. What do yo people think of it? Or do you have any other suggestion or experience? Many thanks!
5. ## [Cal3D] Matching bone rotation

Hi! Thanks for your reply. Unfortunately, I think I have tried every single combination possible. I guess I could try to seperate the Quaternion values somehow and multiply these in all kinds of diferent orders. I'm beyond clueless, and thinking of ditching the problem for a few weeks. Unfortunately, this is something which is quite a requirement in my game.
6. ## [Cal3D] Matching bone rotation

Hm, no one with any ideas? I'm so suprised that there are so many users, while no one ever seems to write a word about it except for problems. :)
7. ## [Cal3D] Matching bone rotation

Hi everyone, I've been trying for a few days to attach an object to the Cal3D bones. (More specific, the right hand). I thought things were going well. The translation was easy. But the rotation. Why could it be that hard. I've spent an enormous amount of time on it, and still it does not work. My code can be found here as well (below), it might be useful to other people. Cal3D documentation is very sparse, and alsost no information can be found on the net. Now, I hope someone can give advice how to fix the rotation. Cal3D has been used in so many commercial games, but there is no single piece of examples available made by other people. Strange. Can anyone please shed some light on how to fix the rotation issue? Many many thanks in advance! int boneId = mesh->m_calModel->getSkeleton()->getCoreSkeleton()->getCoreBoneId("Bip01 R Hand"); if (boneId > -1) { D3DXMATRIX matRot, matWorld ,matObjectTrans; D3DXMATRIX matBoneRotationMatrix, matBoneTranslation; D3DXMATRIX matCorrect; D3DXMatrixIdentity(&matWorld); D3DXMatrixIdentity(&matObjectTrans); D3DXMatrixIdentity(&matBoneTranslation); //Bip01 L Hand CalBone* bone = mesh->m_calModel->getSkeleton()->getBone(boneId); CalVector translationBoneSpace = bone->getTranslationAbsolute(); //Translate the object to the bone position D3DXMatrixTranslation(&matBoneTranslation, translationBoneSpace.x,translationBoneSpace.y,translationBoneSpace.z); //Translate matrix to object position: D3DXMatrixTranslation(&matObjectTrans, vPos.x,vPos.y,vPos.z); //Apply rotation correction: D3DXMatrixRotationYawPitchRoll(&matCorrect, 0.0f, D3DXToRadian(90.0f), 0.0f); D3DXMATRIX mat2; D3DXMatrixRotationYawPitchRoll(&mat2, 0.0f, 0.0f, D3DXToRadian(90.0f)); matWorld = matBoneRotationMatrix * matCorrect * mat2 * matBoneTranslation * matObjectTrans; // * matModelRotation * matObjectTrans; Next to above code, I have tried iterating through all the parents too, with both relative and absolute coordinates. No luck. I have tried the TransFormMatrix(), no luck. Hence I'm messing around with correction matrices, playing with every single x,yz, z,y,x, y,x,z coordinate version, and I have tried every single angle of my 3D mesh. I amm totally clueless. I'm out of suggestions. :-(
8. ## Water / Terrain - Use the stencil buffer?

Quote:Original post by jamesw Quote:Wow, jamesw, would you be willing to point me in the right direction on how to make an effect like that? I'm pretty clueless on pixel shaders, I'd love to know how that's actually done. The best place to start is right here on gamedev, Yann's water article. And once you have that stuff down take a look at the 'Generic refraction simulation' article in GPU Gems 2 as well as the one about animation water in ShaderX3. Both of these articles have a wealth of knowledge on water effects and the GPU Gems 2 one has a full working sample. Just don't copy it like so many do, figure out how it works and make your own. Quote:Here are two screenshots for you. Thanks! You really have the edge fadeout down, I can't see any sharp edges at all. How come you don't have any banding? Or is it just too far away for that. When I scale the depth values into a good range to be a blend factor they band like crazy. Quote:approximately 10 instruction slots used (3 texture, 7 arithmetic) I'm using 67 arithmetic =( It currently rapes cards with low pixel power. I have to find a way to fit it in ps2.0. Yeah, my reflection is based on Yann's water article. I guess I should look for some refraction articles myself. Most of them are plain ASM though, which I have started to dislike ever since I started on DX9. :). I've used two techniques for my water james. Method 1 (old): The heightmap is sampled on the appropriate coordinate. Since I know what my min/max terrain values are, I can multiply the .r * maxterreinheight. This gives me the (near) perfect height. I also knew the water level (I first had a fixed water height). So, I did something like: float fTerrainHeight = tex2D(HeightMap, vPos).r * fTerrainMaxHeight; float fWaterCalc = fWaterLevel-(fTerrainHeight); float fAlpha = ((fWaterCalc+0.25f) / fWaterLevel); This is old HLSL code, I might have modified it in a version so that it doesn't work. It produces a similar effect as my new version. Method 2: Now I have multi level water (just not for reflections, a whole different challenge with clipping planes..). And I cheated on the water height. I removed the "river" in my original heightmap, and created a watermap. This watermap is like a heightmap, but it tells me where to "dig" rivers/lakes. I have limited the range of depth: 0 = 0, 255 = 4. This depends on your unit system. When generting the terrain, the watermap and heightmap will be 'merged'. so rivers/lakes will automatically be shown in the vertexdata. And, as bonus, I still have this "water map". Submitting this to the pixelshader gives me exact knowledge where to start blending. I can actually immediatly cull any pixels which are black too! Ofcourse, you can generate this map from a fixed (known) waterlevel - height. And submit this texture to the shader. Hope this works out for you. I thought my idea was pretty cool, and the water looks almost commercial quality :-).
9. ## Water / Terrain - Use the stencil buffer?

Thanks :). I will have a look at it. I'm probably going to alter my terrain generator a bit anyway, I have way too much quadtree nodes in my terrain. Rendering those seperately takes more time than rendering a bigger chunk. About the western games: Yeah, my favorite 'game' is a mod called "Badlands" for Unreal tournament 1. Nothing beats walking around with a Sharps plains rifle. Truly one of the best mods made for the game. And because of the time I spent in this game, I'm afraid it won't be freeware :). But, it won't be expensive either.. :). If I finish it ofcourse.
10. ## Water / Terrain - Use the stencil buffer?

Hm, I spent a while on the shader. It's nearly similar now, and because of a few specifics, does not fit into PS1.4 :(, but still it's 20-30fps faster for me: Although maybe I will use one pow() (or something) to make the water blend faster on the sides. Now one side is less shorelined than the other. Original: approximately 26 instruction slots used (3 texture, 23 arithmetic) New: approximately 10 instruction slots used (3 texture, 7 arithmetic)
11. ## Water / Terrain - Use the stencil buffer?

Sure jamesw! Here are two screenshots for you. The terrain might look 'small' but it's an RTS game and will be quite zoomed in. :) I'd like to have the specular highlight which you have as well and some more wavey effect. I think I have reflections currently disabled, trying to find out how to squeeze more FPs juice out of everything. My card ain't the best videocard, but I still think it should do better. Rendering water really kills the fps. Distant view: Closer (excuse the texture choice): Geometry (simple return float4(0.0f,1.0f,0.0f,1.0f) in shader) Hope this is useful to you :)
12. ## .x files

http://www.toymaker.info/Games/html/load_x_hierarchy.html Is one of the best places to actually load an .x model. Personally, I wouldn't merge specific object info in a model file. It should really be in a seperate file.
13. ## Dynamic textures - best place to update?

Quote:Original post by Moe Well, from my limited understanding, you MUST update the texture between the begin/end scenes. From the SDK: Quote:From the DirectX 9 SDK Applications must call BeginScene before performing any rendering and must call EndScene when rendering is complete and before calling BeginScene again. I suppose it depends on what you mean by update. If you are moving geometry around and recalculating what the render-to-texture is seeing, then it would probably be better to have it close to the beginning of the frame to give it some time to get calculated before you have to actually render to the texture. The idea of pre-rendering the render-to-texture a frame in advance to save the lock/unlock from being in the begin/end scene pair does sound like a good idea. I haven't really done this, but it would be interesting to profile some tests to see which is faster, and by how much. Well, you can call BeginScene/Endscene as much as you want. I'm just not sure if it creates a lot more additional overhead. With updating I just mean like rendering my terrain's reflection to a texture. - Or the depthmap of the shadows. :)
14. ## heightmap to normalmap

Quote:Original post by Mythar thx m4gnus : but i kinda already know that, what i need is the code for NormalizeFast and FloatToByte, sorry I did not specify this in my first post. ajoling : I did look into this, but atm im not using D3DX9 Ah, okay, sorry :). You could search on "normalmap 127.5" (without quotes) since that'sa common value. A page with code from Id Software popped up: https://zerowing.idsoftware.com/svn/radiant/GtkRadiant/trunk/plugins/shaders/shaders.cpp Quote: float norm = 1.0/sqrt(nx*nx + ny*ny + nz*nz); out[0] = float_to_integer(((nx * norm) + 1) * 127.5); out[1] = float_to_integer(((ny * norm) + 1) * 127.5); out[2] = float_to_integer(((nz * norm) + 1) * 127.5); out[3] = 255; I used to have a working sample, but I removed it in favor of the other function, I think.
15. ## Dynamic textures - best place to update?

Hi, I've been wondering what the best place would be to update dynamic textures (reflection of water + shadow map). Currently I have them in my BeginScene()/EndScene() block, which sounds like an awfully bad place to lock something. I think I read somewhere that stuff like that should be before BeginScene(). Any opinions on this? Next to that, I wonder if a simple 'switching' texture would be better to render to. so, like a backbuffer. The game would always render from a texture which was not updated that frame, next frame, the textures will be switched again, etc. Any opinions? Just wondering! :)
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!