Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

15. January 2016

 

An update for the Xenko (previously Paradox) game engine was released today.  Relatively minor, mostly a fix release.  Details from the release:

Async Debugging

There were some problems debugging async functions due to a problem in Mono.Cecil. We fixed that!

Now, you’ll be able to look at local variables of any async functions. Also, the usage of the namespace in the watch panel is implicit and you can step over any await calls just normally.

Windows 10 Certification

We fixed several small issues preventing Windows 10 apps created with Xenko from being compatible with Store certification.

Now you can submit your awesome apps/games to the Windows Store. Can’t wait to see your creations!

Skybox Compilation

Skybox compilation required a DX11 GPU (compute shaders) preventing some of you from using it.

We moved to a pixel shader version to ensure GameStudio works fine with older GPUs as well.

List of other improvements made

  • Fixed issues with displayed values of rotations changing after validation
  • You are now able to easily edit the 3 components of a vector simultaneously using the lock icon.
  • The convex hull generation is now working along with the new Skeleton Asset.
  • The Connection Router iOS script required to compile shaders on iOS devices has been fixed.
  • Added support for proper resizing in Windows Universal Apps.
  • Added support for OpenGLES devices that do not support packed depth-stencil-formats
  • Added the missing XenkoDefaultFont required by the profiler system.

GameDev News , ,

1. December 2015

 

Paradox the C# based cross platform game engine we featured a few months back, as just announced a major version release and a name change to Xenko.  First about the update:

Xenko

New Features With This Release
Users Can Now Edit Documentation!

We’re so glad to have added this feature that allows users to share information about how to best use Xenko. We know our documentation is not entirely complete yet, so we are really looking forward to hearing and sharing information through the community.

The process for adding to Xenko documentation is real simple. ‘Edit on Github’ in the top right hand corner and you will be able to edit our documentation. If the user-submitted information passes the verification process, we will add it to the documentation.

Edit documentation on GitHub

Automatic Symbols and Source Code Download

Being open source is great, but only if you can find the sources matching the binary version you are using. From now on, Xenko will download the right sources and symbols for an optimal debug and programming experience so you don’t have to worry about doing it yourself.

The process is simple. All you need to do is open Visual Studio options, go to Debugging > General, and check “Enable Source Server Support”:

Enable PDB

 

Next some news on an upcoming December release:

New Animation System

We’ve added a new animation system that allows you to animate any game property throughout the engine. Animating models is great but why limit animation only to the models? With the newest version of the engine, you will be able to animate material color, UI transparency, and generally any property of your game!

Simple, In-Game Profiler

As good as a game engine can get, at some point, you’re always going to be limited by the hardware’s performance. To help with this, we’ve added a built-in profiler so that you will easily be able to identify problems and bottlenecks in your game. Even better, you will be able to turn on the built-in profiler at any point during the process of making your game.

Debug Physics Collision Shapes At Run-Time

Debugging physics is never easy. To streamline this, you will be able to display all the physics collision shapes at any time in your game.

Built-In Scripts

Writing scripts takes time and is not necessarily accessible to everyone. To improve on this, we added some built-in scripts to the engine so that users will be able to do basic operations with ease. Things like animating the camera, displaying physics debug shapes, and adding profiling information can be done in just a few clicks.

 

Finally on the name change:

So, on to the big news! Paradox is officially changing its name to Xenko. We wanted to show our roots a bit more since we are one of the few Japanese-based gaming engines. Xenko was inspired by the Japanese word, Zenko 善光. The Japanese characters signify perfection and light. Sticking with the Xenko theme, we will strive to improve your experience with the Xenko engine (ah, feels good to say the new name).

We know this is a big change, and we truly appreciate your patience as we have been honing in on this transition. Please note that support and download access to any previous Paradox releases will end on December, 25th, 2015.

You can read the full release here.

 

Not sure what I think of the new name, but the old one was certainly confusing.  Whenever I posted Paradox related news in the past there would always be a comment or three expecting that it was Paradox Interactive releasing their game engine.  These transitions can often create a fair bit of pain, especially if they rename at the code level too.

GameDev News , ,

24. August 2015

 

In this tutorial in our ongoing Paradox3d Game Engine tutorial series  we are going to look at controlling a Paradox game engine scene programmatically.  This includes accessing entities created in the editor, creating new entities, loading assets and more.  It should give you a better idea of the relationship between the scene and your code.

 

As always there is an HD video available here.

 

Creating a Simple Script

 

As part of this process we are going to be attaching a script to a scene entity programmatically.  First we need that script to be created.  We covered this process back in this tutorial if you need a brush up.  We are going to create an extremely simple script named BackAndForth.cs, which simply moves the entity back and forth along the x-axis in our scene.  Here is the contents of the script:

using System;
using SiliconStudio.Paradox.Engine;

namespace SceneSelect
{
    public class BackAndForth : SyncScript
    {
        private float currentX = 0f;
        private const float MAX_X = 5f;
        bool goRight = false;
        public override void Update()
        {
            if (Game.IsRunning)
            {
                if (goRight)
                {
                    currentX += 0.1f; 
                }
                else
                {
                    currentX -= 0.1f;
                }

                if (Math.Abs(currentX) > MAX_X)
                    goRight = !goRight;

                Entity.Transform.Position.X = currentX;
            }
        }
    }
}

 

If you've gone through the previous tutorials, this script should require no explanation.  We simply needed an example script that we can use later on.  This one merely moves the attached entity back and forth across the X axis until it reaches + or – MAX_X.

 

Now what we want to do is attach this script to the Sphere entity created in the default scene.  This means we are going to need to be able to locate an entity in code, and perhaps more importantly, we need some code to run.  We could create our own custom Game class like we did last tutorial, but this time we are going to do things a bit different.  Instead we are going to create a StartupScript.

 

First we new to create a new empty Entity in our scene to attach the script component to.  I called mine Config:

image


Next we create the Script we are going to attach.  Start with the following extremely simple script, Startup.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SiliconStudio.Paradox.Engine;
using SiliconStudio.Paradox.Rendering;

namespace SceneSelect
{
    public class Startup : StartupScript
    {
        public override void Start()
        {
            base.Start();
        }
    }
}

 

A StartupScript is a type of script that is loaded, as you may guess, on start. Unlike the Sync/AsyncScript classes we used earlier, there is no per frame update callback occurring.  This makes StartupScripts very useful for exactly this type of configuration tasks.

 

Now that we have our script, let’s attach it to our entity:

image

 

Finding an Entity using Code

 

First we are going to look at the process of locating an entity creating in Paradox Studio using code.  The following code will select the Sphere from the default scene using LINQ.

    var sphere = (from entities in this.SceneSystem.SceneInstance
                    where entities.Components.ContainsKey(ModelComponent.Key)
                    select entities).FirstOrDefault();

You can get the currently active scene using SceneSystem.SceneInstance, which contains a simple collection of Entity objects.  We then filter by entities with Components of type ModelComponent.  There are many ways we could have accomplished the same thing.  This query actually returns all entities in the scene that have a ModelComponent attached, which is overkill.  We could also select by the entities Name attribute:

image

Using the code:

    var sphere = (from entities in this.SceneSystem.SceneInstance
                    where entities.Name == "Sphere" select entities).
                                         FirstOrDefault();
    if (sphere == null) return;

 

Attaching a Script Component Programmatically

 

    ScriptComponent scriptComponent = new ScriptComponent();
    scriptComponent.Scripts.Add(new BackAndForth());
    sphere.Components.Add<ScriptComponent>(ScriptComponent.Key, scriptComponent);

 

Now that we have a reference to our sphere Entity, adding a new component is pretty simple.  Remember that the ScriptComponent is a collection of Script objects.  Simply Add() an instance of our newly created BackAndForth script.  Finally attach a ScriptComponent to our Sphere’s Components collection. 

 

When we run this code we will see:

BackAndForth

 

Creating a new Entity

 

We can also create another entity programmatically.

    Entity entity = new Entity(position: new SiliconStudio.Core.Mathematics.
                    Vector3(0, 0, 1), name: "MyEntity");
    var model = (SiliconStudio.Paradox.Rendering.Model)Asset.Get(typeof(
                SiliconStudio.Paradox.Rendering.Model), "Sphere");
    ModelComponent modelComponent = new ModelComponent(model);
    entity.Add<ModelComponent>(ModelComponent.Key, modelComponent);

 

Here we create a new entity with the name “MyEntity” and set it’s location to (0,0,1).  Next we get a reference to the ProceduralModel created in Paradox Studio, with a call to Asset.Get() specifying the type and URL ( you can see the Url value by mouse overing the asset in the Asset Viewer panel in Studio).  Now we create a new ModelComponent using this Model.  (Keep in mind, changes to it the Model will affect all instances, as I will show momentarily).  Finally we add the ModelComponent to the entity.

Finally we add our newly created entity to the scene using:

    SceneSystem.SceneInstance.Scene.AddChild(entity);

Now when we run the code:

BackAndForth2

 

As I mentioned earlier, changes to the Model will affect all instances.  For example, let’s say we create a new Material in the editor and apply it to the model.

image

Now the code:

    Entity entity = new Entity(position: new SiliconStudio.Core.Mathematics.
                    Vector3(0, 0, 1), name: "MyEntity");
    var model = (SiliconStudio.Paradox.Rendering.Model)Asset.Get(typeof(
                SiliconStudio.Paradox.Rendering.Model), "Sphere");
    var material = Asset.Load<Material>("MyMaterial");
    model.Materials.Clear();
    model.Materials.Add(new MaterialInstance(material));
    ModelComponent modelComponent = new ModelComponent(model);
    entity.Add<ModelComponent>(ModelComponent.Key, modelComponent);

And the (non-animated) result:

image

As you can see, the material on all of the Spheres has been replaced.  If you do not want this behaviour, you will have to create a new Model, either in Studio or programmatically.

 

New Entity using Clone

 

We could have also created our entity using the Clone() method of our existing Entity.

    var anotherSphere = sphere.Clone();
    sphere.Transform.Position.Z = 1f;
    SceneSystem.SceneInstance.Scene.AddChild(anotherSphere);

Keep in mind, the close will get all of the components of the cloned Entity, so if we clone after we add the ScriptComponent, it will also have the script attached.

 

 

Our complete source example:

using System.Linq;
using SiliconStudio.Paradox.Engine;
using SiliconStudio.Paradox.Rendering;

namespace SceneSelect
{
    public class Startup : StartupScript
    {
        public override void Start()
        {
            base.Start();

            var sphere = (from entities in this.SceneSystem.SceneInstance
                         where entities.Components.ContainsKey(ModelComponent.
                                                               Key)
                         select entities).FirstOrDefault();
            //var sphere = (from entities in this.scenesystem.sceneinstance
            //              where entities.name == "sphere" select entities).
                                                 firstordefault();
            //if (sphere == null) return;

            ScriptComponent scriptComponent = new ScriptComponent();
            scriptComponent.Scripts.Add(new BackAndForth());
            sphere.Components.Add<ScriptComponent>(ScriptComponent.Key, 
                                                   scriptComponent);


            Entity entity = new Entity(position: new SiliconStudio.Core.
                            Mathematics.Vector3(0, 0, 1), name: "MyEntity");
            var model = (SiliconStudio.Paradox.Rendering.Model)Asset.Get(typeof(
                        SiliconStudio.Paradox.Rendering.Model), "Sphere");
            var material = Asset.Load<Material>("MyMaterial");
            model.Materials.Clear();
            model.Materials.Add(new MaterialInstance(material));
            ModelComponent modelComponent = new ModelComponent(model);
            entity.Add<ModelComponent>(ModelComponent.Key, modelComponent);

            SceneSystem.SceneInstance.Scene.AddChild(entity);

            var anotherSphere = sphere.Clone();
            sphere.Transform.Position.Z = 1f;
            SceneSystem.SceneInstance.Scene.AddChild(anotherSphere);
        }
    }
}

And, running:

BackAndForth3

 

The Video

 

Programming , , ,

14. August 2015

 

In this part of the ongoing Paradox3D Game Engine tutorial series we are going to accomplish two tasks.  First we are going to show how to set the resolution of our game in Paradox Studio.  We will then look at an example of extending Game and implementing the same thing using code.  This will be a fairly short tutorial, but needed, as the process isn’t entirely intuitive.

 

As always, there is an HD video version of this tutorial available here.

 

Setting the Screen Resolution using Paradox Studio

 

The process of setting the resolution is incredibly easy, but certainly not intuitive.  To set the resolution, in Solution Explorer within Paradox Studio, right click the game package ( FullScreen in my case ), then select Package properties.

image

 

Then in the Property grid, set the width and height desired:

image 

And done.

 

Extending Game

 

Create a new class in your .Game project, I’m calling mine MyGame.cs.  Now enter the following code:

using SiliconStudio.Paradox.Engine;

namespace FullScreen
{
    public class MyGame : Game
    {
        protected override void Initialize()
        {
            // Set the window size to 720x480
            GraphicsDeviceManager.PreferredBackBufferWidth = 720;
            GraphicsDeviceManager.PreferredBackBufferHeight = 480;

            base.Initialize();
        }
    }
}

This code simply sets the resolution by using GraphicsDeviceManager to set the PreferredBackBufferWidth and Height to our desired dimensions.  Initialize is called after your applications constructor, but before a window is displayed, making it an ideal location to set the resolution.  Why preferred?  Well because frankly outside of desktop platforms (mobile), you often don’t have control over the window size.  Like the previous tutorial, it’s very important to remember to make your class public.

 

Please note, Initialize() is just one point in the application lifecycle, there are several other protected methods you can override to gain much more precise control over the lifecycle of your game:

image

 

Now that we have created our own custom game class, we now need to update the entry point for each target platform to create an instance of our new class instead of using Game.

image

 

Edit the ___App.cs file accordingly:

 

using SiliconStudio.Paradox.Engine;

namespace FullScreen
{
    class FullScreenApp
    {
        static void Main(string[] args)
        {
            using (var game = new FullScreen.MyGame())
            {
                game.Run();
            }
        }
    }
}

 

 

The Video

Programming , ,

14. August 2015

 

In this part of the Paradox3D game engine tutorial series we are now going to look at how you actually program your games.  In the end you will discover that it’s actually a pretty straightforward process, but could certainly use some streamlining.  ( The option to generate a .cs file when you add a script component would be a nice little time saver… ).  Minor quibble however… let’s jump in.  The code in this particular example was written to target version 1.2.  If the code doesn’t work any more, be sure to check the comments for suggestions.  If there is no fix there, please email me.

 

As always, there is an HD video of this process available here or embedded below.

 

Creating a new Script

Scripting in Paradox is a two step process.  First you create the script, generally in Visual Studio.  Then you attach the script to an entity, either programmatically, or using the editor.  We are going to look at the process of creating the script first.

 

In Visual Studio, inside your .Game folder, create a new cs file.

image

 

I personally called mine ExampleScript, outside of standard variable naming requirements, the name really doesn't matter.  We now have two options as to how we want to implement our script.  It can either be a SyncScript or AsyncScript, we will show an example of both. 

A SyncScript as the name suggests, runs Syncronously.  That is, the game loop iterates over and over and we frame our script’s update function is called and we handle the logic of our script.  An AsyncScript on the other hand, takes advantage of C# 5’s async functionality, and allows your script to run in parallel.  This could lead to performance gains on multi processor machines.  Which works best is ultimately up to you and your game’s design.

SyncScript example:

using System;
using SiliconStudio.Paradox.Engine;

namespace ScriptingDemo
{
    public class ExampleScriptSync : SyncScript
    {
        public override void Update()
        {

            if (Game.IsRunning)
            {
                if (Input.IsKeyDown(SiliconStudio.Paradox.Input.Keys.Left))
                {
                    this.Entity.Transform.Position.X -= 0.1f;
                }
                if (Input.IsKeyDown(SiliconStudio.Paradox.Input.Keys.Right))
                {
                    this.Entity.Transform.Position.X += 0.1f;
                }
            }
        }
    }
}

 

AsyncScript example:

using System;
using System.Threading.Tasks;
using SiliconStudio.Paradox.Engine;

namespace ScriptingDemo
{
    public class ExampleScriptAsync : AsyncScript
    {
        public override async Task Execute()
        {
            while (Game.IsRunning)
            {
                await Script.NextFrame();

                if (Input.IsKeyDown(SiliconStudio.Paradox.Input.Keys.Left))
                {
                    this.Entity.Transform.Position.X -= 0.1f;
                }
                if (Input.IsKeyDown(SiliconStudio.Paradox.Input.Keys.Right))
                {
                    this.Entity.Transform.Position.X += 0.1f;
                }
            }
        }
    }
}

 

This particular tutorial isn’t actually about how you program Paradox, so don’t pay too much attention to how the code works, that will all be explained later.  Just be aware that both Async and Sync scripts do the same thing, transform the Entity they are attached to along the X axis when the Left or Right arrow keys are pressed.  The important take away points are that your script derive from one of the two mentioned classes, that your script has access to the entity it is attached to and actually has access to the entire game engine, allowing you to do just about anything.  Update() is not the only callback function implemented, there is also one for Start and Cancel available, if you need to do startup or cleanup functionality.

 

One final extremely important note…  MAKE SURE YOUR CLASS IS PUBLIC!   Otherwise it will not be available in the editor!  Sorry, I’ll stop yelling now.

 

Implement one of the two scripts ( or both, it doesn’t matter ), then compile your project to make sure you haven't made any errors.  We are now ready to attach the script to an entity in Paradox Editor.

 

Attaching a Script using Paradox Studio

 

Now that we have a script, we can attach it to one or more entities in our scene.  In an ideal world, Paradox Studio should notice the changes you made, and pop up a dialog telling you so.  Unfortunately, at least right now, it rarely succeeds with the first script you create.  In this case, simple do a quick restart of Studio using the menu, File->Reload project.

image

 

Now in the 3D view, select the entity you want to attach a script to.  If you are unfamiliar with operating Paradox Studio, please refer to this tutorial.  I am going to attach this script to the sphere model created in a default scene:

image

 

Now go to the Property Grid and press the Add Component button and select Scripts from the drop down.

image

 

Now scroll down to the Scripts component that should have been added, Click the green plus sign next to Script, then in the drop down for Item 0, select your script.

image

 

Run your game using the toolbar:

image

 

You can now control the sphere using the arrow keys:

AttachingArrowKeyScript

 

A couple cool things here.  First this shows that the same script can be used to control multiple entities.  We could attach the exact same script to our camera, the light, another model, etc… and it would just work.  Second, you can attach multiple scripts to the same entity.

 

What we didn’t cover

We covered the basics of attach a script to an Entity in Paradox, and I think it should give you a good idea of how you add logic to entities in your game.  There are two things we didn’t cover (yet), that I think it should be important to be aware of before we move on.

 

First, in addition to the SyncScript and AsyncScript classes, there is a third scripting type, StartupScript.  This is a type of script that is called when your object is created.  The major difference is it is not called each frame or async, like the other two scripts.

 

Second is the game class.  If you look in your generated project, in each platform you will see an entry point, like this one for the Windows platform:

image

 

Here are the contents of that script:

using SiliconStudio.Paradox.Engine;

namespace ScriptingDemo
{
    class ScriptingDemoApp
    {
        static void Main(string[] args)
        {
            using (var game = new Game())
            {
                game.Run();
            }
        }
    }
}

 

As you can see, the heart of this script is to create an instance of Game, then call Run().  If you require more control over the lifecycle of your game, you can easily derive your own game from the Game class and create an instance of it instead.  We will see a simple example of this process in the next tutorial.

 

Don’t worry if you are a bit lost on the specifics of the code, I had no intention of explaining how the code actually works, those posts will be coming in the near future.  You should however have a good idea now of how you create a script and attach it to your game entities.

 

The Video

Programming , ,

Month List

Popular Comments