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


C++ Light::SetCastShadows方法代码示例

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


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

示例1: Tile

TileMaster::TileMaster(Context *context, MasterControl* masterControl):
Object(context),
  masterControl_{masterControl}
{
    rootNode_ = masterControl_->world.scene->CreateChild("TileMaster");
    //Create hexagonal field
    //Lays a field of hexagons at the origin
    int bigHexSize = 23;
    for (int i = 0; i < bigHexSize; i++) {
        for (int j = 0; j < bigHexSize; j++) {
            if (i < (bigHexSize - bigHexSize / 4) + j / 2 &&  //Exclude bottom right
                    i > (bigHexSize / 4) - (j + 1) / 2 &&  //Exclude bottom left
                    i + 1 < (bigHexSize - bigHexSize / 4) + ((bigHexSize - j + 1)) / 2 &&  //Exclude top right
                    i - 1 > (bigHexSize / 4) - ((bigHexSize - j + 2) / 2)) { //Exclude top left
                Vector3 tilePos = Vector3((-bigHexSize / 2.0f + i) * 2.0f + j % 2, -0.1f, (-bigHexSize / 2.0f + j + 0.5f) * 1.8f);
                tileMap_[IntVector2(i, j)] = new Tile(context_, this, tilePos);
            }
        }
    }
    //Add a directional light to the arena. Enable cascaded shadows on it
    Node* lightNode = rootNode_->CreateChild("Sun");
    lightNode->SetPosition(Vector3::UP*5.0f);
    lightNode->SetRotation(Quaternion(90.0f, 0.0f, 0.0f));
    Light* playLight = lightNode->CreateComponent<Light>();
    playLight->SetLightType(LIGHT_DIRECTIONAL);
    playLight->SetBrightness(0.8f);
    playLight->SetRange(10.0f);
    playLight->SetColor(Color(1.0f, 0.9f, 0.95f));
    playLight->SetCastShadows(false);
}
开发者ID:1vanK,项目名称:heXon,代码行数:30,代码来源:tilemaster.cpp

示例2: Object

CameraMaster::CameraMaster(
    Context *context,
    MasterControl *masterControl
) :
    Object(context),
    masterControl_{masterControl}
{
    SubscribeToEvent(E_SCENEUPDATE, HANDLER(CameraMaster, HandleSceneUpdate));

    //Create the camera. Limit far clip distance to match the fog
    translationNode_ = masterControl_->world_.scene->CreateChild("CamTrans");
    rotationNode_ = translationNode_->CreateChild("CamRot");
    camera_ = rotationNode_->CreateComponent<Camera>();
    camera_->SetFarClip(1024.0f);
    //Set an initial position for the camera scene node above the origin
    //translationNode_->SetPosition(Vector3(0.0f, 3.0f, 0.0f));
    translationNode_->SetPosition(Vector3(0.0, 3.0,-20.0));

    rotationNode_->SetRotation(Quaternion(0.0f, 90.0f, 0.0f));
    rigidBody_ = translationNode_->CreateComponent<RigidBody>();
    rigidBody_->SetAngularDamping(10.0f);
    CollisionShape* collisionShape = translationNode_->CreateComponent<CollisionShape>();
    collisionShape->SetSphere(0.1f);
    rigidBody_->SetMass(1.0f);

    Node* lightNode = translationNode_->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.0f, -1.0f, 0.0f));
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_POINT);
    light->SetBrightness(0.5f);
    light->SetColor(Color(0.7f, 0.9f, 0.6f));
    light->SetCastShadows(false);

    SetupViewport();
}
开发者ID:richelbilderbeek,项目名称:TestVoxelWidget,代码行数:35,代码来源:cameramaster.cpp

示例3: CreateScene

void Labyrinth::CreateScene()
{
    // ADDED
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    
    scene_ = new Scene(context_);
    
    // TODO vzdialenost kamery podla rozlisenia obrazovky
    
    // Create scene subsystem components
    scene_->CreateComponent<Octree>();
    scene_->CreateComponent<PhysicsWorld>();
    scene_->CreateComponent<DebugRenderer>();
    
    // Create camera and define viewport. We will be doing load / save, so it's convenient to create the camera outside the scene,
    // so that it won't be destroyed and recreated, and we don't have to redefine the viewport on load
    // TODO treb vytunit poziciu kamery a jej rotaciu
    cameraNode_ = new Node(context_);
    cameraNode_->SetName("cameraNode");
    Camera* camera = cameraNode_->CreateComponent<Camera>();
    camera->SetFarClip(300.0f);
    // aby to vyzeralo ako 2.5D treba prepnut ortho na true
    /*camera->SetOrthographic(false);
    cameraNode_->SetPosition(Vector3(10, 90, 10));
    cameraNode_->SetRotation(Quaternion(75, 0, 0));
    GetSubsystem<Renderer>()->SetViewport(0, new Viewport(context_, scene_, camera));*/
    
    camera->SetOrthographic(false);
    cameraNode_->SetPosition(Vector3(0, 10, 0));
    cameraNode_->SetRotation(Quaternion(90, 0, 0));
    
   
    
    // Create static scene content. First create a zone for ambient lightning and fog control
    Node* zoneNode = scene_->CreateChild("Zone");
    Zone* zone = zoneNode->CreateComponent<Zone>();
    zone->SetAmbientColor(Color(0.15f, 0.15f, 0.15f));
    zone->SetFogColor(Color(0.5f, 0.5f, 0.7f));
    zone->SetFogStart(1000.0f);
    zone->SetFogEnd(1000.0f);
    zone->SetBoundingBox(BoundingBox(-1000.0f, 1000.0f));

    // Create a directional light with cascaded shadow mapping
    Node* lightNode = scene_->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.3f, -0.5f, 0.425f));
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);
    light->SetCastShadows(true);
    light->SetShadowBias(BiasParameters(0.00025f, 0.5f));
    light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));
    light->SetSpecularIntensity(1.0f);
    
    // ------------------------------------------
    
    CreateFloor(20, 14);
}
开发者ID:emp64,项目名称:TuxKing,代码行数:56,代码来源:Labyrinth.cpp

示例4: CreateScene

