Random Planet Generator

So me and my collague found this brilliant blog post; Procedural Planet Generation by Andy Gainey a few days ago. Even though it looks beautiful and stuff, it’s written in javascript which isn’t a popular development platform here, so we decided to convert it to C# & Unity3D.

We’ve only done the icosahedron subdivision part for now, but still working on the rest actively.

 

 

You can find the Unity3D project files below but beware, it’s just a raw translation from Javascript to C# at the moment and looks quite ugly (I mean the coding style). I’ll do the refactoring and beautifying stuff when we’re done with it. That being said, we may not do a 100% conversion either and go on a different way at some point.

Anyway, I hope you guys find it useful, please do notify us about any bugs or issues in the C# version so we can fix it asap. Enjoy!

https://github.com/alprkskn/RandomPlanetGenerator

bTube

Yeap, so I finished my first “One Game a Month” game, bTube, a few days ago.

It’s still far from done and have serious balance issues but still, if you want to try it out;

http://barankahyaoglu.com/ogam/btube/btube.html

Please do let me know what you think!
E-Mail: brnkahyaoglu@gmail.com

 

Banner Saga Caravan Movement

So I’ve been playing Banner Saga for a few days.
I found the gameplay to be rather boring and underwhelming but as a winter person I kept playing just for the winter/snow scenes.
Brilliant art, good writing, great scenes etc.

One of my favorite things for me was the caravan scenes,

Doesn’t that looks BEAUTIFUL?
Yea they put such awesome scenes in between the fights to keep player going and it totally worked on me.

Anyway, so I decided to do that myself in Unity, as I always do. I manage to… recreate it somehow. Sadly programmer art is nowhere close to what you’ve seen above.

 

But it works and that’s satisfying enough for me. It’s just bunch of boxes moving on bezier curve really, nothing complicated.It also has a n-layer background, all infinite, generated as caravan moves etc.
I’m still not that comfortable with Unity but I think the overall structure is rather decent and flexible.

You can also check it out here;
http://barankahyaoglu.com/unity/banner.html

Anyway you can find the project below,Let me know if you have any questions or whatever. ( brnkahyaoglu@gmail.com )
I hope you like it, cheers!

BannerSageTests

Hexagons in Unity – Part 2

OK I decided to write a small post about that part where we create the vertices, UV coordinates etc in the previous post.
I’ll try to make it clear for the people who’re new in 3D stuff.

 

So yeah, we created a hexagon in our previous post, by creating every vertex and triangle by hand, instead of using a pre-build 3D model. For the simplicity, I’ll do a basic version of our hex this time and create only the top face of the hexagon. If you remember the previous post, it had a height, sides and a bottom etc.

Anyway, first have a look at this;

Our hex has a radius of r, this is the distance from the center to any corner. In a standard hex, this is also equals to the edge length. And we have “Half Width”, well it’s the width divided by two really. Nothing fancy.
Remember that we’ll be using center of the hexagon as origin for creating the vertices. So for example, the coordinates for the top corner should be; ( 0, -R ).

UV mapping is a little bit different though. First of all, origin for UV mapping is always bottom left corner, this is fixed and you really can’t change it. Also the width and height of the UV map is scaled down to 1 ( see blue coordinates in the picture ). So again, UV coordinates for the top corner should be; ( 0.5, 1 ).

Let’s have a look at the function;

//top
Vertices[0] =new Vector3(0, 0, Globals.Radius);
UV[0] =new Vector2(0.5f, 1);
//topright
Vertices[1] =new Vector3(Globals.HalfWidth, 0, Globals.Radius /2);
UV[1] =new Vector2(1, 0.75f);
//bottomright
Vertices[2] =new Vector3(Globals.HalfWidth, 0, Globals.Radius /2);
UV[2] =new Vector2(1, 0.25f);
//bottom
Vertices[3] =new Vector3(0, 0, Globals.Radius);
UV[3] =new Vector2(0.5f, 0);
//bottomleft
Vertices[4] =new Vector3(Globals.HalfWidth, 0, Globals.Radius /2);
UV[4] =new Vector2(0, 0.25f);
//topleft
Vertices[5] =new Vector3(Globals.HalfWidth, 0, Globals.Radius /2);
UV[5] =new Vector2(0, 0.75f);

 

Array indexing for these stuff is actually important so be careful with that. Other than that, yea I guess that’s all for this one right?

