I'm trying to make my own basic physics engine, featuring gravity, collision detection, and hopefully some ragdoll. This engine is made in directX 9 in case you didn't notice.
My problem is with the gravity function.
The function is called every millesecond from a timer.
Here is what it looks like:
FrameStruct is a struct with three variables:Code:void Phy_Gravity(LPDIRECT3DRMFRAME frScene, LPDIRECT3DRMFRAME Camera){ LPDIRECT3DRMFRAMEARRAY SceneArray; FrameStruct frFrame; D3DVECTOR vectPos; int ArraySize; frScene->GetChildren(&SceneArray); ArraySize = SceneArray->GetSize(); for (int i = 0; i < ArraySize; i++){ SceneArray->GetElement(i, &frFrame.frFrame); frFrame.frFrame->GetPosition(frScene, &vectPos); if (frFrame.frFrame != Camera){ frFrame.frFrame->SetVelocity(frScene, 0, -frFrame.Weight, 0, false); } } }
You'll notice that if the frame being pulled is not the camera, then I want the object to go down on the y axis according to its own weight, which I defined when I created the frame.Code:LPDIRECT3DRMFRAME frFrame int Weight int Bounce
I set the weight of the cube to 0.1, but I tried debugging and it shows me the weight as being -8.blah blah blah which is way to fast.
I think the problem is that the function does not get the weight variable when I do this:
So it guesses the weight and puts it to a huge number, like -8.Code:SceneArray->GetElement(i, &frFrame.frFrame);
How do I get my function to be able to use the weight variable?



LinkBack URL
About LinkBacks