void Navigation::CreateScene()
{
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    
    scene_ = new Scene(context_);
    
    // Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
    // Also create a DebugRenderer component so that we can draw debug geometry
    scene_->CreateComponent<Octree>();
    scene_->CreateComponent<DebugRenderer>();
    
    // Create scene node & StaticModel component for showing a static plane
    Node* planeNode = scene_->CreateChild("Plane");
    planeNode->SetScale(Vector3(100.0f, 1.0f, 100.0f));
    StaticModel* planeObject = planeNode->CreateComponent<StaticModel>();
    planeObject->SetModel(cache->GetResource<Model>("Models/Plane.mdl"));
    planeObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));
    
    // Create a Zone component for ambient lighting & fog control
    Node* zoneNode = scene_->CreateChild("Zone");
    Zone* zone = zoneNode->CreateComponent<Zone>();
    zone->SetBoundingBox(BoundingBox(-1000.0f, 1000.0f));
    zone->SetAmbientColor(Color(0.15f, 0.15f, 0.15f));
    zone->SetFogColor(Color(0.5f, 0.5f, 0.7f));
    zone->SetFogStart(100.0f);
    zone->SetFogEnd(300.0f);
    
    // Create a directional light to the world. Enable cascaded shadows on it
    Node* lightNode = scene_->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.6f, -1.0f, 0.8f));
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);
    light->SetCastShadows(true);
    light->SetShadowBias(BiasParameters(0.0001f, 0.5f));
    // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
    light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));
    
    // Create some mushrooms
    const unsigned NUM_MUSHROOMS = 100;
    for (unsigned i = 0; i < NUM_MUSHROOMS; ++i)
        CreateMushroom(Vector3(Random(90.0f) - 45.0f, 0.0f, Random(90.0f) - 45.0f));
    
    // Create randomly sized boxes. If boxes are big enough, make them occluders
    const unsigned NUM_BOXES = 20;
    for (unsigned i = 0; i < NUM_BOXES; ++i)
    {
        Node* boxNode = scene_->CreateChild("Box");
        float size = 1.0f + Random(10.0f);
        boxNode->SetPosition(Vector3(Random(80.0f) - 40.0f, size * 0.5f, Random(80.0f) - 40.0f));
        boxNode->SetScale(size);
        StaticModel* boxObject = boxNode->CreateComponent<StaticModel>();
        boxObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
        boxObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
        boxObject->SetCastShadows(true);
        if (size >= 3.0f)
            boxObject->SetOccluder(true);
    }
    
    // Create a NavigationMesh component to the scene root
    NavigationMesh* navMesh = scene_->CreateComponent<NavigationMesh>();
    // Create a Navigable component to the scene root. This tags all of the geometry in the scene as being part of the
    // navigation mesh. By default this is recursive, but the recursion could be turned off from Navigable
    scene_->CreateComponent<Navigable>();
    // Add padding to the navigation mesh in Y-direction so that we can add objects on top of the tallest boxes
    // in the scene and still update the mesh correctly
    navMesh->SetPadding(Vector3(0.0f, 10.0f, 0.0f));
    // Now build the navigation geometry. This will take some time. Note that the navigation mesh will prefer to use
    // physics geometry from the scene nodes, as it often is simpler, but if it can not find any (like in this example)
    // it will use renderable geometry instead
    navMesh->Build();
    
    // Create the camera. Limit far clip distance to match the fog
    cameraNode_ = scene_->CreateChild("Camera");
    Camera* camera = cameraNode_->CreateComponent<Camera>();
    camera->SetFarClip(300.0f);
    
    // Set an initial position for the camera scene node above the plane
    cameraNode_->SetPosition(Vector3(0.0f, 5.0f, 0.0f));
}
开发者ID:PeteX,项目名称:Urho3D,代码行数:79,代码来源:Navigation.cpp

示例5: CreateScene

void CharacterDemo::CreateScene()
{
    ResourceCache* cache = GetSubsystem<ResourceCache>();

    scene_ = new Scene(context_);

    // Create scene subsystem components
    scene_->CreateComponent<Octree>();
    scene_->CreateComponent<PhysicsWorld>();

    // Create camera and define viewport. We will be doing load / save, so it's convenient to create the camera outside the scene,
    // so that it won't be destroyed and recreated, and we don't have to redefine the viewport on load
    cameraNode_ = new Node(context_);
    Camera* camera = cameraNode_->CreateComponent<Camera>();
    camera->SetFarClip(300.0f);
    GetSubsystem<Renderer>()->SetViewport(0, new Viewport(context_, scene_, camera));

    // Create static scene content. First create a zone for ambient lighting and fog control
    Node* zoneNode = scene_->CreateChild("Zone");
    Zone* zone = zoneNode->CreateComponent<Zone>();
    zone->SetAmbientColor(Color(0.15f, 0.15f, 0.15f));
    zone->SetFogColor(Color(0.5f, 0.5f, 0.7f));
    zone->SetFogStart(100.0f);
    zone->SetFogEnd(300.0f);
    zone->SetBoundingBox(BoundingBox(-1000.0f, 1000.0f));

    // Create a directional light with cascaded shadow mapping
    Node* lightNode = scene_->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.3f, -0.5f, 0.425f));
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);
    light->SetCastShadows(true);
    light->SetShadowBias(BiasParameters(0.00025f, 0.5f));
    light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));
    light->SetSpecularIntensity(0.5f);

    // Create the floor object
    Node* floorNode = scene_->CreateChild("Floor");
    floorNode->SetPosition(Vector3(0.0f, -0.5f, 0.0f));
    floorNode->SetScale(Vector3(200.0f, 1.0f, 200.0f));
    StaticModel* object = floorNode->CreateComponent<StaticModel>();
    object->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
    object->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));

    RigidBody* body = floorNode->CreateComponent<RigidBody>();
    // Use collision layer bit 2 to mark world scenery. This is what we will raycast against to prevent camera from going
    // inside geometry
    body->SetCollisionLayer(2);
    CollisionShape* shape = floorNode->CreateComponent<CollisionShape>();
    shape->SetBox(Vector3::ONE);

    // Create mushrooms of varying sizes
    const unsigned NUM_MUSHROOMS = 60;
    for (unsigned i = 0; i < NUM_MUSHROOMS; ++i)
    {
        Node* objectNode = scene_->CreateChild("Mushroom");
        objectNode->SetPosition(Vector3(Random(180.0f) - 90.0f, 0.0f, Random(180.0f) - 90.0f));
        objectNode->SetRotation(Quaternion(0.0f, Random(360.0f), 0.0f));
        objectNode->SetScale(2.0f + Random(5.0f));
        StaticModel* object = objectNode->CreateComponent<StaticModel>();
        object->SetModel(cache->GetResource<Model>("Models/Mushroom.mdl"));
        object->SetMaterial(cache->GetResource<Material>("Materials/Mushroom.xml"));
        object->SetCastShadows(true);

        RigidBody* body = objectNode->CreateComponent<RigidBody>();
        body->SetCollisionLayer(2);
        CollisionShape* shape = objectNode->CreateComponent<CollisionShape>();
        shape->SetTriangleMesh(object->GetModel(), 0);
    }

    // Create movable boxes. Let them fall from the sky at first
    const unsigned NUM_BOXES = 100;
    for (unsigned i = 0; i < NUM_BOXES; ++i)
    {
        float scale = Random(2.0f) + 0.5f;

        Node* objectNode = scene_->CreateChild("Box");
        objectNode->SetPosition(Vector3(Random(180.0f) - 90.0f, Random(10.0f) + 10.0f, Random(180.0f) - 90.0f));
        objectNode->SetRotation(Quaternion(Random(360.0f), Random(360.0f), Random(360.0f)));
        objectNode->SetScale(scale);
        StaticModel* object = objectNode->CreateComponent<StaticModel>();
        object->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
        object->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
        object->SetCastShadows(true);

        RigidBody* body = objectNode->CreateComponent<RigidBody>();
        body->SetCollisionLayer(2);
        // Bigger boxes will be heavier and harder to move
        body->SetMass(scale * 2.0f);
        CollisionShape* shape = objectNode->CreateComponent<CollisionShape>();
        shape->SetBox(Vector3::ONE);
    }
}
开发者ID:evolarium,项目名称:Urho3D,代码行数:93,代码来源:CharacterDemo.cpp

示例6: _ApplyChanges

void DataViewer_GameObject::_ApplyChanges()
{
	if ( _changeList["GameObject"] )
	{
		_selectedObject->SetSavable( _ReadWidget_Bool( _dataGameObject.savable ) );
		_selectedObject->SetEnabled( _ReadWidget_Bool( _dataGameObject.enable ) );
		_selectedObject->SetName( _ReadWidget_String( _dataGameObject.name ) );

		
		_Colorize_GameObject( _selectedObject->IsEnabled() );
		_Colorize_Transform( _selectedObject->IsEnabled() );

		I_Component* comp;

		comp = _selectedObject->GetComponent<Camera>();
		if ( comp != NULL )
		{
			_Colorize_Camera( _selectedObject->IsEnabled() && comp->IsEnabled() );
		}

		comp = _selectedObject->GetComponent<Light>();
		if ( comp != NULL )
		{
			_Colorize_Light( _selectedObject->IsEnabled() && comp->IsEnabled() );
		}

		comp = _selectedObject->GetComponent<MeshDrawing>();
		if ( comp != NULL )
		{
			_Colorize_MeshDrawing( _selectedObject->IsEnabled() && comp->IsEnabled() );
		}

		for (auto& dataScript : _dataScripts)
		{
			Script* script = _selectedObject->GetComponent<Script>( dataScript.scriptName );
			_Colorize_Script( _selectedObject->IsEnabled() && script->IsEnabled(), dataScript );
		}	


		_changeList["GameObject"] = false;
		return;
	}

	if ( _changeList["Transform_Local"] )
	{
		Transform* transform = _selectedObject->GetComponent<Transform>();
		transform->SetPositionLocal( _ReadWidget_Vector3( _dataTransform.posLocal ) );
		transform->SetEulerRotationLocal( _ReadWidget_Vector3( _dataTransform.rotLocal ) );
		transform->SetScaleLocal( _ReadWidget_Vector3( _dataTransform.scaleLocal ) );

		_changeList["Transform_Local"] = false;
		return;
	}

	if ( _changeList["Transform_World"] )
	{
		Transform* transform = _selectedObject->GetComponent<Transform>();
		transform->SetPositionWorld( _ReadWidget_Vector3( _dataTransform.posWorld ) );
		transform->SetEulerRotationWorld( _ReadWidget_Vector3( _dataTransform.rotWorld ) );
		transform->SetScaleWorld( _ReadWidget_Vector3( _dataTransform.scaleWorld ) );

		_changeList["Transform_World"] = false;
		return;
	}

	if ( _changeList["Light"] )
	{
		Light* light = _selectedObject->GetComponent<Light>();
		light->SetEnabled( _ReadWidget_Bool( _dataLight.enable ) );
		light->SetType( EnumConvertor::s2e_LightType[ _ReadWidget_Choice( _dataLight.type ) ] );
		light->SetColor( _ReadWidget_Vector3( _dataLight.color ) );
		light->SetIntensity( _ReadWidget_Float( _dataLight.intensity ) );
		light->SetRange( _ReadWidget_Float( _dataLight.range ) );
		light->SetSpotAngle( _ReadWidget_Float( _dataLight.spotAngle ) );
		light->SetCastShadows( _ReadWidget_Bool( _dataLight.castShadows ) );

		_Colorize_Light( light->IsEnabled() && _selectedObject->IsEnabled() );

		_changeList["Light"] = false;
		return;
	}

	if ( _changeList["Camera"] )
	{
		Camera* camera = _selectedObject->GetComponent<Camera>();
		camera->SetEnabled( _ReadWidget_Bool( _dataCamera.enable ) );
		camera->SetType( EnumConvertor::s2e_CameraType[ _ReadWidget_Choice( _dataCamera.type ) ] );
		camera->SetOrthoSize( _ReadWidget_Vector2( _dataCamera.orthoSize ) );
		camera->SetFovYAngle( _ReadWidget_Float( _dataCamera.fovYAngle ) );
		camera->SetAspectRatio( _ReadWidget_Float( _dataCamera.aspectRatio ) );
		camera->SetNearClipping( _ReadWidget_Float( _dataCamera.nearClipping ) );
		camera->SetFarClipping( _ReadWidget_Float( _dataCamera.farClipping ) );

		_Colorize_Camera( camera->IsEnabled() && _selectedObject->IsEnabled() );

		_changeList["Camera"] = false;
		return;
	}

	if ( _changeList["MeshDrawing"] )
//.........这里部分代码省略.........
开发者ID:MorcoFreeCode,项目名称:2015__MorcoEngine3D,代码行数:101,代码来源:DataViewer_GameObject.cpp

示例7: CreateScene

void VehicleDemo::CreateScene()
{
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    
    scene_ = new Scene(context_);
    
    // Create scene subsystem components
    scene_->CreateComponent<Octree>();
    scene_->CreateComponent<PhysicsWorld>();
    
    // Create camera and define viewport. We will be doing load / save, so it's convenient to create the camera outside the scene,
    // so that it won't be destroyed and recreated, and we don't have to redefine the viewport on load
    cameraNode_ = new Node(context_);
    Camera* camera = cameraNode_->CreateComponent<Camera>();
    camera->SetFarClip(500.0f);
    GetSubsystem<Renderer>()->SetViewport(0, new Viewport(context_, scene_, camera));
    
    // Create static scene content. First create a zone for ambient lighting and fog control
    Node* zoneNode = scene_->CreateChild("Zone");
    Zone* zone = zoneNode->CreateComponent<Zone>();
    zone->SetAmbientColor(Color(0.15f, 0.15f, 0.15f));
    zone->SetFogColor(Color(0.5f, 0.5f, 0.7f));
    zone->SetFogStart(300.0f);
    zone->SetFogEnd(500.0f);
    zone->SetBoundingBox(BoundingBox(-2000.0f, 2000.0f));
    
    // Create a directional light with cascaded shadow mapping
    Node* lightNode = scene_->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.3f, -0.5f, 0.425f));
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);
    light->SetCastShadows(true);
    light->SetShadowBias(BiasParameters(0.00025f, 0.5f));
    light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));
    light->SetSpecularIntensity(0.5f);
    
    // Create heightmap terrain with collision
    Node* terrainNode = scene_->CreateChild("Terrain");
    terrainNode->SetPosition(Vector3::ZERO);
    Terrain* terrain = terrainNode->CreateComponent<Terrain>();
    terrain->SetPatchSize(64);
    terrain->SetSpacing(Vector3(2.0f, 0.1f, 2.0f)); // Spacing between vertices and vertical resolution of the height map
    terrain->SetSmoothing(true);
    terrain->SetHeightMap(cache->GetResource<Image>("Textures/HeightMap.png"));
    terrain->SetMaterial(cache->GetResource<Material>("Materials/Terrain.xml"));
    // The terrain consists of large triangles, which fits well for occlusion rendering, as a hill can occlude all
    // terrain patches and other objects behind it
    terrain->SetOccluder(true);
    
    RigidBody* body = terrainNode->CreateComponent<RigidBody>();
    body->SetCollisionLayer(2); // Use layer bitmask 2 for static geometry
    CollisionShape* shape = terrainNode->CreateComponent<CollisionShape>();
    shape->SetTerrain();
    
    // Create 1000 mushrooms in the terrain. Always face outward along the terrain normal
    const unsigned NUM_MUSHROOMS = 1000;
    for (unsigned i = 0; i < NUM_MUSHROOMS; ++i)
    {
        Node* objectNode = scene_->CreateChild("Mushroom");
        Vector3 position(Random(2000.0f) - 1000.0f, 0.0f, Random(2000.0f) - 1000.0f);
        position.y_ = terrain->GetHeight(position) - 0.1f;
        objectNode->SetPosition(position);
        // Create a rotation quaternion from up vector to terrain normal
        objectNode->SetRotation(Quaternion(Vector3::UP, terrain->GetNormal(position)));
        objectNode->SetScale(3.0f);
        StaticModel* object = objectNode->CreateComponent<StaticModel>();
        object->SetModel(cache->GetResource<Model>("Models/Mushroom.mdl"));
        object->SetMaterial(cache->GetResource<Material>("Materials/Mushroom.xml"));
        object->SetCastShadows(true);
        
        RigidBody* body = objectNode->CreateComponent<RigidBody>();
        body->SetCollisionLayer(2);
        CollisionShape* shape = objectNode->CreateComponent<CollisionShape>();
        shape->SetTriangleMesh(object->GetModel(), 0);
    }
}
开发者ID:3dicc,项目名称:Urho3D,代码行数:76,代码来源:VehicleDemo.cpp

