VisBaseEntity_cl* IController::AddCube(float x, float y, float z) { VisBaseEntity_cl *ent = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(x, y, z), "Models\\Misc\\Cube.Model"); vHavokRigidBody *cube = new vHavokRigidBody(); cube->Havok_TightFit = true; ent->AddComponent(cube); //EntityStack stack = *entityStack; //stack.push(ent); entityStack->push(ent); return ent; }
VisBaseEntity_cl* IController::AddRagdoll(float x, float y, float z) { VisBaseEntity_cl *ent = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(x, y, z), "Models\\Warrior\\Warrior.model"); vHavokRagdoll *ragdoll = new vHavokRagdoll(); ragdoll->SetRagdollCollisionFile("Models\\Warrior\\WarriorRagdoll.hkt"); ent->AddComponent(ragdoll); //EntityStack stack = *entityStack; //stack.push(ent); entityStack->push(ent); return ent; }
VisBaseEntity_cl* IController::AddSphere(float x, float y, float z) { VisBaseEntity_cl *ent = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(x, y, z), "Models\\Misc\\Sphere.Model"); vHavokRigidBody *sphere = new vHavokRigidBody(); sphere->Havok_TightFit = true; sphere->Havok_Restitution = 1.0f; ent->AddComponent(sphere); //EntityStack stack = *entityStack; //stack.push(ent); entityStack->push(ent); return ent; }
//////////////////////////// Water Simulation Controls ////////////////////////////////////////////////////////////// VisBaseEntity_cl *IController::AddWaterDrop(float x, float y, float z, float scaling) { VisBaseEntity_cl *ent = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(x, y, z), "Assets\\Models\\Misc\\Sphere.Model"); ent->SetScaling(scaling); vHavokRigidBody *sphere = new vHavokRigidBody(); sphere->Havok_TightFit = true; sphere->Havok_Restitution = .35f; ent->AddComponent(sphere); ent->Tag(); entityStack->push(ent); return ent; }
void ParticleRainController::RainBalls(int numOfBalls){ while (ballCount < numOfBalls){ int randomx = rand() % 6000 - 3255; int randomy = rand() % 6000 - 1416; VisBaseEntity_cl *ent = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(randomx, randomy, 3000), "Models\\Misc\\Sphere.Model"); vHavokRigidBody *ball = new vHavokRigidBody(); ball->Havok_TightFit = true; ball->Havok_Mass = 5.0f; ball->Havok_Restitution = 1.0f; ball->Shape_Type = ShapeType_SPHERE; ent->SetScaling(1.0f); ent->AddComponent(ball); ++ballCount; } ballCount = 0; }
bool WaterSimulationController::Run(VInputMap* inputMap){ if(inputMap->GetTrigger(CUSTOM_CONTROL_ONE)){ VisBaseEntity_cl *ent = this->AddSphere(0, 0, 300); ent->SetScaling(0.15f); ent->RemoveAllComponents(); vHavokRigidBody *sphere = new vHavokRigidBody(); sphere->Havok_TightFit = true; sphere->Havok_Restitution = 0.1f; ent->AddComponent(sphere); } if(inputMap->GetTrigger(CUSTOM_CONTROL_TWO)){ TriggerBoxEntity_cl *triggerbox = vdynamic_cast <TriggerBoxEntity_cl *> (Vision::Game.SearchEntity("triggerbox")); if(triggerbox->IsEnabled()) triggerbox->SetEnabled(false); else if(!triggerbox->IsEnabled()) triggerbox->SetEnabled(true); } return true; }
static void LookAtBox(const hkvAlignedBBox &bbox) { if (!bbox.isValid()) return; VisBaseEntity_cl* pCenterEntity = Vision::Game.CreateEntity("VisBaseEntity_cl", bbox.getCenter()); const float fBBRadius = bbox.getBoundingSphere().m_fRadius; float fFovX, fFovY; Vision::Contexts.GetMainRenderContext()->GetFinalFOV(fFovX, fFovY); const float fDist = fBBRadius / hkvMath::tanDeg(hkvMath::Min(fFovX, fFovY) * 0.5f); VOrbitCamera* pOrbitCamera = new VOrbitCamera(); pOrbitCamera->MinimalDistance = fDist * 0.01f; pOrbitCamera->MaximalDistance = fDist * 100.0f; pOrbitCamera->CameraDistance = fDist; pCenterEntity->AddComponent(pOrbitCamera); }
void VLineFollowerComponent::InitPhysics(float fPathPos) { VisBaseEntity_cl* pOwner = (VisBaseEntity_cl *)GetOwner(); if (!pOwner) return; hkvVec3 vPos; hkvVec3 vDir; hkvAlignedBBox bbox; m_fCurrentPathPos = fPathPos; if(m_pFollowPath) m_pFollowPath->EvalPoint(fPathPos, vPos, &vDir); else vPos = pOwner->GetPosition(); // to determine correct height on the ground, perform a ray-cast: if (Vision::GetApplication()->GetPhysicsModule()!=NULL && Model_CapsuleHeight>0) { hkvVec3 vRayStart(vPos.x,vPos.y,vPos.z+Model_CapsuleHeight); hkvVec3 vRayEnd(vPos.x,vPos.y,vPos.z-Model_CapsuleHeight); VisPhysicsHit_t hitPoint; if (Vision::GetApplication()->GetPhysicsModule()->Raycast(vRayStart, vRayEnd, hitPoint)) // hit? { vPos.z = hitPoint.vImpactPoint.z + 5.f*Vision::World.GetGlobalUnitScaling(); // add some margin } } VDynamicMesh *pMesh = pOwner->GetMesh(); if (pMesh) { pMesh->GetCollisionBoundingBox(bbox); vPos.z -= bbox.m_vMin.z; // Use model size if not set if (Model_CapsuleRadius<=0.f) Model_CapsuleRadius = hkvMath::Min( bbox.getSizeX(), bbox.getSizeY() )/2.f; if (Model_CapsuleHeight<=0.f) Model_CapsuleHeight = bbox.getSizeZ(); } else { // No model - set some sane values if not set if (Model_CapsuleRadius<=0.f) Model_CapsuleRadius = 40.f; if (Model_CapsuleHeight<=0.f) Model_CapsuleHeight = 90.f; } // Create the physics object pOwner->SetPosition(vPos); if (!m_pPhys) { m_pPhys = new vHavokCharacterController(); m_pPhys->Capsule_Radius = Model_CapsuleRadius; float h = Model_CapsuleHeight * 0.5f; float fPivot = Model_GroundOffset; m_pPhys->Character_Top.set(0, 0, h - fPivot); m_pPhys->Character_Bottom.set(0, 0, -h - fPivot); pOwner->AddComponent(m_pPhys); } // Update position m_pPhys->SetPosition(vPos); // Enable debug rendering m_pPhys->SetDebugRendering(Debug_RenderMesh); m_pPhys->SetDebugColor(V_RGBA_RED); }