Skip to content

Instantly share code, notes, and snippets.

@Alan-FGR
Created November 10, 2016 12:10
Show Gist options
  • Select an option

  • Save Alan-FGR/b73fe154d5b6e3bc69d426f148e8cf39 to your computer and use it in GitHub Desktop.

Select an option

Save Alan-FGR/b73fe154d5b6e3bc69d426f148e8cf39 to your computer and use it in GitHub Desktop.
Black Screen of Despair in Simple Atomic Example
using AtomicEngine;
public class GameRoot : AppDelegate
{
public override void Start()
{
// We will be needing to load resources.
// All the resources used in this example comes with Urho3D.
// If the engine can't find them, check the ResourcePrefixPath.
var cache = GetSubsystem<ResourceCache>();
// Let's setup a scene to render.
var scene = new Scene();
// Let the scene have an Octree component!
scene.CreateComponent<Octree>();
// Let's add an additional scene component for fun.
scene.CreateComponent<DebugRenderer>();
// Let's put some sky in there.
// Again, if the engine can't find these resources you need to check
// the "ResourcePrefixPath". These files come with Urho3D.
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"));
// Let's put a box in there.
Node box = scene.CreateChild();
box.SetPosition(new Vector3(0,0,5));
StaticModel model = box.CreateComponent<StaticModel>();
model.SetModel(cache.GetResource<Model>("Models/Box.mdl"));
model.SetMaterial(cache.GetResource<Material>("Materials/Stone.xml"));
// We need a camera from which the viewport can render.
Camera camera = scene.CreateChild().CreateComponent<Camera>();
camera.SetFarClip(2000);
// Add one light to the camera Node
//Light light = camera.Node.CreateComponent<Light>();
//light.SetLightType(LightType.LIGHT_POINT);
//light.SetRange(1000);
//light.SetBrightness(2);
//light.SetColor(Color.White);
// Now we setup the viewport. Ofcourse, you can have more than one!
var renderer = AtomicNET.GetSubsystem<Renderer>();
var viewport = new Viewport(scene,camera);
renderer.SetViewport(0,viewport);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment