Ogre3D and Xenko

Hi there!

I currently have a project in Ogre3D and it’s a little too big to transfer to Xenko and I’m currently having a game server coded in C#, is there any way that Xenko could be used as a backend engine (server-side) for Ogre3D?

Thanks in advance!

Xenko doesn’t currently have out of the box networking or “game server” support. There a couple of wishlist items on the trello board though Network (Client features) and Network (Linux back-end engine mode).

So basically, I am able to create my own networking library (There is SimpleSocket in source btw) and use it? Also is editor only used to create graphical aesthetics of the game and the dll’s from source can be just imported as a reference in any C# project?
Thanks.

Basically if you can code it in .Net and required libraries etc. are supported on your required platform then you can pretty much do what you like.

Game Studio is used for importing/managing assets like models and making scenes etc. As well as configuring certain things like Graphics API used i.e. Direct3D vs Vulkan.

When games are built the build process does some funky stuff like IL re-writing. But It uses MSBuild. So as long as you created solution/project via Game Studio or cobbled together the appropriate .targets included in your project. You would never need to use Game Studio again.

Well this pretty much sums up everything, also: If it was fully server-sided application would it be a good idea to use Xenko.Null instead of Xenko.Direct3D11 for such as entity position checking, action switching?
Thank you! :slight_smile:

I am not sure about your Xenko.Null question. But if I hazard a quess…that it’s similar to using a D3D NULL Device (basically not a real graphics device and can’t do any sort or rendering). And you don’t want to do anything with the GPU then it might be a good choice. But without any experience with it I am reluctant to give you a yes/no answer. Maybe one of the xenko devs could give you a definitive answer.

Glad to help??? :confused:

I’ve tinkered around with Xenko.Null as I only need a console-based application and I was able to spawn the game and continue coding the game server, so far so good.

Thanks!

I was able to achieve what I wished for, by removing Scenes, Audio, Effects, GraphicsDevice and Window, but I will find a way how to approach another way where I could keep Window as my current Console window instead of nopping everything out of my way.

Here is some reference how after tinkering with engine it might look like:

using System;
using System.Threading.Tasks;
using SiliconStudio.Core;
using SiliconStudio.Xenko.Engine;

namespace TestXenkoServer
{
    public class World : Game
    {
        private WorldEntityManager _entityManager;

        public World()
        {
            _entityManager      = new WorldEntityManager(Services);

            Script.Initialize();
            Script.Add(new StartupEngine());
            Script.Add(new MyFirstScript());
            Script.Add(new MySecondScript());

            Console.WriteLine("Initialized World.");
            Console.WriteLine("Trying to add entities..");
            for (var i = 0; i < 10000; ++i)
            {
                var ent = new Entity();
                _entityManager.Add(ent);
            }
            Console.WriteLine("Total entities: {0}", _entityManager.Count);
        }
    }

    public class WorldEntityManager : EntityManager
    {
        public WorldEntityManager(IServiceRegistry registry) : base(registry)
        {
            //
        }
    }

    public class MyFirstScript : AsyncScript
    {
        public long tickCount = 0;
        public override async Task Execute()
        {
            while (Game.IsRunning)
            {
                if (tickCount++ % 5000 == 0)
                    Console.WriteLine("Async Ticks: {0}", tickCount);
                await Script.NextFrame();
            }
        }
    }

    public class MySecondScript : SyncScript
    {
        public long tickCount = 0;
        public override async void Update()
        {
            while (Game.IsRunning)
            {
                if (tickCount++ % 5000 == 0)
                    Console.WriteLine("Sync Ticks: {0}", tickCount);
            }
        }
    }

    public class StartupEngine : StartupScript
    {
        public override void Start()
        {
            Console.WriteLine("Starting StartupEngine");
        }

        public override void Cancel()
        {
            Console.WriteLine("Stopping StartupEngine");
        }
    }
}

The Null target was made so it would be easy for anyone to add a new backend graphic. I believe no-one before you actually tried to run a game using it.

Yeah pretty much I was just tinkering around to see if I can make it work. Would need to create a target for example Xenko.Console in-case you wish to reuse all assets from the client on the server although I noticed 2 problems while doing it; first one is that the CPU usage for an async script that prints to console and goes to next frame is fairly high and overall sits at 15% at idle with no scripts running; second problem is the ram usage for a server application is quite abronormal, imagine running 10,000 players, it would take around 10 mb just to create an entity and when you start adding monsters, npcs, vehicles it goes up to 200,000 entities for whole world to spawn which is around 800mb of ram and it can go up even higher, I am going to check what’s up with that, but I don’t see any relative solution yet.

EDIT: Pretty much the cpu problem turns out to come from the while loop on tick method that I have put for safe measures. Adding a sleep for 10ms or less solved the CPU issue.