Saturday 4 July 2015

It Broke, I Fix

It's been a while since I've tried working with CryEngine, so I tried setting up a project with CryMono again. And lo and behold, errors everywhere.

As you might know, the CryMono project has been abandoned by its developers. This has left the head branch unusable with the Free SDK (v3.5.8).

Luckily there is a way to get the good old trusty CryMono back that I used in the original CryMono installation tutorial. This time around, I'll even use VS2013.

So without futher ado, here's what you'll need:
  • CryEngine FreeSDK (v.3.5.8)
  • Visual Studio 2012 or 2013
  • GitBash

Getting the right branch

Since the main (master) branch of CryMono no longer seems to work, we have to revert to an older branch. Preferably one that we know works. For this I used the branch that was current at the time of the original tutorial.

Navigate to where you have your CryEngine installed. For brevity, we'll call this <CryEngineFolder>. From here navigate to the code folder and right click, selecting Git Bash here from the menu. 


First we'll clone the entire CryMono repository, this will download the files of the (broken) master branch.

In the Git Bash console write:
"git clone https://github.com/inkdev/crymono --recursive".
NOTE: The double hyphen recursive ensures that all required repositories referenced in CryMono are also downloaded.

Let the cloning process run it's course. Do not attempt to shut down the process, as it WILL corrupt the downloaded files, making you have to start over.

Once the process has been completed, close the console and navigate to the newly created CryMono folder (<CryEngineFolder>\Code\CryMono) and open another Git Bash console here.

In the Git Bash console write:
"git checkout 89c31cb".
 89c31cb is the identifier for the branch (commit). You can find other identifiers here. There is no guarantee that other branches will work right off the bat. If you don't want to spend hours hunting possible issues, just use the command provided.

Let the program run it's course et voila, you can now follow the steps outlined in the other tutorial (from Compiling CryMono onwards).

Compiling CryMono with VS2013

Compiling CryMono with VS2013 requires one small edit. 

The project properties have the platform toolset set to 100, whilst VS2013 only has 120. This can be changed in the CryMono project properties:



Friday 12 September 2014

Be wary of unannounced CryMono updates!

It's been a while since I roared my ugly head.

Thanks to a commenter on the Getting Crymono to Work Tutorial page, I noticed that the CryMono library had been updated since I had made the tutorial. It may very well be that some of the issues mentioned in the article (namely about the missing virtual function(s)) have been fixed.

This means if you're running into errors with the tutorial (mostly dealing with changing the crymono code), you can try skipping the editing step and use the standard CryMono library.

No promises though and I can't check whether this is correct as I haven't worked with CryMono or the CryEngine in a while (laptop died some time ago).

Happy programming!

Friday 18 April 2014

Getting CryMono to work, a tutorial

Update: The steps outlined in this tutorial may not apply to all versions of CryMono. In order to make sure you use the right version, see this post. 

Righto, not technically Friday here anymore. But as long as I'm awake, it's still Friday to me.

This tutorial assumes that you have Visual Studio 2012 installed and have working knowledge of changing properties and basic programming in C++ and C#.

Setting up the latest CryEngine (3.5.8):

First of all, head over to www.crydev.net and download the latest version of the CryEngine if you haven't already done so. Extract the files from a zip to a dedicated folder, this'll be referred to as <CryEngineFolder> during pathing instructions in this tutorial.

Navigate to <CryEngineFolder>\Code\Solutions and open GameCodeOnly.sln. Visual Studio will prompt you to update some of the solutions to the current version (2012), do this and then make the following changes:
  • Right-click CryGameSDK and mark at is Startup Project
  • Go to the CryGameSDK  properties, Debugging and select the Command field. Edit it by browsing to: <CryEngineFolder>\Bin32\Editor.exe. This will launch the 32 bit editor whenever you choose to debug the project.
  • If you're using Visual Studio Express, you'll need to delete GameDll.rc (found in the solution explorer under CryGameSDK\res).
