• Content count

  • Joined

  • Last visited

Community Reputation

132 Neutral

About Cuchulainn

  • Rank
  1. Massive array

    Thanx for all yer replies. On reconcidering i might be able to bring the size down to about 70x70x70 and i managed, using runtime calculations to get the node struct down to: struct node { unsigned short G,H; unsigned long int parent; bool occupied; }; u see i am trying to avoid the waypoint option cause that makes things messy. I want to be able to change my map and the computer generate waypoints from a A* algorithm. The idea being to make waypoints out of the nodes that the computer comes up with by deleting the ones that arent needed - eg like down a corridor. I should get waypoints at the end of corridors or at the entrance of a room. Btw. yes my units can move in 3d - its a futuristic flight sim - kinda like descent only without the handy portal engine. Thanks for all yer help
  2. Massive array

    thanks i suppose i could increase the node size and that might bring it down to 250x250x250 which is only 8 times smaller. i have only 512mb on my machine - obviouly not enough - so how is it meant to be done?
  3. Massive array

    I really suck @ Data structures, which is why i'm posting this here. U c i am trying to do pathfinding on my world. Firstly i need to break it up into approx 500x500x500 (3d) cubes so i can apply the A* algorithm. Thing is i never really got my head around arrays and their relationship to pointers. If i type: node nodemap[500][500][500]; i get an (image exceeds maximum image - file may not run) error - not really surprising if i type node *nodemap = new node[500][500][500]; it says it cant convert from *node to *node[500][500] or something. Btw struct node { Vector center; int G, H, F; int parentnode; } so as you can imagine i need a pretty damn big lump of memory. I'd also like to be able to access it like: nodemap[x][y][z] for convenience sake. I'm sure the answer if a very short initialisation line but i cant seem to get it right - any help would be greatly appreciated
  4. Bouncing Off Corners ??

    Thanx for all the replies, i missed jyks post - he had the answer and so did nagromo. [Edited by - Cuchulainn on July 8, 2004 3:27:44 PM]
  5. Bouncing Off Corners ??

    Yea - its the corner of the table type scenario i'm after - in real life its quite unpredictable if you whack a ball at the corner of a wall - even if you have good aim. I was thinking about that "finding the appropriate plane to bounce off" idea myself but i wouldn't know how to calculate it - i say you'd need the normal from the centre of the ball to the collision point, the normals defining the corner and the velocity normal but i dont know how to use them in an equation to find the appropriate planenormal that i would be bouncing off. Thanx for all the replies. [help]
  6. Bouncing Off Corners ??

    Hi. I was wondering if anyone could tell me how a sphere should respond when it hits against a corner. What direction should it bounce in and how do you determine it? I'm sure there's loads of great articles about this but i cant seem to find any - if you could point me to one or if you know the answer yourself that would be great. __ --> / \ ________________ \__/ \ \ My collision detection at the moment uses the planes normal to determine the bounce, it bounces at the same angle at it comes in at, but i dont know what to do here. Any help would be great. Tx
  7. Hi. I've just put in a quick form of collision detection to my game - basically - i check if the velocity vector of my ship intersects a triangle of the world mesh - if it does - i calculate the normal and make it bounce away from the tringle at the same angle it hit it - easy - but the problem is i want sphere collision detection because otherwise parts of my ship go outside the world (not good :)). Before i get into the messy business of intersections with planes and trinagles and stuff tring to find a sphere collision - i was wondering did any of you see a handier way i could do it with the triintersect function - maybe a more stragically picked ray point - or can it only be done the long hard way. Here's my code for the slightly screwed up collision detection. void Ship_World_CollisionDetection() { for (int s = 0; s < NumberOfShips; s++) { my_vertex *vertices; WORD *indices; //////////////////////////////////////////////////////// scenerymodel[1].Mesh->LockVertexBuffer(0,(VOID**)&vertices); scenerymodel[1].Mesh->LockIndexBuffer(0,(VOID**)&indices); for (int v = 0; v < scenerymodel[1].Mesh->GetNumFaces() * 3; v = v + 3) { V p1, p2, p3; p1.x = vertices[indices[v]].x; p1.y = vertices[indices[v]].y; p1.z = vertices[indices[v]].z; p2.x = vertices[indices[v + 1]].x; p2.y = vertices[indices[v + 1]].y; p2.z = vertices[indices[v + 1]].z; p3.x = vertices[indices[v + 2]].x; p3.y = vertices[indices[v + 2]].y; p3.z = vertices[indices[v + 2]].z; V p1_p2, p1_p3, trinormal; p1_p2 = V(p2) - V(p1); p1_p3 = V(p3) - V(p1); D3DXVec3Cross(&trinormal, &p1_p3, &p1_p2); D3DXVec3Normalize(&trinormal, &trinormal); float disttointersection; D3DXVec3Normalize(&ship[s].velvecn, &ship[s].velvec); if (D3DXIntersectTri(&p1, &p2, &p3, &ship[s].Position, &ship[s].velvecn, NULL, NULL, &disttointersection)) if (disttointersection < ship[s].rad) { M velvecreflectmatrix; D3DXMatrixRotationAxis(&velvecreflectmatrix, &trinormal, D3DX_PI); D3DXVec3TransformCoord(&ship[s].velvec, &ship[s].velvec, &velvecreflectmatrix); ship[s].velvec.x = -ship[s].velvec.x; ship[s].velvec.y = -ship[s].velvec.y; ship[s].velvec.z = -ship[s].velvec.z; } } scenerymodel[1].Mesh->UnlockVertexBuffer(); scenerymodel[1].Mesh->UnlockIndexBuffer(); //////////////////////////////////////////////////////// } } By the way V is defined as D3DXVECTOR3 and M is defined as D3DMATRIX, velvec is the velocity vector - velvecn is the vectors normal. Any ideas to turn this into a sphere collision test? Any help would be.... helpful :) [Edited by - Cuchulainn on July 6, 2004 7:08:53 PM]
  8. Hidden Surface Removal and meshes :(

    thanx - you probably saved me weeks
  9. I've been putting off HSR in my game for a long time and now I'm deciding to tackle it. I looked at BSP trees and octrees and I decided that my since my worlds poly count are usually below 1000, i wouldn't need anything fancy. At the moment i use a ID3DXMesh to draw my whole world. I figured that i might be able to improve performance enough by just drawing my triangles in the right order ie front to back so that the z buffer would do a lot of the hsr for me. I decided to divide the boundingbox of my world into a grid of a certain resolution eg 10 units. In each unit i calculate the right order to draw the triangles in from the point of view of the centre of the grid box. This happens b4 the game starts. Then while running the game would just figure out what grid box the camera was in and draw the triangles of the world in the saved order. The idea was that the zbuffer would correct any bad approximations. If this wasnt enough, i could also do hidden surface determination for each gridbox too. This seemed a good enough solution for my limited map. The Problem: But then i would be putting all of the polygons out of order and i couldn't use drawsubset so i would have to change the texture and the material every triangle - that is if i could figure out from the ID3DXMesh class which texture went with which triangle. My question is: how bad was this idea - i mean does drawing the polygons in the right order make enought difference to outweigh the cost of SetTexture(*****) and SetMaterial(****) every frame. Please point me in the right direction. (NEWish B) [Edited by - Cuchulainn on June 30, 2004 8:50:13 PM]
  10. Additive Blending Troubles

    Thanx :)
  11. Additive Blending Troubles

    <quote>fading the colour itself to black will fade out the quad for example).<quote> Thanx. I my first problem by forgetting about the alpha parameter and changing my code to: mtrl.Diffuse.r = mtrl.Ambient.r = mtrl.Specular.r = worldeffect[k].transparency; mtrl.Diffuse.g = mtrl.Ambient.g = mtrl.Specular.g = worldeffect[k].transparency; mtrl.Diffuse.b = mtrl.Ambient.b = mtrl.Specular.b = worldeffect[k].transparency; I'm Still having my second unwanted flare effect problem when they are ate full transparency though - any ideas? This is an extract from my D3DInit function ////////Set Texture Stage States//////////////// g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_BLENDFACTORALPHA ); g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE ); g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT ); g_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); g_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); g_pd3dDevice->SetTextureStageState(1,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR ); g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); g_pd3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); float fFogStart = 40; float fFogEnd = 1600; float Density = 1; ///////////////Set Render States//////////////// g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE); g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); g_pd3dDevice->SetRenderState(D3DRS_FOGENABLE , TRUE); g_pd3dDevice->SetRenderState(D3DRS_FOGCOLOR, fogcolour); g_pd3dDevice->SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR ); g_pd3dDevice->SetRenderState(D3DRS_FOGDENSITY, *((DWORD*) (&Density))); g_pd3dDevice->SetRenderState(D3DRS_FOGSTART, *((DWORD*) (&fFogStart))); g_pd3dDevice->SetRenderState(D3DRS_FOGEND, *((DWORD*) (&fFogEnd))); g_pd3dDevice->SetRenderState(D3DRS_RANGEFOGENABLE, TRUE); g_pd3dDevice->SetRenderState(D3DRS_SHADEMODE , D3DSHADE_PHONG ); g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA); g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA); You'll notice additive blending isn't turned on but i do turn it on for drawing the worldeffects: g_pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, False); g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE); g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE); DrawWorldEffects(); g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA); g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA); g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); g_pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
  12. I'm having a few problems implementing a smoke effect in my game. I have a billboard additive quad with the texture of smoke against a black background but that seems to be limiting me because when I create the effect, i want it to expand and get more and more transparent till it dissapears but i cant seem to effect the transparency of the quad like i could with my other objects. Here Is My Code: D3DMATERIAL9 mtrl; ZeroMemory( &mtrl, sizeof(mtrl) ); mtrl.Diffuse.a = mtrl.Ambient.a = mtrl.Specular.a = worldeffect[k].transparency; mtrl.Diffuse.r = mtrl.Ambient.r = mtrl.Specular.r = 1; mtrl.Diffuse.g = mtrl.Ambient.g = mtrl.Specular.g = 1; mtrl.Diffuse.b = mtrl.Ambient.b = mtrl.Specular.b = 1; g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld); g_pd3dDevice->SetMaterial(&mtrl); g_pd3dDevice->SetTexture(0, worldeffectmodel[type].textures[0]); g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0, worldeffectmodel[1].NumberOfTriangles); Also another problem i seem to be having is when all of the smoke quads are aligned in a line it just looks like a white flare with smokey edges due to additive blending. Is there anyway to keep my black background and make it look normal. TY