So now we have bunch of vertices in the space but that doesn’t mean much in a 3D world. To create something visible, we need surfaces and for that we need triangles. Next thing we need to do is to set the triangle information, in other words, let the system know which 3 vertices will be used for a triangle.

 

Now check this out;

 

 

Notice that numbers right by the corners are the index numbers of vertices in the Vertices array. So now we divided our hexagon into 4 triangles and all we have to do is;

2f3″>};

Triangles =new int[]
{
1, 0, 5, 2, 4, 3, 2, 1, 4, 1, 5, 4
};

This array will take integer three by three and generate triangles out of them. So 1,0,5 will be our first triangle, 2,4,3 will be the second etc.
Important thing to note here is that, order of the vertices do matter. In our situation, we ordered them counter clockwise so the surface will be above ( it’s all one sided ). If we had them clockwise, surface would have been below. So if you want to turn it over, you can just change the order of vertices, ie 1,0,5 to 1,5,0.

 

There is one more little thing in the code I posted earlier; Normals.
Normals aren’t always necessary ( depending on the shader ) but it’s good to know really. They are small vectors, showing UP for every single vertex. Yea, Up as in the opposite of down. Normals are used for lighting calculations so pretty damn important as well. For this example though, our normals array will be extremely simple as our shape is simple itself. It’s a simple surface so we can just set all vertex normals to 0,1,0 ( world up in my sample ).

22282a;color:#ffcd22

Normals =new Vector3[]
{
new Vector3(0, 1, 0),
new Vector3(0, 1, 0),
new Vector3(0, 1, 0),
new Vector3(0, 1, 0),
new Vector3(0, 1, 0),
new Vector3(0, 1, 0)
     };

Again the indexes should be in sync with other array indexes, so first vector3 is the normal for vertex 0 etc.

Aaaand that should be it. You can find the whole sample code in the previous post.

Let me know if you have any question, liked the post or wanted to say hi.
I had to close the comments due to increasing spams but you sure can always mail me for anything; brnkahyaoglu@gmail.com
See you later everyone!

Unity

Soooo it has been a while eh?

I know I know, I really should start posting again. It’s not that I’m not doing but I’m terribly busy and doing some oh-not-so-cool stuff these days. ie. master course homeworks -_-

Yeah, boring days, development wise.

Anyway, I had little free time yesterday and decided to check out Unity3D. I actually was looking for a chance to check it out for… a few years now? Finally yesterday was the day!

My first experimental work was on hexagons as usual. I just love hexagons.

I learned a decent amount of stuff about code management and structure of unity. It’s quite fun really, even felt a little bit toooo easy haha.

Even after switching from XNA to Unity, I’m still creating every object vertex by vertex by the way, not sure if it’s a good habit or not but sure feels weird.

Anyway you can check it out here; ( WASD for movement and mouse for camera )

http://www.barankahyaoglu.com/unity/smallshooter.html

Oh yea I’m also LOVING this web player thing. A few seconds of gameplay is sooo much better than thousands of screenshots afterall.

I’ll try to post more and especially about Unity in the future.

Cyaaa!

Shadow Casting

I did this a few weeks ago actually but didn’t have time to write a post about it.

Well I was planing to write a longer post about it but considering it’s not that fast ( not as fast as it should be ) and buggy ( got some corner cases ), I decided to skip the post thingy and just put it here as is ( mainly because I have no intention to fix&improve it further )

Oh and again, it is inspired by Amit and his Shadow Casting post.

 

 

And here it is;

http://barankahyaoglu.com/shadowcasting/

( You might need to refresh the page right away )

 

Tangent Bug

Yet another bug algorithm. Pretty much same as others I posted earlier this week ( bug 0,1 and 2 ) but this one has a ranged sensor so it can detect obstacles from a distance and act properly.

Well at least it’s supposed to, my implementation is horribly broken at the moment, hope my professor won’t see this haha. Oh yea this was our first homework on “Robot Motion Planning and Control” class. It was a great homework as well but I was ( still am ) total newbie to javascript, html5, continues space calculations and bug algorithms of course, I my progress was terribly slow, had to rewrite lots of things again and again.

I think the presentation is fine though, if I can make this work properly ( I hope to keep working on it when I have time ( read never )), it’ll be a nice and probably useful to many people.

 