示例8: Scene

void Urho3DTemplate::CreateScene()
{
    ResourceCache* cache = GetSubsystem<ResourceCache>();

    scene_ = new Scene(context_);

    //Create octree, use default volume (-1000, -1000, -1000) to (1000,1000,1000)
    //Also create a DebugRenderer component so that we can draw debug geometry
    scene_->CreateComponent<Octree>();
    scene_->CreateComponent<DebugRenderer>();

    //Create scene node & StaticModel component for showing a static plane
    Node* planeNode = scene_->CreateChild("Plane");
    planeNode->SetScale(Vector3(100.0f, 1.0f, 100.0f));
    StaticModel* planeObject = planeNode->CreateComponent<StaticModel>();
    planeObject->SetModel(cache->GetResource<Model>("Models/Plane.mdl"));
    planeObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));

    //Create a Zone component for ambient lighting & fog control
    Node* zoneNode = scene_->CreateChild("Zone");
    Zone* zone = zoneNode->CreateComponent<Zone>();
    zone->SetBoundingBox(BoundingBox(-1000.0f, 1000.0f));
    zone->SetAmbientColor(Color(0.15f, 0.15f, 0.15f));
    zone->SetFogColor(Color(0.5f, 0.5f, 0.7f));
    zone->SetFogStart(100.0f);
    zone->SetFogEnd(300.0f);

    //Create a directional light to the world. Enable cascaded shadows on it
    Node* lightNode = scene_->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.6f, -1.0f, 0.8f));
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);
    light->SetCastShadows(true);
    light->SetShadowBias(BiasParameters(0.00025f, 0.5f));

    //Set cascade splits at 10, 50, 200 world unitys, fade shadows at 80% of maximum shadow distance
    light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));

    //Create some mushrooms
    const unsigned NUM_MUSHROOMS = 100;
    for (unsigned i = 0; i < NUM_MUSHROOMS; ++i)
        CreateMushroom(Vector3(Random(90.0f) - 45.0f, 0.0f, Random(90.0f) - 45.0f));

    //Create randomly sized boxes. If boxes are big enough make them occluders
    const unsigned NUM_BOXES = 20;
    for (unsigned i = 0; i <NUM_BOXES; ++i)
    {
        Node* boxNode = scene_->CreateChild("Box");
        float size = 1.0f + Random(10.0f);
        boxNode->SetPosition(Vector3(Random(80.0f) - 40.0f, size * 0.5f, Random(80.0f) - 40.0f));
        boxNode->SetScale(size);
        StaticModel* boxObject = boxNode->CreateComponent<StaticModel>();
        boxObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
        boxObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
        boxObject->SetCastShadows(true);
        if (size >= 3.0f)
            boxObject->SetOccluder(true);
    }

    //Create Jack node that will follow the path
    jackNode_ = scene_->CreateChild("Jack");
    jackNode_->SetPosition(Vector3(-5.0f, 0.0f, 20.0f));
    AnimatedModel* modelObject = jackNode_->CreateComponent<AnimatedModel>();
    modelObject->SetModel(cache->GetResource<Model>("Model/Jack.mdl"));
    modelObject->SetMaterial(cache->GetResource<Material>("Materials/Jack.xml"));
    modelObject->SetCastShadows(true);

    //Create the camera. Limit far clip distance to match the fog
    cameraNode_ = scene_->CreateChild("Camera");
    Camera* camera = cameraNode_->CreateComponent<Camera>();
    camera->SetFarClip(300.0f);

    //Set an initial position for the camera scene node above the plane
    cameraNode_->SetPosition(Vector3(0.0f, 5.0f, 0.0f));
}
开发者ID:richelbilderbeek,项目名称:TestVoxelWidget,代码行数:75,代码来源:qtvoxelwidget.cpp

示例9: CreateScene

