L B Posted December 22, 2009 Share Posted December 22, 2009 I'm working on C# and trying to get a skybox to work. I followed the rather old PDF tutorial which seemed rather logical. I have a cube and a skybox behind it (well, ideally). At the moment, I get either the cube or the skybox, depending on which world is initialized last. The 2 following examples are the same, except that in the first one, the Main world gets created before the Sky world, and in the second one, the Sky world gets created before the Main world. Thing being: The last world created is what I get on screen. Examples: 1. With this code, I only get the skybox: public static void Main() { //Initialize FileSystem.AbstractPath = @"C:\Program Files\LE2.3"; Graphics.Initialize(1440, 900); //Main World world = new World(); Camera cam = new Camera(); cam.ClearMode = CameraClearMode.Depth; Buffer lightBuffer = new Buffer(1440, 900, (int)BufferType.Color | (int)BufferType.Depth | (int)BufferType.Normal); Mesh.CreateCube().Position = new Vector3(0, 0, 5); //Sky World background = new World(); Mesh skybox = Mesh.CreateCube(); Camera skycam = new Camera(); skybox.Flip(); skybox.Material = Material.Load("abstract::Sky01.mat"); while (!Keyboard.KeyHit(Key.Escape)) { Timing.Update(); World.Update(Timing.Speed); Buffer.Current = lightBuffer; skycam.Rotation = cam.Rotation; World.Current = background; World.Render(); World.Current = world; World.Render(); Buffer.Current = Buffer.Back; Light.Render(lightBuffer); Graphics.Flip(); } Engine.Terminate(); } 2. With this code, I only get the cube: public static void Main() { //Initialize FileSystem.AbstractPath = @"C:\Program Files\LE2.3"; Graphics.Initialize(1440, 900); //Sky World background = new World(); Mesh skybox = Mesh.CreateCube(); Camera skycam = new Camera(); skybox.Flip(); skybox.Material = Material.Load("abstract::Sky01.mat"); //Main World world = new World(); Camera cam = new Camera(); cam.ClearMode = CameraClearMode.Depth; Buffer lightBuffer = new Buffer(1440, 900, (int)BufferType.Color | (int)BufferType.Depth | (int)BufferType.Normal); Mesh.CreateCube().Position = new Vector3(0, 0, 5); while (!Keyboard.KeyHit(Key.Escape)) { Timing.Update(); World.Update(Timing.Speed); Buffer.Current = lightBuffer; skycam.Rotation = cam.Rotation; World.Current = background; World.Render(); World.Current = world; World.Render(); Buffer.Current = Buffer.Back; Light.Render(lightBuffer); Graphics.Flip(); } Engine.Terminate(); } Now questions on what my problem is: 1. Am I missing something obvious? 2. If not, is there a problem in this code? 3. If not, where do you think the problem is in my wrapper? (I doubt it is) 4. If not, where is the problem in Leadwerks? 5. If not, let's pray together? Thanks a lot in advance. I know you're not used to C#, but it's more than understandable to anyone who can read. Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 22, 2009 Share Posted December 22, 2009 ok, not knowing exactly how you have your wrapper working... but shouldn't it be: skybox.FlipMesh(); instead of: skybox.Flip(); FlipMesh Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
L B Posted December 22, 2009 Author Share Posted December 22, 2009 No it's "Flip", since it's applied to a mesh class. Wrappers don't go "Mesh::FlipMesh()". It's redundant for nothing. Quote Link to comment Share on other sites More sharing options...
Paul Thomas Posted December 22, 2009 Share Posted December 22, 2009 Try skycam.ClearMode = CameraClearMode.Depth; In Framewerk there is also a ClearBuffer(BUFFER_DEPTH) before "World.Current = background" and after the background "World.Render()" See if it helps? I really need to download your headers and try this out. I really like the syntax flow. Quote Link to comment Share on other sites More sharing options...
L B Posted December 22, 2009 Author Share Posted December 22, 2009 There is no point "before "World.Current = background" and after the background "World.Render()"". I tried putting Buffer.Clear(BufferType.Depth) at any point in the render loop: No use. I also set the SkyCam's clear mode to Depth. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.