Archived

This topic is now archived and is closed to further replies.

PSioNiC

!! DON'T READ THIS MESSAGE !!

Recommended Posts

there''s a sneaky way of getting attention I NEED code for the D3DXIntersect function. If anybody has seen, attempted, or used this code, PLEASE LET ME KNOW !!! i have been trying to get this function to work since i was a fetus (thats an exaggeration)

Share this post


Link to post
Share on other sites
hi,

i have briefly tried that function, but couldn''t get it to work. I could have been using a parameter wrong, i just wanted to see if it would work.

I have seen a number of other posts about D3DXIntersect (maybe yours), but havn''t seen any one post how to use it.

I wish that MS would give developers source for DX (yah right) so we could see how it actually does stuff, this would make problems like this easier to solve.

Share this post


Link to post
Share on other sites
Well, to my knowledge, Microsoft is not responsible for implementing those functions for DirectX. I think that is the task of the hardware manufacturers. MS is only responsible to give the interfaces of the functions. I''m not sure if that is true. I just read something about it in a book, but maybe I get this wrong

Share this post


Link to post
Share on other sites
LongingForDeath/
Well, surely D3DXIntersect is nothing to do with the video card or the drivers, it's just a math function MS have coded themselves. It's certainly not a feature any DX supporting video card can perform. I think the same is probably true of a lot of the D3DX functions.


Edited by - simon_brown75 on April 26, 2001 5:18:53 AM

Share this post


Link to post
Share on other sites
PSioNiC:
I haven''t tried the intersect function, but I have gotten the D3DXBoxBoundProbe() to work. Have you tried going that route? If you need more info just ask

Share this post


Link to post
Share on other sites
Make sure directX is in debug mode (you can set this stuff in the control panel), and move the slider for debug output level in the direct3d tab to more. this will ensure directx prints all errors and you will be able to tell what parameters and stuff are wrong.

Edited by - LeeIsMe on April 28, 2001 11:05:21 AM

Share this post


Link to post
Share on other sites
Yes i would like to see your code for D3DXBoundBoxProbe()
Its not exactly what I am looking for but it is a start.

And about debug mode, how does that work?

My computer is running with 2 monitors, I think that helps. I have to disable the second monitor though when I run any d3d app though cause it will crap out if i don''t.

Are their any special functions you have to call to setup debuging with multi monitor ?

Share this post


Link to post
Share on other sites
actually that is a different topic all together, so I will start a new thread for that one.

please though, more D3DXIntersect information wanted !!!

Share this post


Link to post
Share on other sites
There''s a helper function called D3DXComputeBoundingBox(). Use this by passing the vertex buffer for your object to it, as well as 2 D3DXVECTOR3 objects bboxMin and bboxMax (create these as public members in your object class). Then follow the Pick sample included with the sdk(it will show you how to create the ray origin and direction, which is needed). Just substitute a call to D3DXBoxBoundProbe() at the appropriate place (which returns a bool). If you have problems let me know, because I just went through all of this with a current project for work. This is usually used for mouse picking, but can be mutated for many other purposes

Good luck;
Prairie

Share this post


Link to post
Share on other sites
That sounds pretty cool, but it still doesn''t top the power of D3DXIntersect.

What you are saying to do is like a work around for us crap coders who can''t get an already written function to work

I''d rather just try to get the real thing working.

Share this post


Link to post
Share on other sites
What exactly are you trying to accomplish? This may improve the level of support I can give.

Is the goal collision detection or object picking? If everything is set up properly then the helper functions should work. With-out knowing any specifics, I suggest looking over your ray origin and direction code.

-Prairie

Share this post


Link to post
Share on other sites
Im using the D3DXIntersect function for colision detection and Y-Correction on my terrain engine, im also using it to see if a bullet hit a dude.

Share this post


Link to post
Share on other sites
hmm, I'm guessing by Y-correction you're referring to keeping something (camera position, projectiles, etc..) a certain distance above the ground. On this regard, I can't help you. But, as far as the bullet hitting part, start with bounding box (or sphere, which ever best suits your model shape) interception for rough culling in the logic portion. You can then set up a chain of sub-checks to test against if you are going for a Soldier of Fortune hit zone set-up.