void RibbonTrailDemo::CreateScene()
{
    ResourceCache* cache = GetSubsystem<ResourceCache>();

    scene_ = new Scene(context_);

    // Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
    scene_->CreateComponent<Octree>();

    // Create scene node & StaticModel component for showing a static plane
    Node* planeNode = scene_->CreateChild("Plane");
    planeNode->SetScale(Vector3(100.0f, 1.0f, 100.0f));
    StaticModel* planeObject = planeNode->CreateComponent<StaticModel>();
    planeObject->SetModel(cache->GetResource<Model>("Models/Plane.mdl"));
    planeObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));

    // Create a directional light to the world.
    Node* lightNode = scene_->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.6f, -1.0f, 0.8f)); // The direction vector does not need to be normalized
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);
    light->SetCastShadows(true);
    light->SetShadowBias(BiasParameters(0.00005f, 0.5f));
    // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
    light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));

    // Create first box for face camera trail demo with 1 column.
    boxNode1_ = scene_->CreateChild("Box1");
    StaticModel* box1 = boxNode1_->CreateComponent<StaticModel>();
    box1->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
    box1->SetCastShadows(true);
    RibbonTrail* boxTrail1 = boxNode1_->CreateComponent<RibbonTrail>();
    boxTrail1->SetMaterial(cache->GetResource<Material>("Materials/RibbonTrail.xml"));
    boxTrail1->SetStartColor(Color(1.0f, 0.5f, 0.0f, 1.0f));
    boxTrail1->SetEndColor(Color(1.0f, 1.0f, 0.0f, 0.0f));
    boxTrail1->SetWidth(0.5f);
    boxTrail1->SetUpdateInvisible(true);

    // Create second box for face camera trail demo with 4 column.
    // This will produce less distortion than first trail.
    boxNode2_ = scene_->CreateChild("Box2");
    StaticModel* box2 = boxNode2_->CreateComponent<StaticModel>();
    box2->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
    box2->SetCastShadows(true);
    RibbonTrail* boxTrail2 = boxNode2_->CreateComponent<RibbonTrail>();
    boxTrail2->SetMaterial(cache->GetResource<Material>("Materials/RibbonTrail.xml"));
    boxTrail2->SetStartColor(Color(1.0f, 0.5f, 0.0f, 1.0f));
    boxTrail2->SetEndColor(Color(1.0f, 1.0f, 0.0f, 0.0f));
    boxTrail2->SetWidth(0.5f);
    boxTrail2->SetTailColumn(4);
    boxTrail2->SetUpdateInvisible(true);

    // Load ninja animated model for bone trail demo.
    Node* ninjaNode = scene_->CreateChild("Ninja");
    ninjaNode->SetPosition(Vector3(5.0f, 0.0f, 0.0f));
    ninjaNode->SetRotation(Quaternion(0.0f, 180.0f, 0.0f));
    AnimatedModel* ninja = ninjaNode->CreateComponent<AnimatedModel>();
    ninja->SetModel(cache->GetResource<Model>("Models/NinjaSnowWar/Ninja.mdl"));
    ninja->SetMaterial(cache->GetResource<Material>("Materials/NinjaSnowWar/Ninja.xml"));
    ninja->SetCastShadows(true);

    // Create animation controller and play attack animation.
    ninjaAnimCtrl_ = ninjaNode->CreateComponent<AnimationController>();
    ninjaAnimCtrl_->PlayExclusive("Models/NinjaSnowWar/Ninja_Attack3.ani", 0, true, 0.0f);

    // Add ribbon trail to tip of sword.
    Node* swordTip = ninjaNode->GetChild("Joint29", true);
    swordTrail_ = swordTip->CreateComponent<RibbonTrail>();

    // Set sword trail type to bone and set other parameters.
    swordTrail_->SetTrailType(TT_BONE);
    swordTrail_->SetMaterial(cache->GetResource<Material>("Materials/SlashTrail.xml"));
    swordTrail_->SetLifetime(0.22f);
    swordTrail_->SetStartColor(Color(1.0f, 1.0f, 1.0f, 0.75f));
    swordTrail_->SetEndColor(Color(0.2f, 0.5f, 1.0f, 0.0f));
    swordTrail_->SetTailColumn(4);
    swordTrail_->SetUpdateInvisible(true);

    // Add floating text for info.
    Node* boxTextNode1 = scene_->CreateChild("BoxText1");
    boxTextNode1->SetPosition(Vector3(-1.0f, 2.0f, 0.0f));
    Text3D* boxText1 = boxTextNode1->CreateComponent<Text3D>();
    boxText1->SetText(String("Face Camera Trail (4 Column)"));
    boxText1->SetFont(cache->GetResource<Font>("Fonts/BlueHighway.sdf"), 24);

    Node* boxTextNode2 = scene_->CreateChild("BoxText2");
    boxTextNode2->SetPosition(Vector3(-6.0f, 2.0f, 0.0f));
    Text3D* boxText2 = boxTextNode2->CreateComponent<Text3D>();
    boxText2->SetText(String("Face Camera Trail (1 Column)"));
    boxText2->SetFont(cache->GetResource<Font>("Fonts/BlueHighway.sdf"), 24);

    Node* ninjaTextNode2 = scene_->CreateChild("NinjaText");
    ninjaTextNode2->SetPosition(Vector3(4.0f, 2.5f, 0.0f));
    Text3D* ninjaText = ninjaTextNode2->CreateComponent<Text3D>();
    ninjaText->SetText(String("Bone Trail (4 Column)"));
    ninjaText->SetFont(cache->GetResource<Font>("Fonts/BlueHighway.sdf"), 24);

    // Create the camera.
    cameraNode_ = scene_->CreateChild("Camera");
    cameraNode_->CreateComponent<Camera>();
//.........这里部分代码省略.........
开发者ID:JTippetts,项目名称:Urho3D,代码行数:101,代码来源:RibbonTrailDemo.cpp

示例10: CreateScene

void MasterControl::CreateScene()
{
  world_.scene = new Scene(context_);

  //Create octree, use default volume (-1000, -1000, -1000) to (1000,1000,1000)
  {
    world_.scene->CreateComponent<Octree>();
  }
  //Create the physics
  {
    PhysicsWorld * const physicsWorld = world_.scene->CreateComponent<PhysicsWorld>();
    physicsWorld->SetGravity(Vector3::ZERO);
  }

  world_.scene->CreateComponent<DebugRenderer>();

  //Create an invisible plane for mouse raycasting
  world_.voidNode = world_.scene->CreateChild("Void");
  //Location is set in update since the plane moves with the camera.
  world_.voidNode->SetScale(Vector3(1000.0f, 1.0f, 1000.0f));
  StaticModel* planeModel = world_.voidNode->CreateComponent<StaticModel>();
  planeModel->SetModel(cache_->GetResource<Model>("Models/Plane.mdl"));
  planeModel->SetMaterial(cache_->GetResource<Material>("Materials/Terrain.xml"));

  CreateBackground();

  {
    // Create skybox. The Skybox component is used like StaticModel, but it will be always located at the camera, giving the
    // illusion of the box planes being far away. Use just the ordinary Box model and a suitable material, whose shader will
    // generate the necessary 3D texture coordinates for cube mapping
    Node* skyNode = world_.scene->CreateChild("Sky");
    skyNode->SetScale(500.0f); // The scale actually does not matter
    Skybox* skybox = skyNode->CreateComponent<Skybox>();
    skybox->SetModel(cache_->GetResource<Model>("Models/Box.mdl"));
    skybox->SetMaterial(cache_->GetResource<Material>("Materials/Skybox.xml"));
  }

  //Create a directional light to the world. Enable cascaded shadows on it
  {
    Node* lightNode = world_.scene->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.0f, -1.0f, 0.0f));
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);
    light->SetBrightness(1.0f);
    light->SetColor(Color(1.0f, 0.8f, 0.7f));
    light->SetCastShadows(true);
    light->SetShadowBias(BiasParameters(0.00025f, 0.5f));

    //Set cascade splits at 10, 50, 200 world unitys, fade shadows at 80% of maximum shadow distance
    light->SetShadowCascade(CascadeParameters(7.0f, 23.0f, 42.0f, 500.0f, 0.8f));
  }

  //Create a second directional light without shadows
  {
    Node * const lightNode = world_.scene->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.0, 1.0, 0.0));
    Light * const light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);
    light->SetBrightness(0.25);
    light->SetColor(Color(1.0, 1.0, 1.0));
    light->SetCastShadows(true);
    light->SetShadowBias(BiasParameters(0.00025f, 0.5f));
  }

  //Create camera
  world_.camera = new CameraMaster(context_, this);
}
开发者ID:richelbilderbeek,项目名称:travis_qmake_gcc_cpp11_urho3d,代码行数:67,代码来源:mastercontrol.cpp

