本文整理汇总了C++中StaticModel::SetOccluder方法的典型用法代码示例。如果您正苦于以下问题:C++ StaticModel::SetOccluder方法的具体用法?C++ StaticModel::SetOccluder怎么用?C++ StaticModel::SetOccluder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StaticModel
的用法示例。
在下文中一共展示了StaticModel::SetOccluder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateScene
void MultipleViewports::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 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 = 240;
for (unsigned i = 0; i < NUM_MUSHROOMS; ++i)
{
Node* mushroomNode = scene_->CreateChild("Mushroom");
mushroomNode->SetPosition(Vector3(Random(90.0f) - 45.0f, 0.0f, Random(90.0f) - 45.0f));
mushroomNode->SetRotation(Quaternion(0.0f, Random(360.0f), 0.0f));
mushroomNode->SetScale(0.5f + Random(2.0f));
StaticModel* mushroomObject = mushroomNode->CreateComponent<StaticModel>();
mushroomObject->SetModel(cache->GetResource<Model>("Models/Mushroom.mdl"));
mushroomObject->SetMaterial(cache->GetResource<Material>("Materials/Mushroom.xml"));
mushroomObject->SetCastShadows(true);
}
// 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 the cameras. Limit far clip distance to match the fog
cameraNode_ = scene_->CreateChild("Camera");
Camera* camera = cameraNode_->CreateComponent<Camera>();
camera->SetFarClip(300.0f);
// Parent the rear camera node to the front camera node and turn it 180 degrees to face backward
// Here, we use the angle-axis constructor for Quaternion instead of the usual Euler angles
rearCameraNode_ = cameraNode_->CreateChild("RearCamera");
rearCameraNode_->Rotate(Quaternion(180.0f, Vector3::UP));
Camera* rearCamera = rearCameraNode_->CreateComponent<Camera>();
rearCamera->SetFarClip(300.0f);
// Because the rear viewport is rather small, disable occlusion culling from it. Use the camera's
// "view override flags" for this. We could also disable eg. shadows or force low material quality
// if we wanted
rearCamera->SetViewOverrideFlags(VO_DISABLE_OCCLUSION);
// Set an initial position for the front camera scene node above the plane
cameraNode_->SetPosition(Vector3(0.0f, 5.0f, 0.0f));
}
示例2: 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));
}
示例3: 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));
}