Jump to content

Recommended Posts

Posted

Just got done implementing Framework into C#. I run this scene at 60 FPS, which is the top I can seem to get in editor or in C#. So performance wise, it's quite good.

 

I'll let you judge for the simplicity:

public static void Main()
{
FileSystem.AbstractPath = @"C:\Program Files\Leadwerks Engine SDK";

Graphics.Initialize(800, 600);

Framework.Initialize();

Scene.Load("abstract::test.sbx");

FreeCamera fc = new FreeCamera(Framework.Layers.Main.Camera); // Custom class

Framework.Effects.Water = true;
Framework.Effects.Parameters.Water.Height = 2.0f;
Framework.Effects.DistanceFog = true;
Framework.Effects.Bloom = true;
Framework.Effects.VolumetricLighting = true;
Framework.Effects.HighDynamicRange = true;
Framework.Effects.Skybox = Material.Load("abstract::FullskiesBlueClear0016_2_L.mat");

while (!Keyboard.KeyHit(Key.Escape))
{
	fc.Update();
	Framework.Update();
	Framework.Render();
	Graphics.Flip();
}

Framework.Terminate();
Engine.Terminate();
}

 

C.jpg

  • Upvote 1
Posted

That looks clean. The only thing that seems backwards is:

 

Framework.Effects.Water = true;

Framework.Effects.Parameters.Water.Height = 2.0f;

 

I'd think it would be:

 

Framework.Effects.Water.Enabled = true;

Framework.Effects.Water.Parameters.Height = 2.0f;

 

 

That seems more logical to me.

 

 

Or really you wouldn't even need Parameters just Water.Height. That's the more .NET way of things :blink:

Posted

Either way, no biggie. By having the .Enabled and such as opposed to just making the effect name true/false it opens up for future expansion of new effects that have parameters or old effects to get parameters at some point and could save you time & consistency issues later. That's all I was thinking. Otherwise I like it.

Posted

Well done Ubu, look's like you got it working nicely, nice screenshot.

 

Hey, i'm trying to use that code in vb.net, but i can't find the FreeCamera in this line.

 

FreeCamera fc = new FreeCamera(Framework.Layers.Main.Camera); // Custom class

 

In vb.net it look's like this

 

Dim fc As New FreeCamera(Framework.Layers.Main.Camera)

 

It say's type FreeCamera is not defined.

 

Any idea what i'm doing wrong ?

 

Thank's.

Win 7 64, LE 2.31, Liquid Cooled I7-960 @ 4.00GHz, 6GB DDR3 Ram @ 1600mhz, BFG GTX295, Sound Blaster X-FI.

Posted

Ok, i missed the comment "//custom class" duh. :lol:

 

How did you define the FreeCamera, in you custom class?

 

Thank's

Win 7 64, LE 2.31, Liquid Cooled I7-960 @ 4.00GHz, 6GB DDR3 Ram @ 1600mhz, BFG GTX295, Sound Blaster X-FI.

Posted

FreeCamera is basically a spectator, only faster to make for me. Here's the code, but I don't guarantee it's clean or efficient. It's just for my personal development use that I made it:

using Leadwerks;

namespace Origins
{
public class FreeCamera
{
	public Camera Camera { get; set; }
	public float SpeedMultiplier { get; set; }
	private Vector3 CameraRotation { get; set; }
	private Vector2 MouseDelta { get; set; }
	private float Move { get; set; }
	private float Strafe { get; set; }

	public FreeCamera(Camera camera)
	{
		this.Camera = camera;
		this.SpeedMultiplier = 10.0f;
		this.CameraRotation = new Vector3();
		this.MouseDelta = new Vector2();
		this.Move = 0.0f;
		this.Strafe = 0.0f;

		Mouse.Center();
		Mouse.Hide();
	}

	public void Update()
	{
		this.MouseDelta.X = Utilities.Curve(Mouse.X - Window.Width / 2, this.MouseDelta.X, 6);
		this.MouseDelta.Y = Utilities.Curve(Mouse.Y - Window.Height / 2, this.MouseDelta.Y, 6);
		Mouse.Center();
		this.CameraRotation.X += this.MouseDelta.Y / 10;
		this.CameraRotation.Y -= this.MouseDelta.X / 10;
		this.Camera.Rotation = this.CameraRotation;
		this.Move = Utilities.Curve(((Keyboard.KeyDown(Key.W) ? 1 : 0) - (Keyboard.KeyDown(Key.S) ? 1 : 0)) * this.SpeedMultiplier, this.Move, 20);
		this.Strafe = Utilities.Curve(((Keyboard.KeyDown(Key.D) ? 1 : 0) - (Keyboard.KeyDown(Key.A) ? 1 : 0)) * this.SpeedMultiplier, this.Strafe, 20);
		this.Camera.Move(new Vector3(this.Strafe / 10 * Timing.Speed, 0, this.Move / 10 * Timing.Speed));
	}
}
}

Posted

Either way, no biggie. By having the .Enabled and such as opposed to just making the effect name true/false it opens up for future expansion of new effects that have parameters or old effects to get parameters at some point and could save you time & consistency issues later. That's all I was thinking. Otherwise I like it.

 

I changed the structure to your second suggestion.

 

Here's an example from the "Scene.Load(string path);" I'm working on:

Framework.Effects.DistanceFog.Enabled = Convert.ToBoolean(int.Parse(child.GetKey("fogmode")));
Framework.Effects.DistanceFog.Color = Vector4.Parse(child.GetKey("fogcolor"));
Framework.Effects.DistanceFog.SetAngles(float.Parse(child.GetKey("fogangle").Split(',')[0]), float.Parse(child.GetKey("fogangle").Split(',')[1]));
Framework.Effects.DistanceFog.SetRanges(float.Parse(child.GetKey("fogrange").Split(',')[0]), float.Parse(child.GetKey("fogrange").Split(',')[1]));

Posted

Thank's for sharing that code Ubu, it's working nice now.

 

If anyone want's the vb.net version, i'll post the code.

Win 7 64, LE 2.31, Liquid Cooled I7-960 @ 4.00GHz, 6GB DDR3 Ram @ 1600mhz, BFG GTX295, Sound Blaster X-FI.

Posted

I changed the structure to your second suggestion.

 

Here's an example from the "Scene.Load(string path);" I'm working on:

Framework.Effects.DistanceFog.Enabled = Convert.ToBoolean(int.Parse(child.GetKey("fogmode")));
Framework.Effects.DistanceFog.Color = Vector4.Parse(child.GetKey("fogcolor"));
Framework.Effects.DistanceFog.SetAngles(float.Parse(child.GetKey("fogangle").Split(',')[0]), float.Parse(child.GetKey("fogangle").Split(',')[1]));
Framework.Effects.DistanceFog.SetRanges(float.Parse(child.GetKey("fogrange").Split(',')[0]), float.Parse(child.GetKey("fogrange").Split(',')[1]));

 

 

Looks clean and crisp. I like it. I really hope this C# version sticks around and has all the functionality of the other versions because I prefer working in .NET.

Posted

Looks clean and crisp. I like it. I really hope this C# version sticks around and has all the functionality of the other versions because I prefer working in .NET.

 

It should. At version 1.3 I'll try to talk with Josh about getting it official.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...