示例11: Setup

//-------------------
//-------------------
void VaniaDebugEnv::Setup(SharedPtr<Scene> scene, SharedPtr<Node> cameraNode)
{

	scene_ = scene;
	cameraNode_ = cameraNode;

	ResourceCache* cache = GetSubsystem<ResourceCache>();

    // Create scene node & StaticModel component for showing a static plane
    /*Node* planeNode = scene_->CreateChild("Plane");
    planeNode->SetScale(Vector3(100.0f, 1.0f, 100.0f));
    StaticModel* planeObject = planeNode->CreateComponent<StaticModel>();
    planeObject->SetModel(cache->GetResource<Model>("Models/Plane.mdl"));
    planeObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));*/

    // Create a Zone component for ambient lighting & fog control
    Node* zoneNode = scene_->CreateChild("Zone");
    Zone* zone = zoneNode->CreateComponent<Zone>();
    zone->SetBoundingBox(BoundingBox(-1000.0f, 1000.0f));
    zone->SetAmbientColor(Color(0.15f, 0.15f, 0.15f));
    zone->SetFogColor(Color(0.5f, 0.5f, 0.7f));
    zone->SetFogStart(100.0f);
    zone->SetFogEnd(300.0f);

    // Create a directional light to the world. Enable cascaded shadows on it
    Node* lightNode = scene_->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.6f, -1.0f, 0.8f));
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);
    light->SetCastShadows(true);
    light->SetShadowBias(BiasParameters(0.00025f, 0.5f));
    // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
    light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));

    // Create animated models
    /*const unsigned NUM_MODELS = 100;
    const float MODEL_MOVE_SPEED = 2.0f;
    const float MODEL_ROTATE_SPEED = 100.0f;
    const BoundingBox bounds(Vector3(-47.0f, 0.0f, -47.0f), Vector3(47.0f, 0.0f, 47.0f));

    for (unsigned i = 0; i < NUM_MODELS; ++i)
    {
        Node* modelNode = scene_->CreateChild("Jack");
        modelNode->SetPosition(Vector3(Random(90.0f) - 45.0f, 0.0f, Random(90.0f) - 45.0f));
        modelNode->SetRotation(Quaternion(0.0f, Random(360.0f), 0.0f));
        AnimatedModel* modelObject = modelNode->CreateComponent<AnimatedModel>();
        modelObject->SetModel(cache->GetResource<Model>("Models/Jack.mdl"));
        modelObject->SetMaterial(cache->GetResource<Material>("Materials/Jack.xml"));
        modelObject->SetCastShadows(true);

        // Create an AnimationState for a walk animation. Its time position will need to be manually updated to advance the
        // animation, The alternative would be to use an AnimationController component which updates the animation automatically,
        // but we need to update the model's position manually in any case
        Animation* walkAnimation = cache->GetResource<Animation>("Models/Jack_Walk.ani");
        AnimationState* state = modelObject->AddAnimationState(walkAnimation);
        // The state would fail to create (return null) if the animation was not found
        if (state)
        {
            // Enable full blending weight and looping
            state->SetWeight(1.0f);
            state->SetLooped(true);
        }

        // Create our custom Mover component that will move & animate the model during each frame's update
        //Mover* mover = modelNode->CreateComponent<Mover>();
        //mover->SetParameters(MODEL_MOVE_SPEED, MODEL_ROTATE_SPEED, bounds);
    }*/
    {

        Node* floorNode = scene_->CreateChild("Floor");
        floorNode->SetPosition(Vector3(0.0f, -1.0f, 0.0f));
        floorNode->SetScale(Vector3(1000.0f, 1.0f, 1000.0f));
        StaticModel* floorObject = floorNode->CreateComponent<StaticModel>();
        floorObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
        floorObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));
        
        // Make the floor physical by adding RigidBody and CollisionShape components. The RigidBody's default
        // parameters make the object static (zero mass.) Note that a CollisionShape by itself will not participate
        // in the physics simulation
        RigidBody* body = floorNode->CreateComponent<RigidBody>();
        CollisionShape* shape = floorNode->CreateComponent<CollisionShape>();
        body->SetCollisionLayer(32);
        body->SetCollisionMask(63);
        // Set a box shape of size 1 x 1 x 1 for collision. The shape will be scaled with the scene node scale, so the
        // rendering and physics representation sizes should match (the box model is also 1 x 1 x 1.)
        shape->SetBox(Vector3::ONE);
    }

   
    /*Node* stateNode = scene_->CreateChild("state");
    stateNode->SetPosition(positions_[0]);
    StaticModel* stateModel = stateNode->CreateComponent<StaticModel>();
    stateModel->SetModel( cache->GetResource<Model>(String("Models/States/")+states_[0]) );*/

    // Create the camera. Limit far clip distance to match the fog
    //cameraNode_ = scene_->CreateChild("Camera");
    //Camera* camera = cameraNode_->CreateComponent<Camera>();
    //camera->SetFarClip(300.0f);
//.........这里部分代码省略.........
开发者ID:ghidra,项目名称:urho_vania,代码行数:101,代码来源:VaniaDebugEnv.cpp

示例12: CreateScene

