Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

235 Neutral

About mcguile25

  • Rank
  1. mcguile25


    Looks good!
  2. mcguile25

    New Screens

    Just wanted to post an update with a few screenshots. I'm in the "building" phase, trying to get the first map created, so that other, more important features of the game can be coded (collision, networking, etc.) :D
  3. mcguile25

    "Picking" the closest mesh problem

    Aha! I fixed it and this is what I originally was suspecting: Since the objects have different scaling factors, I guess the distance returned was in a different space because of the scaling. So I multiply the distance returned by the scaling factor so that scaled meshes have a scaled distance as well. It seems to work fine, but it kind of feels like a hack. Eh, oh well. If anyone else comes up with anything else, please let me know, thanks!
  4. mcguile25

    "Picking" the closest mesh problem

    Also, to be more clear, this picking loop works perfectly fine for any number of meshes (not just 1 by itself). The problem arises when I scale one or more of the meshes. Then things don't pick correctly. I made sure I was transforming the ray by the inverse of each object's world matrix. Hmm..
  5. mcguile25

    "Picking" the closest mesh problem

    Thanks for the reply. First off, that function returns true if a collision occured or false if it didn't. Also, you pass in a pointer to a distance variable that gets filled in with the ray distance if a collision occured. Sorry I wasn't clear about that. Here is my loop code. Basically, if a collision occured, I check if it's the first match or less than the current closest distance and if so, set my highlighted index variable to 'i'. I don't break out of the loop prematurely at all. // distance variables D3DXVECTOR3 collisionPoint; float closestDistance = -1.0f; float loopDistance = 0.0f; // ------------- // we're going to see what object the user has clicked on and // set that as the highlighted object. we do this by keeping track of the closest // ------------- D3DXVECTOR3 menuCursorPos = g_gameEngine.GetPersistentData()->GetMenuCursor()->GetPos(); D3DXVECTOR2 cursorPos( menuCursorPos.x, menuCursorPos.y ); D3DXMATRIXA16 matWorld; int i = 0; // ** models ** for ( i = 0; i < m_models.size(); ++i ) { m_models[ i ]->CalcWorldMatrix( &matWorld ); if ( CCollision::GetInstance()->PickModel( m_displayDevice, m_models[ i ]->GetMesh(), &matWorld, &loopDistance, &cursorPos, &collisionPoint ) ) { // store this model if it's closer than the current closest (or we're at the first closest mesh) if ( closestDistance == -1.0f || loopDistance < closestDistance ) { m_highlightedObjectIndex = i; m_highlightedObjectType = MAP_EDITOR_TYPE_MODEL; closestDistance = loopDistance; } } }
  6. Hi all. I've got a problem with my "picking" code in DirectX. It works perfectly fine on any number of meshes _until_ I scale one of the meshes up or down. Here are some pictures and a description of what's happening in each (the mouse cursor is kind of hard to see, sorry bout that :D). Here are two meshes. Obviously the yellow one was "picked" and is highlighted yellow. Both meshes are their original size, orientation and placement. The next two screenshots have the floor mesh scaled by a factor of 5 all around. You can see that when selecting the vertical wall mesh, it still wants to select the ground mesh (the scaled mesh). If I try this code with one model that is scaled, the picking works correctly, it only seems to not pick the right one when there are multiple meshes with one or more being scaled. Now, in my code, I am choosing the picked mesh by the closest distance to the cursor position. Here is some of my code. Is there anything glaringly wrong here? bool CCollision::PickModel( LPDIRECT3DDEVICE9 displayDevice, LPD3DXBASEMESH mesh, D3DXMATRIXA16 *worldMatrix, float *distance, D3DXVECTOR2 *cursorPos, D3DXVECTOR3 *hitPos ) { D3DXMATRIXA16 matProj, matView; displayDevice->GetTransform( D3DTS_PROJECTION, &matProj ); displayDevice->GetTransform( D3DTS_VIEW, &matView ); D3DXVECTOR3 v; v.x = ( ( ( 2.0f * cursorPos->x ) / DISPLAY_SCREEN_WIDTH ) - 1 ) / matProj._11; v.y = -( ( ( 2.0f * cursorPos->y ) / DISPLAY_SCREEN_HEIGHT ) - 1 ) / matProj._22; v.z = 1.0f; D3DXMATRIX m; D3DXVECTOR3 rayOrigin,rayDir; D3DXMatrixInverse( &m, NULL, &matView ); // Transform the screen space pick ray into 3D space rayDir.x = v.x*m._11 + v.y*m._21 + v.z*m._31; rayDir.y = v.x*m._12 + v.y*m._22 + v.z*m._32; rayDir.z = v.x*m._13 + v.y*m._23 + v.z*m._33; rayOrigin.x = m._41; rayOrigin.y = m._42; rayOrigin.z = m._43; // Use inverse of matrix D3DXMATRIX matInverse; D3DXMatrixInverse(&matInverse,NULL,worldMatrix); // Transform ray origin and direction by inv matrix into this object's model space D3DXVECTOR3 rayObjOrigin,rayObjDirection; D3DXVec3TransformCoord(&rayObjOrigin,&rayOrigin,&matInverse); D3DXVec3TransformNormal(&rayObjDirection,&rayDir,&matInverse); D3DXVec3Normalize(&rayObjDirection,&rayObjDirection); bool hasHit = false; float hitU, hitV = 0.0f; DWORD faceIndex = 0; D3DXIntersect(mesh, &rayObjOrigin, &rayObjDirection, reinterpret_cast<BOOL*>(&hasHit), &faceIndex, &hitU, &hitV, distance, NULL, NULL); // determine the hit position if ( hasHit ) { *hitPos = rayObjOrigin + (rayObjDirection * (*distance)); D3DXVec3TransformCoord( hitPos, hitPos, worldMatrix ); } return hasHit; }
  7. mcguile25

    Lighting entire levels

    Hey thanks for the response. Couple reasons why I am not using pixel shaders (yet): my video card is a piece and can't do pixel shaders and I haven't learned them yet. Hopefully both of these issues will get addressed sooner or later. But yeah, I'm thinking about putting N number of lights in my level, and then determining which ones are closest and just enable those.
  8. Hey guys, I was wondering how to go about doing lighting in my game. Let's say I've got a level with 15 rooms. I am using Direct3D, so I'm assuming I'll be using D3DLIGHT9. I'm not using lightmaps or anything like that. So I guess my question is, how do most games without lightmaps do lighting? Do they just place a bunch of D3DLIGHT9 point lights in the various rooms? Obviously there's also a limit on the number of lights active in one scene (I think about 8 right)? Sorry this is so general, I'm just trying to get a feel for how I can light my entire level up efficiently and beautifully without lightmaps or such. Thanks.
  9. mcguile25


    I'm off to the GDC!
  10. mcguile25


    Whoa, that logo looks hot!
  11. mcguile25

    Moving while firing

    Ah, thanks for the replys guys. I think I (partly) figured out what's going on. It seems to be a timing issue. The gun and the player have a "Time Last Updated" variable (as do all objects in the game..). What was happening was that once the projectile was fired, the time last updated variable was set to the current time for the projectile (consequence of calling object->SetActive()), but for the player, the time last updated could be anything. So when activating the projectile, I set the time last updated variable for my projectile to be the same as the player's time last updated. Now, it's working a lot better, but it's still off a bit when strafing and such, but it's damn close..I'll have to keep working at this to figure out what's going on.
  12. Hi guys, just had a quick question that I hope has a quick answer :) In my 3D game, I am having a problem with firing bullets and having them render in the appropriate spot _while_ I am actively moving side-to-side or diagonlly or whatnot. The bullets seem to "lag" behind, so for instance, if I am strafing horizontally to the right, the bullets appear to the left at the previous position I was. Now, if I am just standing still, I can look up/down, rotate the camera, and shoot, and the projectile is fired in the correct spot. I think I've tried just about everything imaginable to try and get this to work. Why would it not show up in the correct spot while running side to side or diagonlly or whatever? In my player's HandleInput function, first I have the code to handle player position updates, then if the player fires, a projectile is started from the player's position and direction x/y angles. So the projectile is getting the starting position from the player, so it should be up-to-date by the time the player is moving and shooting. Any suggestions? Do you need code samples?
  13. mcguile25


    So I've taken the last couple of days to create a simple height-mapped terrain for outdoor levels. It still needs quite a bit of work, but I think it's looking pretty good. I added in some range-based fog as well. Let me know what you guys think so far (please excuse the crap texture and general look of the hills...)
  14. mcguile25

    Creating Huge Tribes-Like Terrains

    Tbank you all. This has given me several new ideas :D
  15. Hey all, I've been working on my terrain system in DirectX and am wondering how a game like Tribes is able to generate and render such a huge terrain that seems to go on for miles. Currently, I have a multi-textured height-mapped terrain. The height map is 256x256x8bits. It looks good, but it's so dang small. I even scale the vertices by a quite a bit and it doesn't have the "scale" that I would like to see. Let's say I have a jet-pack like in Tribes and you are able to float in air and see the terrain for what seems like ever. That's what I would like to see in my game. So how is something like this usually done? Is my height-mapped terrain a good start or is the terrain in Tribes rendered with some other method?
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

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!