void RuntimeGameObject::AddImpulse(_In_ const Vector3& value) { auto body = _body.lock(); if (body) { body->AddImpulse(value); } }
void RenderFrameDX9(void) { LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9(); device->BeginScene(); AddImpulse(); WaterSimulation(); HeightmapToNormal(); device->SetRenderTarget(0, g_pMainFramebuffer); device->SetDepthStencilSurface(g_pMainDepthbuffer); device->Clear(0, NULL, D3DCLEAR_ZBUFFER, 0x0, 1.0f, 0); RenderWater(); DrawObject(); SwapHeightmaps(); float x = -1.0f; float y = -1.0f; float w = 0.4f; float h = 0.4f; if ( g_iMode & 0x01 ) { DrawImage(g_pTextures[TEX_HEIGHT2], x, y, w, h, &g_ImageInfo); x+=w; } if ( g_iMode & 0x02 ) { D3DXHANDLE shader = g_pWaterEffect->GetTechniqueByName("Heightmap"); D3DXHANDLE heightmap_var = g_pWaterEffect->GetTechniqueByName("heightmap_current"); g_pWaterEffect->SetTechnique(shader); g_pWaterEffect->SetTexture(heightmap_var, g_pTextures[TEX_HEIGHT2]); g_pWaterEffect->Begin(NULL, 0); g_pWaterEffect->BeginPass(0); GutDrawScreenQuad_DX9(x, y, w, h, &g_ImageInfo); g_pWaterEffect->EndPass(); g_pWaterEffect->End(); x+=w; } if ( g_iMode & 0x04 ) { DrawImage(g_pTextures[TEX_NORMAL], x, y, w, h, &g_ImageInfo); x+=w; } device->EndScene(); device->Present( NULL, NULL, NULL, NULL ); }
void RPhysics::ProcessPlayerCollision(RPlayer *other) { m_boostLeft = 0; other->physicsEngine->m_boostLeft = 0; Vector4 velDiff = m_velocity-other->physicsEngine->m_velocity; Vector4 initImp = -25*velDiff; AddImpulse(initImp); other->physicsEngine->AddImpulse(-initImp); /* if(DotProduct3(m_velocity,other->physicsEngine->m_velocity)>0) { if(Length3(m_velocity)-Length3(other->physicsEngine->m_velocity)<0) { Vector4 imp = 18*Normalize3(other->physicsEngine->m_velocity)*Length3(velDiff); //AddImpulse(imp); //other->physicsEngine->AddImpulse(-imp); } } */ Vector4 dummy; Vector4 dirToUse = other->getPos()-m_player->getPos(); m_player->Move(.3,-dirToUse,dummy); other->Move(.3,dirToUse,dummy); }
void RigidBody2D::AddImpulse(const Vector2f& impulse, CoordSys coordSys) { return AddImpulse(impulse, GetCenterOfGravity(coordSys), coordSys); }
void RigidBody2D::AddImpulse(const Vector2f& impulse, CoordSys coordSys) { return AddImpulse(impulse, GetMassCenter(coordSys), coordSys); }