You can find my report on this homework and implementation details on the page as well, there is also a bugs-eye chart there as well, which I believe is neat.

 

Anyway it’s all here;

http://www.barankahyaoglu.com/robotics/tangent/

 

Oldies – The Corridors

I didn’t even named this one. Solution files are saved as “Maze” though, probably because I used a maze generation algorithm to create the level. ( I believe it was depth first search )

 

Anyway, this was a nice one actually. I really had hopes that I would finish this. I have something for 3rd person action games I guess, I believe they would be extremely fun and really underrated at the moment. Anyway, no way I’m finishing this one so here it is.

 

 

I tested it before uploading though it was rather slow. There are probably some debugging stuff running in the background ( or just my code sucks ) so beware. Also all 3d stuff should be in there as well, let me know if it doesn’t run or missing anything, I’ll check.

 

I’ll just copy paste the rest from previous post;

I must warn you though, code is most likely horrible. It might give you various kinds of disease, start a hurricane, place you right by the Gandhi on map or make you want to gauge your eyes out. All these projects are “as is” and I won’t be able to help you much further with them ( I really don’t remember much ) or fix bugs etc etc.

If you like them though, you’re obliged to let me know and feel happy. I want to feel happy. Don’t be mean. ( you can use the comments below or mail brnkahyaoglu@gmail.com )

Download: Maze.zip (2.97 mb)

Oldies – Fedora

So I was bored and started checking some old stuff today. Eventually I got to the projects folder. Good god, so many unfinished XNA project….

So decided to dump them here. One in a million chance but someone may find them interesting, read and/or use them.

Guess I’ll start with Fedora. It’s a silly name, I know. I started this with the intention of making a Fez ripoff and then got bored and decided to go for something like Bastion. The only point of interest is that boxes fall from sky, floor rises from depths of hell. Looks kinda cool though.

I must warn you though, code is most likely horrible.  It might give you various kinds of disease, start a hurricane, place you right by the Gandhi on map or make you want to gauge your eyes out. All these projects are “as is” and I won’t be able to help you much further with them ( I really don’t remember much ) or fix bugs etc etc.

If you like them though, you’re obliged to let me know and feel happy. I want to feel happy. Don’t be mean. ( you can use the comments below or mail brnkahyaoglu@gmail.com )

Download : Fedora.zip (70.69 kb) 

 

 

Bug Algorithms

First Javascript post ever! Wohoooo… I guess…

Or not. I actually hate it, rather passionately too ( especially after trying typescript ).

http://barankahyaoglu.com/robotics/bug/

Anyway,

I’ve done this little simulation after the first day Robot Motion Control and Planning class. It simulates the behaviours of 3 different bug algorithms ; Bug 0, Bug 1 and Bug 2. Creative names indeed.

 

I’ll just copy paste the description here as well;

All robots ;

have tenticle sensor ( no range ).
have no information other than the relative position of the goal.

Bug 0
It moves towards the goal.
If it runs into an obstacle;
Turns left or right ( this should be fixed but kinda random in my implementation ),
Follows the obstacle until it can freely move towards the goal again.
Rinse repeat.

Bug 1
This one is a little smarter.
Non greedy, rather safe compared to Bug 0 and Bug 2.
It moves towards the goal.
If it runs into an obstacle;
Turns left or right ( this should be fixed but kinda random in my implementation ),
Follows the obstacle until it reaches the starting point again, ( so it travels all around the obstacle )
Keeps track of all points around the obstacle,
Goes back to the one closest to the goal,
Moves towards the goal.
Rinse repeat.

Bug 2
This one is also a bit smart, in a different way though.
It’s greedy.
Finds the shortest path to goal as if there are no obstacles ( going through obstacles ), let’s call it “direct path” It moves towards the goal.
If it runs into an obstacle;
Turns left or right ( this should be fixed but kinda random in my implementation ),
Follows the obstacle until it reaches a point on direct path
Now that it’s back on the direct path again, it just move towards the goal.
Rinse repeat.

 

It’s unstable though, gets confused or just simply break down on some occasions. By no means a full implementation, just the simple barebone  algorithm, vulnerable to every corner case situation. Don’t even bother trying to use the javascript code for whatever, it’s horrible. ( again, first javascript project ever )

 

Oh and I used KineticJS for it. Actually using it for almost everything these days, works brilliant with typescript as well. One of the better libraries out there I guess ( not that I know anything about JS community but still )