当前位置: 首页>>代码示例>>C++>>正文


C++ PhysicsWorld::GetWorld方法代码示例

本文整理汇总了C++中PhysicsWorld::GetWorld方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsWorld::GetWorld方法的具体用法?C++ PhysicsWorld::GetWorld怎么用?C++ PhysicsWorld::GetWorld使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhysicsWorld的用法示例。


在下文中一共展示了PhysicsWorld::GetWorld方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Init

//=============================================================================
//=============================================================================
void Vehicle::Init()
{
    // This function is called only from the main program when initially creating the vehicle, not on scene load
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    
    StaticModel* hullObject = node_->CreateComponent<StaticModel>();
    hullBody_ = node_->CreateComponent<RigidBody>();
    CollisionShape* hullColShape = node_->CreateComponent<CollisionShape>();
    
    hullBody_->SetMass(1200.0f);
    hullBody_->SetLinearDamping(0.2f); // Some air resistance
    hullBody_->SetAngularDamping(0.5f);
    hullBody_->SetCollisionLayer(1);

    
    int rightIndex = 0;
    int upIndex = 1;
    int forwardIndex = 2;
    PhysicsWorld *pPhysWorld = GetScene()->GetComponent<PhysicsWorld>();
    btDynamicsWorld *pbtDynWorld = (btDynamicsWorld*)pPhysWorld->GetWorld();
    
    m_vehicleRayCaster = new btDefaultVehicleRaycaster( pbtDynWorld );
    m_vehicle = new btRaycastVehicle( m_tuning, hullBody_->GetBody(), m_vehicleRayCaster );
    pbtDynWorld->addVehicle( m_vehicle );
    
    

    
    m_vehicle->setCoordinateSystem( rightIndex, upIndex, forwardIndex );
    
    
    //Vector3 v3BoxExtents = Vector3::ONE;//Vector3(1.5f, 1.0f, 3.0f);
    hullObject->SetModel(cache->GetResource<Model>("MyProjects/MiniCooper/test/Chassis_001.mdl"));
    node_->SetScale( Vector3(1.0f, 1.0f, 1.0f) );
  
    
    hullColShape->SetConvexHull(cache->GetResource<Model>("MyProjects/MiniCooper/test/collision.mdl"));
    //hullColShape->SetConvexHull(cache->GetResource<Model>("Models/Box.mdl"));
    //hullColShape->SetBox((hullObject->GetBoundingBox()).Size());
    //hullColShape->SetTriangleMesh(cache->GetResource<Model>("Models/Box.mdl"));
    //hullColShape->SetSize(Vector3(1.0f, 1.0f, 3.0f));
    
    
    //hullColShape->SetPosition((hullObject->GetBoundingBox()).Center() - Vector3(0.0f, 0.0f, 0.0f) );
    //hullColShape->SetPosition( Vector3(0.0f, +0.2f, 0.0f) );
    
    
    
    
   
    
    hullObject->SetCastShadows(true);

    
    Node* patricleTest = node_->CreateChild("patricleTest");
    patricleTest->LoadXML(cache->GetResource<XMLFile>("MyProjects/MiniCooper/particleTest.xml")->GetRoot());
    patricleTest->SetPosition(Vector3(0.0f, 0.2f, -2.0f));

    Node* lightTest = node_->CreateChild("lightTest");
    lightTest->LoadXML(cache->GetResource<XMLFile>("MyProjects/MiniCooper/lightTest.xml")->GetRoot());
    lightTest->SetPosition(Vector3(0.0f, 0.2f, 2.0f));
    

    
    
    

    

    //float connectionHeight = -0.4f;//1.2f;
    //float connectionHeight = 0.0f;
    bool isFrontWheel=true;
    btVector3 wheelDirectionCS0(0,-1,0);
    btVector3 wheelAxleCS(1,0,0);
    
    double wheelOffset = 0.5;
    
    
    // front right
    //////////////
    Node* node_wheel_temp0 = GetScene()->CreateChild("node_wheel_temp0");
    StaticModel* model_wheel_temp0 = node_wheel_temp0->CreateComponent<StaticModel>();
    model_wheel_temp0->SetModel(cache->GetResource<Model>("MyProjects/MiniCooper/test/wheel_000.mdl"));
    model_wheel_temp0->ApplyMaterialList("MyProjects/MiniCooper/test/wheel_000.txt");
    model_wheel_temp0->SetCastShadows(true);

    //btVector3 connectionPointCS0(((model_wheel_temp0->GetBoundingBox()).Center()).x_, ((model_wheel_temp0->GetBoundingBox()).Center()).y_, ((model_wheel_temp0->GetBoundingBox()).Center()).z_);
    //wheelRadius = model_wheel_temp0->GetBoundingBox().HalfSize().y_;
    //m_vehicle->addWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, m_tuning, isFrontWheel);
    btVector3 connectionPointCS0((model_wheel_temp0->GetBoundingBox()).Center().x_,((model_wheel_temp0->GetBoundingBox()).Center()).y_ + wheelOffset,((model_wheel_temp0->GetBoundingBox()).Center()).z_);
    m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,btVector3(-1,0,0),suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);


    Node* node_wheel_0 = GetScene()->CreateChild("node_wheel_0");
    node_wheel_0->SetPosition((model_wheel_temp0->GetBoundingBox()).Center());
    node_wheel_0->SetRotation(Quaternion(0.0f, 0.0f, 90.0f));
    node_wheel_temp0->SetParent(node_wheel_0);
    m_vpNodeWheel.Push( node_wheel_0 );
//.........这里部分代码省略.........
开发者ID:l19g2004,项目名称:Urho3D,代码行数:101,代码来源:Vehicle.cpp


注:本文中的PhysicsWorld::GetWorld方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。