void Water::CreateScene()
{
    ResourceCache* cache = GetContext()->m_ResourceCache.get();

    scene_ = new Scene(GetContext());

    // Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
    scene_->CreateComponent<Octree>();

    // Create a Zone component for ambient lighting & fog control
    Node* zoneNode = scene_->CreateChild("Zone");
    Zone* zone = zoneNode->CreateComponent<Zone>();
    zone->SetBoundingBox(BoundingBox(-1000.0f, 1000.0f));
    zone->SetAmbientColor(Color(0.15f, 0.15f, 0.15f));
    zone->SetFogColor(Color(1.0f, 1.0f, 1.0f));
    zone->SetFogStart(500.0f);
    zone->SetFogEnd(750.0f);

    // Create a directional light to the world. Enable cascaded shadows on it
    Node* lightNode = scene_->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.6f, -1.0f, 0.8f));
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);
    light->SetCastShadows(true);
    light->SetShadowBias(BiasParameters(0.00025f, 0.5f));
    light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));
    light->SetSpecularIntensity(0.5f);
    // Apply slightly overbright lighting to match the skybox
    light->SetColor(Color(1.2f, 1.2f, 1.2f));

    // Create skybox. The Skybox component is used like StaticModel, but it will be always located at the camera, giving the
    // illusion of the box planes being far away. Use just the ordinary Box model and a suitable material, whose shader will
    // generate the necessary 3D texture coordinates for cube mapping
    Node* skyNode = scene_->CreateChild("Sky");
    skyNode->SetScale(500.0f); // The scale actually does not matter
    Skybox* skybox = skyNode->CreateComponent<Skybox>();
    skybox->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
    skybox->SetMaterial(cache->GetResource<Material>("Materials/Skybox.xml"));

    // Create heightmap terrain
    Node* terrainNode = scene_->CreateChild("Terrain");
    terrainNode->SetPosition(Vector3(0.0f, 0.0f, 0.0f));
    Terrain* terrain = terrainNode->CreateComponent<Terrain>();
    terrain->SetPatchSize(64);
    terrain->SetSpacing(Vector3(2.0f, 0.5f, 2.0f)); // Spacing between vertices and vertical resolution of the height map
    terrain->SetSmoothing(true);
    terrain->SetHeightMap(cache->GetResource<Image>("Textures/HeightMap.png"));
    terrain->SetMaterial(cache->GetResource<Material>("Materials/Terrain.xml"));
    // The terrain consists of large triangles, which fits well for occlusion rendering, as a hill can occlude all
    // terrain patches and other objects behind it
    terrain->SetOccluder(true);

    // Create 1000 boxes in the terrain. Always face outward along the terrain normal
    unsigned NUM_OBJECTS = 1000;
    for (unsigned i = 0; i < NUM_OBJECTS; ++i)
    {
        Node* objectNode = scene_->CreateChild("Box");
        Vector3 position(Random(2000.0f) - 1000.0f, 0.0f, Random(2000.0f) - 1000.0f);
        position.y_ = terrain->GetHeight(position) + 2.25f;
        objectNode->SetPosition(position);
        // Create a rotation quaternion from up vector to terrain normal
        objectNode->SetRotation(Quaternion(Vector3(0.0f, 1.0f, 0.0f), terrain->GetNormal(position)));
        objectNode->SetScale(5.0f);
        StaticModel* object = objectNode->CreateComponent<StaticModel>();
        object->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
        object->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
        object->SetCastShadows(true);
    }
    Node* shipNode = scene_->CreateChild("Ship");
    shipNode->SetPosition(Vector3(0.0f, 4.6f, 0.0f));
    //shipNode->SetRotation(Quaternion(0.0f, Random(360.0f), 0.0f));
    shipNode->SetScale(0.5f + Random(2.0f));
    StaticModel* shipObject = shipNode->CreateComponent<StaticModel>();
    shipObject->SetModel(cache->GetResource<Model>("Models/ship04.mdl"));
    shipObject->SetMaterial(0,cache->GetResource<Material>("Materials/ship04_Material0.xml"));
    shipObject->SetMaterial(1,cache->GetResource<Material>("Materials/ship04_Material1.xml"));
    shipObject->SetMaterial(2,cache->GetResource<Material>("Materials/ship04_Material2.xml"));
    shipObject->SetCastShadows(true);

    // Create a water plane object that is as large as the terrain
    waterNode_ = scene_->CreateChild("Water");
    waterNode_->SetScale(Vector3(2048.0f, 1.0f, 2048.0f));
    waterNode_->SetPosition(Vector3(0.0f, 5.0f, 0.0f));
    StaticModel* water = waterNode_->CreateComponent<StaticModel>();
    water->SetModel(cache->GetResource<Model>("Models/Plane.mdl"));
    water->SetMaterial(cache->GetResource<Material>("Materials/Water.xml"));
    // Set a different viewmask on the water plane to be able to hide it from the reflection camera
    water->SetViewMask(0x80000000);

    // Create the camera. Set far clip to match the fog. Note: now we actually create the camera node outside
    // the scene, because we want it to be unaffected by scene load / save
    cameraNode_ = new Node(GetContext());
    Camera* camera = cameraNode_->CreateComponent<Camera>();
    camera->setFarClipDistance(750.0f);

    // Set an initial position for the camera scene node above the ground
    cameraNode_->SetPosition(Vector3(0.0f, 7.0f, -20.0f));
}
开发者ID:nemerle,项目名称:lutefisk3d,代码行数:98,代码来源:Water.cpp

示例13: bounds