Build the solution and run the debugger. If everything works without problems, then well done, you've just compiled your first CryGame. If not, leave a comment with whatever issue you're having (and make sure you've done all of the above).

NOTE: You'll likely (nearly 100% certain) encounter a CryAssert Failure when launching the newly compiled editor. This is not a fatal error and can be ignored for now, but should be fixed before final release (details on this can be found on CryDev)



Downloading CryMono

The most current version of CryMono (not this is not a final 1.0 release) can be found at https://github.com/inkdev/CryMono. You can install/download CryMono either by using Git (which can be found at: http://msysgit.github.io/) or by downloading the sources manually.

Using GitBash:

Navigate to <CryEngineFolder>\Code and right-click in order to select GitBash. In the console enter: "git clone https://github.com/inkdev/CryMono –recursive", note the double hyphen before 'recursive'. Let the program run to the end, this might take a while. Closing the program prematurely can and will lead to errors later on.

Manually:

Go to the CryMono repository and download the project as ZIP file. Note that this won't include the contents of the 'mono' of the repository as that actually links to another repository. In order to get those contents, go to the mono repository and download that project as a ZIP file as well.

Open the CryMono repository ZIP file and extract the contents of CryMono-master (the folder inside the ZIP file) to <CryEngineFolder>\Code\CryMono.

Next open the mono repository ZIP file and extract the contents of mono-master to <CryEngineFolder>\Code\CryMono\mono.

Compiling CryMono:

In order to use CryMono with the CryEngine, you'll need to compile it to a DLL file so that the engine can load its functionality. In order to do this, we'll need to edit a few things.

Go to <CryEngineFolder>\Code\CryMono\Solutions and open CryMono.sln. Update any files to VS2012 as needed. Then in the solution explorer navigate to: CryCommon\Interfaces_h\ISystem.h.

In this file, look for the SSystemGlobalEnvironment struct. At the end of this struct add: 
"struct IMonoScriptSystem* pMonoScriptSystem;"

According to the book I mentioned in an earlier post, this should be enough to compile CryMono. However, doing so now (with the current version being v0.7) will lead to abstract class instantiation errors. In order to fix this you must add a function to CMonoActor class:

In the solution explorer navigate to CryMono\ActorSystem\Actor.h. Then, in CMonoActor class, go to line 133 and add: 
"virtual void OnReused(IEntity *, SEntitySpawnParams &) override {}"


Now you can build CryMono. The project is set up so that the DLL will appear in the Bin32 directory of your CryEngine structure.

Integrating CryMono with CryEngine:

Now comes the fun part, integrating CryMono into CryEngine and making the whole thing work.

Go back to (or re-open) GameCodeOnly.sln. In the CryGameSDK properties, go to C/C++, General and edit the "Additional Include Directories" field. Add a new line and enter: ..\..\CryMono\MonoDll\Headers. Save the properties and close the window.

In order for CryMono to start with the game, you'll eed to change the game startup files.

First, open up GameStartup.h, found in the solution explorer under CryGameSDK\Startup Files\. At the end of the CGameStartup class, add: 
"static HMODULE m_cryMonoDll;"



Now open up GameStartup.cpp. After the include block, add: 
"#include <CryMonoInitializationHelpers.h>"

Also in this file, just before the CGameStartup class function definitions add the following:
  • "IMonoScriptSystem *IMonoScriptSystem::g_pThis = nullptr;"
  • "HMODULE CGameStartup::m_cryMonoDll = 0;"
In order for the CryMono DLL to unload correctly when the game ends, go to the CGameStartup destructor and add the following:

"if(m_cryMonoDll)
{
    CryFreeLibrary(m_CryMonoDll);
    m_cryMonoDll = 0;
}"



Now navigate to the Init function of CGameStartup and add the following before  REGISTER_COMMAND("g_loadMod", ...):

"m_cryMonoDll = InitCryMono(gEnv->pSystem, m_pFramework);"

Congratulations, the CryMono framework will now load at the beginning of the game and unload at the end. It won't load FlowNodes yet though, which requires some extra coding. For this, open up Game.cpp, which can be found in CryGameSDK\Game Files\.

In this file, after the include block, add:
"#include <IMonoScriptSystem.h>"

Now find the CGame::RegisterGameFlowNodes function and add the following to it:
"GetMonoScriptSystem()->RegisterFlownodes();"



You're now set to load custom made FlowNodes and use CryMono to its full extent. Build the project and test the editor. If you have any issues, leave a comment or head over to CryDev.

NOTE: You might be welcomed by a CryMono exception, which states there's no scripts for it to compile in the GameSDK\Scripts\ folder. You can add a dummy .cs file to this folder and the error will go away.

Resources:


Tuesday 15 April 2014

Finally Bug Free

I might have jynxed myself there.

So after fixing the compiling issues I described in my previous post I ran into a bunch of other nasties. Some of which were gamebreaking (access violations, yuck. They sound like the progamming equivalent of rape), some of which weren't.

But now they are all fixed and I can finally get on with the book and actually learn a thing or two about programming in and with CryEngine 3 (Yes I said in, Flowgraphs still are programming in my book).

Given the amount of time it took me to get CryMono to work properly, I will make a tutorial on implementing it with the current version of CryEngine 3 (3.5.8). That will probably be done by Friday (no promises though).

Saturday 12 April 2014

CryEngine: Woooooooo; CryMono Documentation: Not so Woooooo

I have deserted my engine programming efforts and switched to the almighty CryEngine. 

I'm still very much in it for the programming though. So as a good newbie, I went around the internet looking for tutorials and other useful learning resources. In doing so I stumbled over a book made by an old friend of mine (if you're reading this, Carto, hellooooo): 

So yeah, the book is called: CRYENGINE Game Programming  with C++, C# and Lua



I've read chapter 1 and it looks good to me.

Chapter 1, I hear you ask? Well that's because CryMono, the scripting module the book uses with CryEngine, has been a royal pain in the butt to implement. It's taken me over a week to find several (rather miniscule) errors that prevented CryMono from compiling.

And it's not just been me. I've seen posts describing similar issues pop up multiple times on the CryDev forums, usually with some mentioning of the book. Some of the issues were due to the tech itself, however some issues were due to missing instructions in the book.

They're small instructions and easy to fix if you know where to look. But if you're a newbie programmer and haven't seen a linker error in your entire life, you'll be having to forage the internet's massive information repository.

Luckily, CryDev member ivanhawkes has listed the missing instructions in his topic.

So yeah, lot's of effort for what you'd think would all be explained well in the book. Which is a shame.

I might make a post just for the integration of CryMono into a project which will draw from the book and the findings from CryDev. Which should make for some easier reading and implementation.

Tuesday 14 January 2014

It's Alive

After a number of failed attempts at making a DevBlog for a bunch of indie projects I started (but never finished), I decided to make on for my own little dabbles in C++ and OpenGL.

So what can you expect to see here?


Essentially, how my program is evolving, update by update (update's a bit of a big word for the small amount of work I get done, but it fits).

My OpenGL test program is based off of the the following tutorials, mixed together to fit my personal preferences:
I will make a post soon, explaining the current status of my test program, what I use and my experiences thus far.

Who am I again?

I am a student of Mathematics and Physics, with a keen interest in game development (at first I tried my hand at 3D art and now I dabble in C++ mostly).

One day, I hope to be able to use my own engine to make a little game ad publish it. That's a nice goal to work towards isn't it?