For what you're trying to achive you need to closely examine the ray generation section of your code. Because the intercept function needs a world space origin and direction (which is the difficult part to generate).

Alot of your past posts have dealt with sprite info. If you're making an arcade shooter type of game, bounding box calcs will simplify your workload greatly.

Good luck;
Prairie

Edited by - Prairie on April 28, 2001 10:44:53 PM

Share this post


Link to post
Share on other sites
Ok, you want to see my code - here it is. Now, I have gotten this to work, ALMOST. I have a huge mesh for the terrain (the tank in arbitrary world coords is 2x3, and this terrain mesh is 40*40. Anyway, when the tank gets around 10 away from the Origin, pHit ALWAYS returns 0... hmmmm. So, this function works part of the time, then fails all over the place. I have about 10 different versions of this function, so I''m sorry if it looks like a hack.

Ghallo



VOID MoveTank(D3DXMATRIX* matParent)
{

//Shane''s FLOAT code - Ok, going to start with a "level" tank that just stays .3 above the ground
//decided off the center of the tank. Start the "intercept" at tank center, then look at y-10...

BOOL pHit;
DWORD pFaceIndex;
FLOAT pU;
FLOAT pV;
FLOAT pDist=0.0;
FLOAT probe_distance = 10.0;//TANK_HOVER_HEIGHT;

D3DXVECTOR3 TankLocation;
D3DXVECTOR3 TankBottom;

TankLocation = cTank.sObjPhy.location;
TankBottom = cTank.sObjPhy.location;

TankBottom.y = TankLocation.y-probe_distance;


D3DXIntersect(cTerrain.pMesh, &TankLocation, &TankBottom, &pHit, &pFaceIndex, &pU, &pV, &pDist);

//so, pDist is the distance from tank to the ground... this is a + number ALWAYS

/*Here''s the Specs of the function
HRESULT D3DXIntersect
(
LPD3DXBASEMESH pMesh, Pointer to an ID3DXBaseMesh interface, representing the mesh to be tested.
CONST D3DXVECTOR3* pRayPos, Pointer to a D3DXVECTOR3 structure, specifying the origin coordinate of the ray.
CONST D3DXVECTOR3* pRayDir, Pointer to a D3DXVECTOR3 structure, specifying the direction of the ray.
BOOL* pHit, Pointer to a BOOL. If the ray intersects a triangular face on the mesh, this value will be set to TRUE. Otherwise, this value is set to FALSE.
DWORD* pFaceIndex, Pointer to an index value of the face closest to the ray origin, if pHit is TRUE.
FLOAT* pU, Pointer to a Barycentric hit coordinate. (Means, where on the triangle did it hit?)
FLOAT* pV, Pointer to a Barycentric hit coordinate.
FLOAT* pDist Pointer to a ray intersection parameter distance.
);
*/

if(pHit)
{
pDist=pDist*probe_distance;
cTank.sObjPhy.location.y=-(pDist-.3);
}
cTank.sObjPhy.location.x-=.01;//just move it for debug

float x=(float)cTank.sObjPhy.location.x;
float y=(float)cTank.sObjPhy.location.y;
float z=(float)cTank.sObjPhy.location.z;

float yaw=(float)cTank.sObjPhy.rotation;//done through user input
float pitch=(float)cTank.sObjPhy.pitch;
float roll=(float)cTank.sObjPhy.roll;

// For our world matrix, we will just leave it as the identity
// this is actually the tank''s matrix. rename later

D3DXMATRIX matRotate;
D3DXMATRIX matTranslate;

D3DXMatrixRotationYawPitchRoll(&matRotate,yaw,pitch,roll);
D3DXMatrixTranslation(&matTranslate,x,y,z);
D3DXMatrixMultiply(matParent,&matRotate,&matTranslate);
g_pd3dDevice->SetTransform(D3DTS_WORLD, matParent);
}


Share this post


Link to post
Share on other sites