Category: Jonathan R.

More Unity: Part 4 (Basic Testing of Components)

This week I have been trying to get a more cohesive project finished because I would like to have something to show off in my final presentation in May. This was difficult and I ran into a few problems but I did get a very basic video recorded of what the skeleton of the project looks like…

In the video I have the Mount Lemmon terrain, a rough representation of the Mount Lemmon road and an object that represents you, the bicycle rider. The camera is a little buggy but that just requires a little more coding which is taking more time than I thought. Other than that, I am rather pleased with what I have done with the terrain and the project as a whole and I am excited to keep you updated till my presentation.

Things left to do before the presentation (hopefully):

  • Implement the bezier curve or something similar so the bicycle will be able to follow the road by its self and not require any outside inputs from the user.
  • Place checkpoints. This sounds very basic but I have put it off till the end because it is time consuming and the other parts of this project are more interesting
  • Get it VR ready.
  • And that’s pretty much all I would have time for.

Talk to you later in the next blog post which might be the last one…

More Unity: Part 3 (Terrain and Roads)

More Unity: Part 3 (Terrain and Roads)

In my last post I talked about Bezier Curves and it was not only hard to describe to you but it has been very hard to implement so I am still working on that. Another important aspect of my game or simulator is too have a road on which the user can ride their bike on and that is what I will be talking about in this post.

Ordinarily this task would be rather straight forward if I was working with flat terrain but as you can see in the feature image, my terrain is a mountain. Also, I am still figuring out how I can accurately place a road onto the terrain and at this point the easiest thing to do would be to just place a road and have it not be accurate. I figured out that I was working with an incorrectly scaled representation of Mount Lemmon. I changed this by making the units in Unity meters and then I was easily able to make a correctly scaled representation. Then I just started placing a road approximately where it would be and it turned out pretty well. Mount Lemmon Road

Obviously there are still things that I can iron out but for now this will do. It is something I can add all the other components to like the checkpoint system. Peace out until next post…

More Unity: Part 2 (Path Following and Bezier Curves)

More Unity: Part 2 (Path Following and Bezier Curves)

Part 1 talked about using triggers as checkpoints for the player. It was a relatively basic concept that I was able to implement after I learned of the useful component of triggers. After I did this I noticed that I would probably want a system in which the bike can turn corners and follow the path without having the user do anything. This would have to be implemented because by the time my project would be finished, there would be no turning mechanism that the user could input.

Making an object follow a path is rather straight forward if you want a very basic path, but my path is going through steep terrain and turns which is quite difficult to make an object follow.

I visited with my onsite advisory, Rodrigo, and  he brought up the ingenious idea of using Bezier Curves for a path following mechanism. Bezier are a bit complicated but I will try to explain.

In short , Bezier Curves are parametric equations that are often used in computer graphics and similar fields. For simplicity, we will be looking at a two point Bezier Curve. If you have two points Po and P1 and you want an object to follow the path between those two points then you step up a basic equation…

\mathbf {B} (t)=\mathbf {P} _{0}+t(\mathbf {P} _{1}-\mathbf {P} _{0})=(1-t)\mathbf {P} _{0}+t\mathbf {P} _{1}{\mbox{ , }}0\leq t\leq 1

This equation tells you the percentage of each point you are at. You can think of t as the percentage at which you have completed the path. If t is at 0.75, then P1 is going to be a greater value than Po so your final position (B(t)) will be closer to P1. This concept can be better visualized below…

A two point Bezier Curve is the simplest form and as you add more points the equation and concept gets more complicated. Below you can see a Bezier Curve with 4 points…

What I am working on is to create Bezier Curves that follow my Mount Lemmon road. Once I do that then all I have to do is to have my bicycle follow the path by making it the point in the path similar to the point in the first picture.

Farewell till next post where I talk about trying to accurately place the Mount Lemmon road onto my terrain!

More Unity: Part 1 (Triggers and Timing)

My last post focused on working with terrain in Unity and figuring out how to import real life height maps to create 3-D models of terrain. Since then I have completed most of my work involving the Mount Lemmon terrain; however, I still have some work to do with finding a way to put a real life copy of the Mount Lemmon road onto my 3-D terrain. As my presentation deadline comes closer, I am trying to focus on the backbone of the project so the road might have to wait.

In this past week I have been working on timing and checkpoints. First I will give a little background so you understand where this comes into place with my project.

The objective of this project is to create a virtual reality game by taking inputs from a bike trainer. The game will render a 3-D scenario such as riding a bicycle on the Mount Lemmon road so the user can be given an experience similar to a real life one. One of the goals of this project is to be able to save times and checkpoints so the user can then train against previous times. Much like how somebody could’ve ran an eight minute mile a month ago but because of constant training can now run a seven minute mile.

Ordinarily, the task of saving previous times would’ve been a walk in the park but because I am using a programming language which I only have a babies grasp on, this task has proved to be challenging. The first step was to find an easy way to time the user every meter. At first, I had no clue as to how to do this but after a couple minutes with my adviser (who is familiar with Unity) I had the problem solved. 3-D objects in Unity can be “triggers” which means that when another object touched them they can trigger something. I used this neat feature in my roll-a-ball scenario to test it out and it worked fabulously. I used a cube as the trigger and told the cube that every time my ball touched it to print out the time in the console. And sure enough, it worked like a charm. To be continued…