//.........这里部分代码省略.........
        Vector3(3.07175517082f,-0.00999999977648f,2.11033010483f),
        Vector3(1.79783010483f,0.0185000002384f,0.926185011864f),
        Vector3(2.24017524719f,-0.00619999971241f,0.882490038872f),
        Vector3(2.32092523575f,-0.0052499989979f,1.23307991028f),
        Vector3(2.81634521484f,-0.00429999921471f,1.25435996056f)
    };

	scene_ = scene;
	cameraNode_ = cameraNode;

	ResourceCache* cache = GetSubsystem<ResourceCache>();

    // Create scene node & StaticModel component for showing a static plane
    /*Node* planeNode = scene_->CreateChild("Plane");
    planeNode->SetScale(Vector3(100.0f, 1.0f, 100.0f));
    StaticModel* planeObject = planeNode->CreateComponent<StaticModel>();
    planeObject->SetModel(cache->GetResource<Model>("Models/Plane.mdl"));
    planeObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));*/

    // Create a Zone component for ambient lighting & fog control
    Node* zoneNode = scene_->CreateChild("Zone");
    Zone* zone = zoneNode->CreateComponent<Zone>();
    zone->SetBoundingBox(BoundingBox(-1000.0f, 1000.0f));
    zone->SetAmbientColor(Color(0.15f, 0.15f, 0.15f));
    zone->SetFogColor(Color(0.5f, 0.5f, 0.7f));
    zone->SetFogStart(100.0f);
    zone->SetFogEnd(300.0f);

    // Create a directional light to the world. Enable cascaded shadows on it
    Node* lightNode = scene_->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.6f, -1.0f, 0.8f));
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);
    light->SetCastShadows(true);
    light->SetShadowBias(BiasParameters(0.00025f, 0.5f));
    // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
    light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));

    // Create animated models
    /*const unsigned NUM_MODELS = 100;
    const float MODEL_MOVE_SPEED = 2.0f;
    const float MODEL_ROTATE_SPEED = 100.0f;
    const BoundingBox bounds(Vector3(-47.0f, 0.0f, -47.0f), Vector3(47.0f, 0.0f, 47.0f));

    for (unsigned i = 0; i < NUM_MODELS; ++i)
    {
        Node* modelNode = scene_->CreateChild("Jack");
        modelNode->SetPosition(Vector3(Random(90.0f) - 45.0f, 0.0f, Random(90.0f) - 45.0f));
        modelNode->SetRotation(Quaternion(0.0f, Random(360.0f), 0.0f));
        AnimatedModel* modelObject = modelNode->CreateComponent<AnimatedModel>();
        modelObject->SetModel(cache->GetResource<Model>("Models/Jack.mdl"));
        modelObject->SetMaterial(cache->GetResource<Material>("Materials/Jack.xml"));
        modelObject->SetCastShadows(true);

        // Create an AnimationState for a walk animation. Its time position will need to be manually updated to advance the
        // animation, The alternative would be to use an AnimationController component which updates the animation automatically,
        // but we need to update the model's position manually in any case
        Animation* walkAnimation = cache->GetResource<Animation>("Models/Jack_Walk.ani");
        AnimationState* state = modelObject->AddAnimationState(walkAnimation);
        // The state would fail to create (return null) if the animation was not found
        if (state)
        {
            // Enable full blending weight and looping
            state->SetWeight(1.0f);
            state->SetLooped(true);
        }
开发者ID:ghidra,项目名称:urho_vania,代码行数:67,代码来源:Stage2.cpp

示例14: CreateScene

void MasterControl::CreateScene()
{
    world.scene = new Scene(context_);

    world.octree = world.scene->CreateComponent<Octree>();
    physicsWorld_ = world.scene->CreateComponent<PhysicsWorld>();
    physicsWorld_->SetGravity(Vector3::ZERO);
    world.scene->CreateComponent<DebugRenderer>();

    //Create a Zone component for ambient ing & fog control
    Node* zoneNode = world.scene->CreateChild("Zone");
    Zone* zone = zoneNode->CreateComponent<Zone>();
    zone->SetBoundingBox(BoundingBox(Vector3(-100.0f, -50.0f, -100.0f),Vector3(100.0f, 0.0f, 100.0f)));
    zone->SetAmbientColor(Color(0.15f, 0.15f, 0.15f));
    zone->SetFogColor(Color(0.0f, 0.0f, 0.0f));
    zone->SetFogStart(56.8f);
    zone->SetFogEnd(61.8f);

    //Add a directional light to the world. Enable cascaded shadows on it
    Node* lightNode = world.scene->CreateChild("PointLight");
    lightNode->SetPosition(Vector3::UP*5.0);
    lightNode->SetRotation(Quaternion(90.0f, 0.0f, 0.0f));
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);

    light->SetBrightness(1.0f);
    light->SetRange(7.0f);
    light->SetColor(Color(1.0f, 0.9f, 0.95f));
    light->SetCastShadows(false);
    light->SetShadowBias(BiasParameters(0.00025f, 0.5f));
    //Set cascade splits at 10, 50, 200 world unitys, fade shadows at 80% of maximum shadow distance
    light->SetShadowCascade(CascadeParameters(7.0f, 23.0f, 42.0f, 500.0f, 0.8f));

    //Create cursor
    world.cursor.sceneCursor = world.scene->CreateChild("Cursor");
    //world.cursor.sceneCursor->SetPosition(Vector3(0.0f,0.0f,0.0f));
    StaticModel* cursorObject = world.cursor.sceneCursor->CreateComponent<StaticModel>();
    cursorObject->SetModel(cache_->GetResource<Model>("Resources/Models/Hexagon.mdl"));
    cursorObject->SetMaterial(cache_->GetResource<Material>("Resources/Materials/Glow.xml"));
    world.cursor.sceneCursor->SetEnabled(false);

    //Create an invisible plane for mouse raycasting
    world.voidNode = world.scene->CreateChild("Void");
    //Location is set in update since the plane moves with the camera.
    world.voidNode->SetScale(Vector3(1000.0f, 1.0f, 1000.0f));
    StaticModel* planeObject = world.voidNode->CreateComponent<StaticModel>();
    planeObject->SetModel(cache_->GetResource<Model>("Models/Plane.mdl"));
    planeObject->SetMaterial(cache_->GetResource<Material>("Resources/Materials/Invisible.xml"));

    //Create camera
    world.camera = new heXoCam(context_, this);

    //Create arena
    tileMaster_ = new TileMaster(context_, this);
    for (int i = 0; i < 6; i++){
        new ArenaEdge(context_, this, (60.0f * i)+30.0f);
    }

    spawnMaster_ = new SpawnMaster(context_, this);

    player_ = new Player(context_, this);
    apple_ = new Apple(context_, this);
    heart_ = new Heart(context_, this);
}
开发者ID:sabotage3d,项目名称:heXon,代码行数:64,代码来源:mastercontrol.cpp

示例15: CreateScene

void GameApplication::CreateScene()
{
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    
    scene_ = new Scene(context_);
    
    // Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
    // Also create a DebugRenderer component so that we can draw debug geometry
    scene_->CreateComponent<Octree>();
    scene_->CreateComponent<DebugRenderer>();
    
    // Create scene node & StaticModel component for showing a static plane
    Node* planeNode = scene_->CreateChild("Plane");
    //planeNode->SetScale(Vector3(100.0f, 1.0f, 100.0f));
    StaticModel* planeObject = planeNode->CreateComponent<StaticModel>();
    planeObject->SetModel(cache->GetResource<Model>("Models/dikuang.mdl"));

	Material* material = cache->GetResource<Material>("Materials/Water.xml");

    planeObject->SetMaterial(material);	//dikuang
	
    // Create a Zone component for ambient lighting & fog control
    Node* zoneNode = scene_->CreateChild("Zone");
    Zone* zone = zoneNode->CreateComponent<Zone>();
    zone->SetBoundingBox(BoundingBox(-1000.0f, 1000.0f));
    zone->SetAmbientColor(Color(0.3f, 0.3f, 0.3f));
    zone->SetFogColor(Color(0.5f, 0.5f, 0.7f));
    zone->SetFogStart(100.0f);
    zone->SetFogEnd(300.0f);
    
    // Create a directional light to the world. Enable cascaded shadows on it
    Node* lightNode = scene_->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.2f, -0.5f, -0.1f));
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);
//	light->SetSpecularIntensity(3);
	light->SetBrightness(1);
    light->SetCastShadows(true);
    light->SetShadowBias(BiasParameters(0.0001f, 0.5f));
    // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
    light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));

	InitGridModels();
    
    // Create the camera. Limit far clip distance to match the fog
    cameraNode_ = scene_->CreateChild("Camera");
    Camera* camera = cameraNode_->CreateComponent<Camera>();
	//float fZoom = camera->GetFov();
	//camera->SetFov(fZoom);

    camera->SetFarClip(300.0f);
    
    // Set an initial position for the camera scene node above the plane
	cameraNode_->SetPosition(Vector3(0.2318,7.5248,-0.2721));
	yaw_ = 0.10003410;
	pitch_ = 90;

 //   cameraNode_->SetPosition(Vector3(5.0f, 5.0f, -15.0f));
	//pitch_ = 19;
	cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
}
开发者ID:xujingsy,项目名称:Urho3D_xujing,代码行数:61,代码来源:GameApplication.cpp


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