I don’t want this blog post to get too long so I will be writing another post shortly which will cover part two of my Unity adventures.




Working with Terrain in Unity

In my previous post, I talked about working with the physics in Unity and making a little “roll-a-ball” game to get familiar with the software and language of C#. Today I will be talking about terrain in Unity, essentially the world that everything happens in for your program.

Working with terrain in Unity has its different levels, you could be a beginner and make some rolling hills or you could be an expert and create a whole landscape with water, grass, and trees. I am just a beginner seeing that I have only been working with Unity for about two weeks or so but I started fooling around with the terrain and all the features that you can use with it. At first, I made a few hills and added a ball into the scenario and rolled it around to see how it interacted with the terrain. I was very pleased how it worked and went on from there.

The next thing I wanted to do was to import real life terrain into Unity so it could be represented as a 3D model. This was much harder than I had initially expected. The concept of importing a grayscale height map into Unity is rather simple but the execution can have its obstacles and weird problems. To import real life terrain, one has to get a grayscale picture of the terrain, convert that picture from jpeg or png to raw using a photo editor (photoshop in my case), and then import the raw into unity and bingo you have a 3D representation of your real life terrain. That is how easy it should be but I had my problems

Firstly, when importing the raw the dimension and resolution of your picture they have to be just perfect for Unity to render it correctly. If the dimensions are skewed or wrong then you will be left 3D representation of this:bad terrain unity

which is not a real-life terrain.

Secondly, which wasn’t a problem with Unity, I didn’t have a photo editor that could save a picture as raw so that took me quite awhile to finally realize that I could just download the trial version of photoshop infinitely so I could have my supply of raw pictures.

So after all that tweaking, I was finally able to import a raw, grayscale height map and get my desired 3D real life terrain.  The terrain that I took was from Mount Lemmon which is important as I progress in my project.MountLemmon Terrain Unity

Yay! Finally I did it



Working with Unity and C#

To be able to make a Virtual Reality environment, I will be working with 3D software and in this case we will be using the widely used Unity 3D software. One of the cool features of Unity and the reason why we are using it is the ability to make Virtual Reality perspectives in it which is exactly what we are aiming to do. So far I have been able to have a little fun working with the physics and the game objects with the software and I have been able to make very simple environments, one of which is where you have a ball and you can move the ball with the arrow keys and pick up little square when you roll over them. Another really cool feature of Unity is the fact that you can program in scripts to the program which allows for freedom for the creator. For example, I had to program the scripts to be able to have the ball move based on keyboard inputs and for the camera to follow the ball as the it moved. As I have gotten deeper and deeper into this project, I am beginning to realize just how many programming languages there are and how each language has its advantages and disadvantages. So far I have had to learn python and java and now I have to learn C# for Unity scripts.

New Project: Virtual Reality and Stationary Trainers

The new project that I will be working on will be creating a virtual reality environment for stationary trainers, in this case, I will be working with a stationary bike trainer. The end goal is to come up with software and a mechanism to have an individual exercise on a stationary bike trainer while wearing a Virtual Reality headset and have that software render a real life environment, so essentially the rider will feel like he or she is actually riding a bike out on a road. This will not only make the whole experience of using a stationary bike trainer better, but it can allow for healthy competition with yourself or others. Our software will be able to save previous times and display those times as ghosts on the current ride. This project will be able to make stationary trainers more than just an exercise machine, it will make it an interactive game with exercise as your controller.

Road Block – Changing to Virtual Reality

Road Block – Changing to Virtual Reality

The last time I posted, I was talking about learning python so I could work with the raspberry pi and that has been going well. Using what I knew from my AP and Post-AP Computer Science class I was able to learn the basics of python rather quickly which is all I need.

Unfortunately as my onsite advisor and I did hours of research into the sensors for our build, we very quickly realized that these sensors that we were looking for were either too expensive or just flat out faulty. So my advisor and I decided to set aside the hydroponic grower idea and venture into the world of Virtual Reality and within a few days we had come up with a project. I’ll be going into depth about this new project in a future post (hopefully by tomorrow). In this new project, we will be working with Virtual Reality machines, stationary trainers, Virtual Reality software and lastly the versatile raspberry pi.

The good news is that everything that I’ve done up until this point is still very useful. The programming for the raspberry pi unit will still be used and the software that I have learned to use such as Solid Works will still come into use in my engineering studies at the UA.

Step 1: Learn Python (Raspberry Pi)

Step 1: Learn Python (Raspberry Pi)

For this project one of the key components is the processing unit and the most popular unit and the one we’ll be using is the raspberry pi. The raspberry pi is a simple processing unit with multiple inputs and outputs making it very versatile and useful when you are venturing out and doing a self-made project. The programming language that the raspberry pi uses is python so if I am going to any work with the pi unit I will have to first learn the ins and outs of python.