Wednesday, April 29, 2015

Max Proof: Creating the functionality for the Inventory

  So good news, the design for the inventory is practically done! After having finished the design of the inventory we begun the production phase where we created the functionality for the inventory. Being familiar with Adobe Flash and creating user interface with it, I knew this would be fairly simple, seeing there were similarities between flash and widget blueprints. The only worries I had were well basically getting the item to drag and drop upon pressing a button. So taking from what we know and had to be done we begun creating logic in the event graph of the inventory. To make this fairly easy and dynamic I created a function called Drop Item with the parameters of Class Actor and a array of Image.

DropItem Function
  With these parameters I would be able to plug them into statements that would allow me to spawn an actor of type class and changed the opacity of an array texture 2D image. To begin the function we said if button is click is false, play a sound. Afterwards spawn an actor of type class and the parameter we will put in for this is our input parameter Actor. Still in the same statement we spawn this actor at a Vector MousePos. The point of MousePos is to hold the position of the mouse's X,Y coordinates. So upon clicking the button, spawn an actor at mouse position. To add onto this function we set the return value of spawn actor to Target actor and then set the opacity of the input image to fifty percent. So upon clicking the button we want to give that look that hey... We pressed a button so all other buttons are disable, visually speaking. To continue this we set button is click value to true at the end of the function. Thus ending the function of Drop Item. Now if we were to test this out in the game nothing really would happen because we never called the function. To actually make something happen in game we added four given functions into the event graph. These functions were OnPress for IS1, IS2, IS3 and IS4. What we basically said was on each button press, call the DropItem function. For each of these methods we made sure to assign two parameters in the DropItem function. In IS1 we assigned the board, IS2 we assign the Duct tape, IS3 we assigned the lock and IS4 we assign the gate actors. For each of these methods we also made sure in the array parameter to set all four images in there.
Button Click Events
  So now in the game world upon clicking on a button something would actually happen. Upon click, a mesh will spawn on the mouse position and all four images of the button would be somewhat translucent. Now if the player were to move the mouse, well the mesh wouldn't move. Why? The answer for that came from the game loop. We never stated in the game loop to dynamically set the mouse position at every tick. Before continuing on I wanted to say, me and my partner spent a while figuring out how to get the inventory to drop while dragging. The logic is pretty simple and fairly easy however it became difficult after finding out on UE4 with widget blueprints, you can't specify On Release events for buttons. Which is odd because you can specify On Release events for actors in a scene. With knowing this though, we still were able to add this functionality in the game loop using two tests. So if button is click is true and left mouse button is not down, at every tick set the MousePos to the actual mouse position on screen and then set the actor location. If left mouse button was down, don't do this but instead set button is click to true. Having this logic will allow us to basically drag and drop.

Event Tick Event
  
  Upon playing the game now if I were to hit any of the buttons what will happen is a mesh would be spawned at the location of the mouse position and at every second the mesh will follow the mouses position until I click again. Having completed this logic was very satisfying mainly because, in Max Proof it isn't just the inventory where you can drag and drop items, but items in the game world too. So you can probably assume, creating the logic for the actors in the game world was fairly easy! In all honesty, the drag and drop functionality in the game world looks way more clean than the inventory mainly because I can actually do On Release events! Now enough about that, that will be for another blog. From looking above your probably wondering why I never mention about the hover button function as well as the refresh button function. My goal is to actually go over that in the next blog as I finish up polishing the inventory in Max Proof. Stay tune!

Sunday, April 26, 2015

Max Proof: Designing an Inventory

  One of the things many people are told is that you gain more experience in a specific skill whether its doing more on hand tasks at a new job or doing more in a degree that your pursuing. All I can say is it's true. To start this off while pursuing my Bachelors in Game Programming as a junior I took Midterm project. Our project at the time was a first person puzzle game made on Unreal Engine 3 where the character is trapped in some ruins. The goal of the game was to get out of the ruins through solving puzzles. One of the main mechanics I can recall for this game was an Inventory System where the user can switch between a torch or a lighter,  even have the ability to pull different books out of the inventory to read. Now out of all the things me and my group were taught in our major, creating an Inventory system was something that was never taught before. Although of that, as a programmer your known for creating problems and solutions. With all the material gather, chances are you can use that knowledge to create your own Inventory. At the time however, I guess you can say we weren't as experienced enough to just dive into creating an inventory for our midterm project. So where am I leading with this?
  Well to dive right into it, I am currently a senior now attending senior project. The project that was assigned to us was Max Proof. In Max Proof players are given an inventory of items where the user can drag and drop to baby proof an area. So here it is again, an Inventory that has to be created. To top it all off, through our entire time as a Game Programmer we were taught the ins and outs of Unreal Engine 3. Seeing that Unreal Engine 4 came out we decided as a group to dive into that instead and it was a huge transition I must say. 
  With Unreal Engine 3, creating UI would have to be done through Scaleform which in turn would have to be done through Adobe Flash where you use Scaleform to transition that SWF file onto Unreal Engine 3. Looking at Unreal En
gine 4, there isn't any Scaleform, instead there's Widget Blueprints where you can create the UI through there. Personally from seeing that I was thrilled because it saved me the time to go through of having to do one thing in a program to another. So what is the difference between me and my group from where we were a junior taking midterm project versus now?
Ruin Game
  The difference I would say is we now know how to create an Inventory. In fact, as a programmer we've learn that not only does it take a lot of hands on work to gain experience but it also takes much research as well to be able to expand your knowledge. The goal for the inventory in Max Proof is to allow the user to grab items and place them into the level. With the items it will cause a list of events. These items are, a lock, duct tape, boards, and gates. Knowing the inventory will consist of these items means we will need four graphics that are buttons (Gate graphic in progress). Upon clicking the buttons a polygon mesh will come out where the user can drag the mesh and drop it into the game world. Having this information I was able to know how to design the inventory. The great thing about Unreal Engine 4 is that Scaleform is not integrated into it. Did I say that before? 
  In Unreal Engine 4 we have something called Widget Blueprints where developers, designers, even programmers can create UI with but enough of that, lets get into the implementation.
  I would like to break this implementation down through three phases, design, production and polish.  During our design phase we created a Widget Blueprint called Hud. In this widget blueprint we started off by creating a horizontal box in the canvas and placing it below in the canvas with the length filled to where its fully expanded. This horizontal box we called "inventory". Inside Inventory we also threw in four buttons naming them IS1, IS2, IS3, IS4 which standed four Inventory Slot with an associated number to it. To continue this we made should to have some padding with each button to create a space between them all. After actually being comfortable of the buttons placement in the Inventory we threw in an image inside each button. So the hierarchy looked like Canvas >  Inventory > IS1 > image , IS2 > image, IS3 > image, IS4 > image. The purpose of placing these images in the buttons well was of course to create the look that the buttons were truly the images. Thus doing this practically completed our design of the inventory. But is that really all we had to do for designing the inventory? Not at all! We had a few more steps.

  This last steps consisted of creating a new blueprint class that derived or inherited from a HUD. After creating this new blueprint GameHud, we basically grabbed our widget blueprint and added it to GameHud through using the event graph. In the Event graph we basically said... At the start of the level create this widget blueprint called Hud and place it in the viewport. At the same time, set the current mouse to show on the screen. From doing this we allow ourselves to actually have the Inventory appear when playing the game but how does the compiler know to actually call this GameHud blueprint? This is where the game mode comes in.

  With Game mode we can actually assign things like what the player controller class is, the pawn class, the hud class or the camera class. With that knowledge we created a Game Mode blueprint and had GameHud integrated in it. Thus, the HUD is officially done with the design.

Animating Max: Creating his Walk Cycle

  One last step and Max will be finally ready to be integrated in Max Proof.  This last step is Animating Max. My goal is to create a walk cycle for him so when we throw him in the game, we can at least have a working AI. The method I used for creating his Walk cycle is actually the second time I've used this which is using the CAT Motion Editor


  The CAT Motion Editor is a great way to edit animations. To begin creating Max walking what I did was go to the motion tab and while on there click the CAT Parent object in the scene. This brings you to the animation properties. While in the properties I added a CAT Motion Layer and toggled the animation mode to play which in turn, assuming I have an animation would allow me to now officially play it. Having the CAT Motion layer added in I hit the CAT Motion Editor and open the character walk animation. With the character walk animation added into the layer I was now able to see Max walking however it wasn't pleasing. The reason being is because Max's arms were bending and twisting to much as well as the body. Considering Max is a baby, my goal was to make the walk animation as if it was really a toddler walking. Still in the editor, I begun going to different groups such as RibcageGroup >  Arms > Bend or PelvisGroup > Pelvis > Twist and messing with the parameters. While changing the parameters I made sure to have the animation playing to see how the parameters would effect Max's walk cycle.

  I did this for quite a bit, maybe an hour or two honestly only because the original walk cycle had so much twisting and bending occurring. On top of that when it came to animating Max and messing with the animation parameters in the CAT Motion Editor, I was able to truly see what part's of the body were stretching. After seeing, I would have to go back to skinning and re adjusting weights on bones. Eventually on though, I was able to get Max walking without any stretching occurring. And man must I say, I feel accomplish! After completing Max's animation I was ready to export him so that we can integrate him in our game. To do this simply, I went to File > Export after giving the export a file name in the presets, I checked on Smoothing groups, Converting Deforming Dummies to Bones, Checked Animation on and set the walk cycle to the key length of the animation. Now some may be wondering why I set converting deforming dummies to bones and well when it came to importing to Unreal Engine 4 I ran into the issue where the bones would actually fuse with the mesh to where it actually shows in game. Going back to 3ds Max and setting converting deforming dummies to bones actually allowed me to export and import perfectly with no problems. That being said hope you guys enjoy the model and animation!!


Skinning Max

  Phew, I got Max fully modeled and rigged. All there's left is skinning Max and animating him. Skinning sounds like a simple process to do because practically what your doing is adding the bones to the model and then adjusting weights on the bones to prevent any stretching occurring on the textures.

  I like to think of this process as guess and check, not literally but you get the picture. To get into detail what I mean is, adjusting the weights of the model and then checking based on that adjustment.. How the textures look on the model. Is there any stretching still because the bones were adding? To actually begin skinning, in the modifiers tab I chose Skin. With Skin being selected in the stack I hit Add right next to bones. Having hit Add I chose Max's Pelvis and hit Control C. Doing that allows to select all bones child to Pelvis. Having done that I hit select which adds all those bones to the Skin modifier or in other words.. Adds the skeleton to the model. Now if we wanted to we could go straight to animating and the actual model would move. The problem is, now that the skeleton has been added to Max there is possible stretching that may occur. The weights of each bone can affect not only the textures but the actual model itself. With the picture above you can see what I mean. Having selected one of the bones in the body brings out a capsule as well as a few color. I like to think of the color as temperature. So the cooler the color is, the less the body will be influenced by the bone and the hotter the color the more influence is occuring. As you can see above, having select the middle bone you can see its influencing part of the arm. Wait what? Why would that bone influence an arm? So what this means is if we were to move or rotate this bone, the arms would be influenced as well. I'll just say it, we don't want this. If anything there shouldn't be any influence what so ever between these two. This is where editing envelopes comes along. The capsules are the envelopes which produce different temperature representing the influence level the bone gives out. The goal I had was to have minimal influence in locations that would make sense to not have influence in.


  As you can see with the picture above, by clicking the quads envelope, the influence levels are only or mainly at the quads and minimal from top to knee. So how did I minimize the influence levels you may ask. Actually I just learn how to do this in a more simple way. Having selected an envelope I hit vertices and begun selecting all the vertices I wanted either more or less influence on. After selecting the vertices I went to weight properties. In Weight properties there's a spot called Abs Effect. In Abs Effect you can adjust the weight's influence level of a bone through numerical values. 1.0 being the hottest to 0.0 being no influence at all. So what i did for each envelope was select vertices I wanted no influence at and set the Abs Effect to 0.0.


  After doing this to all envelopes and becoming satisfied, I was able to begin animating the model. I'm not going to lie, after finishing with skinning Max I got more excited because I was dying to integrate him in the game already. Well let's jump to animating now!

Rigging Max

  In all the things I have ever done on 3ds Max, the baby model Max was the most complex! I spent way more than thirty hours on just that model. One of the things I wanted to say before I begin how I rigged Max is after finishing everything with polishing Max I actually used a modifier called Turbosmooth. Seeing how so complex Max is with polygons, Turbosmooth worked perfect for him. What Turbosmooth does is iterate the number of polygons on the model and smooth it out more. Now after getting that off my chest lets dive into how I rigged Max. The method of rigging Max is different from all the other ways I ever rigged a model. To start it off, I begun by going to the create tab in 3ds Max and choosing helpers. While in helpers I chose CAT Objects from the drop down. In CAT Objects I selected CAT Parent. With CAT Parent selected I clicked and dragged on the screen to create the basis of where the rigging will begin. Now before, I said the method of how I rigged Max was different and this is where the different process comes along. Usually I would create the rig from scratch such as the bones but for experience I wanted to get more familiar with Max and so I used a preset for the rig. The way I went about doing this was while having the CAT Parent selected in the scene, in the details panel clicked the folder called "Open Preset Rig". The rig I chose was the Base human rig which basically gives you the skeleton for a character. In all honesty for the first time going with this approach, I would actually recommend it only because it's literally creating a skeleton for you assuming the model is a character versus doing the manual way which would produce the same result. Now after loading this preset there still was so much to do such as positioning of the bones, scaling to match the model size as well as rotation.


  In the picture above, the skeleton to the right is the original base human preset skeleton. The skeleton to the left is the edited version that I did of the base human preset. As you can see there's a huge difference with positioning and sizing.


  After creating the skeleton I position it to have it exactly meet the location of the model. Once doing that I begun increasing the size of each bone to match the body through going to each bone and increment the length, width, height or depth. Once becoming satisfied with the sizing of the bones I positioned them in the desire location. For the pelvis bone, I brought it a little back more and rotated it. For the arms, I made sure to translate it to where the bone is in the middle of the mesh. After doing that I begun rotating the arm bones so that the rotation mimics the actual mesh itself. The great thing about rigging and something I just learn is there's a functionality similar to mirror and symmetry. Let's say I position rotate and scale a bone to my liking. Let's say its the arm. There's a button called, copy/mirror limb settings and with that it copies a parameters for that bone. So when I go to the other arm I can hit the paste/mirror limb settings to paste those parameters right on to mimic the other arm. Having said that I did that for the arms and legs. Completing the rigging for Max. If we wanted to we could begin animating the skeleton however upon playing the animation Max wouldn't move. The reason being is because we never skinned the bones onto Max or in other terms welded the bones on to him. The next task you can probably already guess. Skinning Max!

Polishing up the Baby Model

  Good news, the basis of the baby model is completed so I was able to jump to polishing up the model more in details. Some of the features I needed to polish on the baby was well more on the head; dealing with the size of the head, the shape of the nose and mouth as well. Then there's the hands that need polishing, back, butt and lastly the positioning of the arms which I'll get to later. When given this project, one of the things the client wanted with the baby model was the model having a big head. Having this information I was able to make the head bigger through selecting all polygons on the head and scaling them up in all axis. Once doing that I shrink the top vertices of the neck a bit to make it look better


  If you were to look at my previous blog, the last image posted showed the baby's back straight. My goal with the back was to create a more realistic back; to curve it more. Essentially that's what I did and this process was long. Creating this curve from the back well... Most 3D modelers would have an idea how I did it. The idea is pretty simple however the process took some time. Basically what I did was grab a few desired vertices and move them towards the stomach and as I descended down to the next edge, I would go in more with the vertices giving that inward look for the back. Towards the middle I begun grabbing vertices and pulling them away from the stomach to create that arc look. Now as odd as it sounds, if you were to look at the butt... It's pretty flat. It should be rounded more. 


  As you can see with the picture above, I was able to succeed that. Through some observation you can definitely pin point that I added a lot more edges to the stomach to round it out more but as well as to begin working on the butt. Modeling the butt was very similar to polishing the bottom of the back. I begun pulling vertices out and then inward. After doing so I begun rounding the butt out more that that it doesn't look flat on the sides. If you were to compare this picture above with the first picture in this blog, the noses are different. In all honesty the nose's shape was bother me a lot and after accomplishing the arc on the baby's back I was thinking... Why not do the same for the nose. So similar to the back, I arc the nose to create more realism and appeal.
  Unfortunately around this time I stopped creating different versions of saved files and continue polishing with this one, so I wouldn't be able to pull up the progress of how I did certain things with the model. Fortunately because I made this baby model, I can go into details on what I did as far as processes goes. After getting the shape of the head, the neck, the back, butt and nose..My next task was positioning the arms. 
  
  The problem with the model is that it's in T Pose. Upon texturing it where practically texturing the armpits as if it was stretched. So upon moving the arms down when rigging, the texture for the arm pit's would still be stretched. Knowing this would be an issue I changed the baby's posed from T to relax, as you can see above. Now wouldn't this be a hassle to do for both arms? YES! This is where mirroring came along. I grabbed half of the models polygons from one side and deleted it. Upon deleting it, in the modifiers tab, I selected Symmetry. Symmetry is just like mirror but the difference is, it has a auto weld function that upon collapsing the stack of modifiers... It welds the symmetrical half, to the original half. With symmetry, it makes a copy of the model and then you can choose which axis the copy is in. Where I'm going at with this is, all I had to do is re position one arm and boom! I'm down with the other side! Now re positioning one arm was bad as it is. What I had to do was select a ring of polygons that would separate the arms from the shoulders and delete it. Once deleting that ring allowed me to gain access in maneuver just the arm of the model and not the arm and the model at the same time. So when I did this, I translated the arm down a bit, rotated it as desired. Once I was satisfied with the position I had to re attach it to the model. From using 3ds Max for a while now, I'm very comfortable and confident when it comes to doing crazy things. Re attaching the arm back to the body is very possible. The way I did it was selecting border. With border I selected the opening of the arm and hit Cap which creates a face in the opening. I did the same with the shoulder. After doing this I selected both new faces and hit bridge. Hitting bridge connected both the new faces together which in turn.. Connected the arm to the body.
  Having re position the arm I had a few tasks left for the baby. This came from rounding the head out more and polishing the hands. To give an idea of how I rounded the head... I begun moving vertices inward to give less of boxed head shape and more of a sphere shape.



  After accomplishing that I begun polishing the hands more. The hands to start off were just spheres in the beginning. Considering Max the baby, would grip on objects, we needed a more realistic hand.  I was able to accomplish this through very similar methods. Pushing and pulling vertices in and placing them in desire locations. I also spent a lot of time on rounding the hands out more so that they don't look like there are any sides that look squared. Thus after doing this finished the baby model! Well at least modeling it! As you can see there was a big jump from pictures as far as progress went. My teammate had textured the baby for me. After texturing was completed meant we were one step closer for integrating the baby. The last things left are Rigging, Skinning and Animating the baby. Hope you guy's enjoy the model!


Creating a Basis 3D Baby Model

  Currently I am enrolled in my senior project course and I must say, I'm really excited. This course is divided up into two eight weeks where we will be developing a product based on a project a client has given us. The project me and my group have been given is called Max Proof which will be a game where players have to baby proof an area so that Max; the baby can walk safely. The game is in isometric view and will take place in the babies home. Before the baby begins to walk in the area, players are given thirty seconds to baby proof the area.This can come from securing doors using locks, fill in holes using boards, even moving items in the scene to different locations. As a group, we are given the task to of course deliver the complete project to our client. So as a group how have we spread the work out? Well for what I can say, I was assign to create the baby model, rig and skin it, as well as create the animations for the baby. To continue this I was also assign for helping develop the inventory with one of my team members on top of doing the collision functionality in the game. For me, senior project is a big deal so I can say this 3D baby model has been the most complex model I have ever developed and I am very excited to continue to work on it. So lets dive into it!
  Having begun a few side projects before senior project I was developing a character model for a game. When I got to senior project I had three options; create the baby from scratch, use the character model I was already working on and make it into the baby or use a model I had completely finish that was just for fun. The option I went with was of course, the character model. The model I had completed for fun was a model many might be familiar with; sack boy!

  This was a very fun model to work on and I've been dying to implement this model in a game. Unfortunately because I am not a 3D modeler but a programmer there are a few bad things about the sack boy model I created. Such as cleanliness and location of polygons. When it came to the sack boy model, it was not organize as far as polygons went. I basically went nuts as you can tell. On top of this, if you look at sack boy's legs... His legs are to far from the hips and they are already bent. With that creates a lot of issues with rigging and animating because since they are already bent, we may get a lot of illegal geometry when straightening the legs in animation. Thanks to those reasons I was able to come to conclusion to go with the other model because it was very clean.

  As you can see above, this was the character model I was working on based off a tutorial I was watching. I went with this because it was way more cleaner in polygons here. A lot of the placements as well made a lot more sense. In all honesty, before I actually get started to show how I develop the baby, I just want to say I'm really excited to show how much of a transformation I made from this model above to what the results are now. So when I begun modeling the baby model using this one I develop as a template, I started off with the hands and feet first. The way I went about creating the hands and feet was through the tool called bevel. Bevel is just like extruding but with outline in it where you basically pushing or pulling a polygon out and either scaling the face more or less. When it came to the hands I selected the face that pointed forward and used Insert which created another face in the polygon and shrink it down. Having that new polygon created I bevel it out to create the thumbs. Thus ending the basis of the feet and hand.
  The next step was proceeding on the stomach...Giving the baby a belly! This honestly was the most fun part because it was pretty hilarious to work on. I mean when I first was doing this I was like wait...This guy looks pregnant, he can't look pregnant!

  Eventually though I was able to get it right. The way I went about doing the baby's belly was very simple. I selected one edge going vertical, hit Ring which selects a ring of edges that's horizontal to the one I originally selected and then hit Connect. Doing this creates a new ring of edges going horizontal that connects to the ring of edges going vertical. Having three new rings of edges, I basically started selecting vertices and bringing them out, creating that round shape belly. After doing that I selected all polygons on both legs  and scaled them down on the Z axis and stretched the legs out a bit on both the X and Y axis to created that look as if the legs are fat. I also did this for the arms as well. So with this being said, I practically had most of the basis down! Just needed a head next!


  If I were to give any detail on how I did the head, the most descriptive way I would say I accomplish this came from how I did the hands. Basically beveling things out, scaling polygons down. As you can see with the picture above, I bevel quite a bit to create the head. Before I went crazy though, I made sure to extrude first to create the neck. The next step was creating the eyes and and nose for the baby. Just like anything else, I messed around with either Insert or Outline and then extrude it. Well for the most part of the nose. One of the things I did do with the nose though was also translate some of the polygons as well as shrink them more as desired. On top of that as I got towards the nostrils, I beveled inwards to create that hole; making sure that the polygons that was going in was not overlapping any existing polygons.


  When it came to the eyes I actually did not have to do anything with Outline, Insert or Bevel. If anything I would think of it as just planning it out. My goal for the eyes were to get it at least an oval shape which I achieved through moving vertices to desire locations. You may be wondering now, how come in the picture above the other eye looks weird. The reason why I left the other eye alone was because I knew I was going to end up deleting half of the model in the future so that I can mirror it and eventually weld the two together. It sounds confusing but when I go over it later on, you'll see what I mean. The last step for creating the basis of the baby was the mouth and man I must say this was the most difficult thing to work on. It wasn't fun at all only because it gave a weird look as if his cheeks were going in. Just like how I did with everything else, I used the friendly bevel tool. With the mouth I beveled inward and eventually begun extruding by small iterations inwards. After having what I needed to work with as far as polygons I begun shaping the mouth more by moving the vertices to desire locations. Just like with the eyes, I tried going an oval shape. The difference between doing this and the eyes were well... I needed lips and I needed a hole for the mouth. After having the final part extruded out I also beveled inwards to create that hole for the mouth but as well give me more opportunity to shape the lips more. Thus finishing the basis of the entire. Model. Now keep in mind, I said basis! All of this is just a foundation of what I'm really going to work on. Still very excited to show off the baby!

Monday, April 20, 2015

Unreal Engine 4: Lift Demo v1

  After having to get Leap Motion integrated in Unreal Engine 4 I immediately jumped into learning a few new things through going to the Leap Motion website where there was an example implementation of Leap in Unreal Engine 4. Having spend some time looking at the different projects offered I felt I become somewhat familiarized with what I wanted to do. One of the things I like to do now is whenever I begin a new project, create a requirement list. To me creating a requirement list is very helpful because you can use the list as a way to debug your project further or to see if everything is matching what your requirements are for the project. For this project, I created a small requirements list.
Lift Demo
Requirement ID
Description
Status
1.1
The system shall recognize when a hand is added
Complete
1.1.1
If the system recognizes if a hand is added, the system shall set the hand mesh to visible
Complete
1.1.2
The system shall recognize when the hand is removed and set the hand mesh to not visible
Complete
2.1
The system shall be able to determine when a hand has collided with a handler
Complete
2.1.2
If a hand collides with the right handler, the system shall move the ball right with some torque
Complete
2.1.3
If a hand collides with the Left handler, the system shall move the ball left with some torque
Complete
2.1.4
If a hand collides with the back handler, the system shall move the ball backwards with some torque
Complete
2.1.5
If a hand collides with the forward handler, the system shall move the ball forward with some torque
Complete
2.1.6
If a hand collides with the top handler, the system shall have the ball jump based on an impulse
Complete
3.1
The system shall be able to change the balls material if both hands collide with one another
Incomplete
3.1.2
If two hands collide with each other, the system shall be able to change the balls collision status
Incomplete
4.1
The system shall be able to grab different objects in a scene using two hands
Incomplete

  As you can see above, I still have quite a few major aspects to still implement in the demo but other than that, I was able to get one portion working fine! So to begin the process I started off with a new project using the rolling ball template in Blueprint. Looking at some of the functionality I changed some methods, added a few functions as well as integrated the Leap Motion Controller onto the pawn blueprint. But that's not really saying much or diving in is it?

To dive into it, in the pawn blueprint of the ball I added the component Leap Motion Controller

   When I first did this, I ran into a problem. Upon starting the game, the hands would appear assuming you had your Leap Motion Controller set up. But considering the pawn is a ball that roll's, the hands would roll too. In order to prevent this from occurring I actually just attached the controller as a child of Spring Arm. Thus, the hands would not rotate. So the hands were integrated in the pawn's blueprint, but what is it doing? Nothing really. My goal was to have the hands control the movement of the ball. The way I went about doing this was creating Handlers. Each handler would determine which way the ball would maneuver when a hand collided with it. Thanks to UE4 this was simple in the Pawn's blueprint. I created five box collisions. The names I gave to these handlers were RightHandler, LeftHandler, TopHandler, Forward, Backward. All child's of Spring Arm so there relative rotation are not relative to the ball.

  After creating these new components, I placed them in the desire location close to the Leap Motion Controller. Now begins the logic! To begin with the logic I created three functions called MoveRightLeft, MoveForwardBackward, and Jump. These functions say what they need to do. Move the ball right, left, forward, backward or jump. Clicking the + sign at the top right of functions I created my MoveRightLeft function. In it was really only three statements. Setting a boolean called HandCollides to true and if HandCollides is true add a torque to the target ball. In the torque pin, I broke out the vector where I multiplied a float called RollTorque of 50000000.0 value to the parameter XAxis and plugged the value of that to the X coordinate of the vector. To end the function, I created an Input parameter called XAxis of float type.

 
  Thus ending the MoveRightLeft function. The MoveForwardBackward function was very similar. The only difference was, I use the resultant value and plugged it in the Y coordinate and changed the input paramter name to Y Axis.


  Lastly, I just needed one more function left. The Jump function. This one was already given, I just made it into a function for organization.


  Having the functions finished, I jumped back to the Event graph to get the implementation running in the game loop. Actually implementing was fairly easy, all I had to do was on each begin overlap of a handler, call the desire function relative to the name. On end overlap set HandCollides to false which disables the ball from continuing moving.



  Thus completing most part of the Demo. All I needed left was the material changing dynamically on the mesh as well as the ability to grab objects with the Leap Motion Controller. As far as it came down to dynamically changing the mesh, I was very familiar how to do it upon a key press... But not sure how to go about doing it if both hands collided with one another. To actually get the balls material to change dynamically and with it's collision I created an input event called I. My logic behind this was if the ball was not invisible, set the material to visible and set the collision response to ignore all on all objects that are dynamic. If the ball is invisible, change the material back to the original and set the collision response to block world dynamic.


  After doing this I decided to just jump into the level to see how the integration worked out and man it's so cool! My goal before actually calling this demo completed is to not only complete my requirements list, but to create the balls movement more smoother through creating a Gyro Ball. Based on the hands location in the gyro ball I want the ball's location to increase whether the hand is moving forward in the ball, forward left ect. Personally I feel this route is much cleaner. My other goal is to actually spend some time designing the level. The current level was just something I threw in to see how the functionality of the pawn works. Can't wait to release version 2 of it!!




Integrating Leap Motion in Unreal Engine 4

Currently I am taking GSP 475, phew one step closing to graduating! For this class we essentially have a eight week project where student's have the option to create something with emerging technology. For me, I decided since I have the desire to continue expanding my knowledge in Unreal Engine 4 now that 3 is slowly becoming obsolete, I wanted to do a project with Unreal Engine 4. Being up to date I am, I actually read an article from Epic about Leap Motion. For those not aware, Leap Motion is a motion tracking device that tracks hand movement. It's pretty cool and can be integrated in many software such as; Unreal Engine 4. For this project my goal essentially was to create a small game where players can maneuver a ball based on hand movements as well as have the ability to pickup objects and place them in desire locations. For this project, I decided to call it Lift. Before jumping in to how I went about developing this project, I wanted to give a brief description on how to Integrate Leap Motion into Unreal Engine 4. Here it is!


Instructions for getting Leap Motion Running


To install and be able to use this product, first you must obtain a few other software such as Leap Motion SDK, Visual Studio Community 2013, as well as Unreal Engine 4’s source code. To continue this you will also need a Leap Motion Controller.

So let’s begin with the first software.

How to obtain Leap Motion SDK:

1.      Go to the Leap Motion site.
2.      From there jump in the Developer tab and the download should begin right away. If not, hit the download link to begin the download.
3.      After the download is complete, run the installer application.
4.      Assuming a Leap Motion Controller is on hand, connect the Leap Motion Controller to your computer.
5.      In the taskbar, a Leap Motion Controller Icon should appear. Right click>Visualizer to test that the software and hardware are working properly.

There you go, you officially have integrated the working software and hardware into your computer. The next step is downloading Visual Studio Community 2013.

Acquiring Visual Studio Community 2013:

1.      Go to the Visual Studio site.
2.      Hit Download.
3.      Run the .Exe
4.      Continue following the steps guided by Microsoft visual studio to fully install it

One more list of steps and then you’re done! We now have to download Unreal Engine 4 source code onto your computer through GitHub so that you can acquire the Leap Motion Plugin in the Engine.

How to obtain Unreal Engine 4 Source code through GitHub:

  Establishing an account with Unreal Engine:

1.      Go to the Unreal Engine 4 site.
2.      If an account has been created before, sign in otherwise sign up.
3.      After signing in or signing up, go to Account
4.      In the box Get UE4 Full Source Code, right click and open in a new tab linking your GitHub account
5.      In the steps below featured on the page, click the first step’s link GitHub.com which will take you to GitHub

  Creating an account on GitHub:

1.      If an account has been created before, sign in otherwise sign up.
2.      After signing in or signing up you should have been taken to Epic Game’s page on GitHub. If not, retrace your steps back to step 4 which assuming if logged in on GitHub. You’ll be taken to Epic Game’s page.
3.      Once on Epic Game’s page on GitHub, click Unreal Engine.

  Installing GitHub:

1.      Once on the page, scroll down to Getting Up and Running where you’ll click GitHub for Windows. Assuming you have windows.
2.      On the new page open, hit the download button to install GitHub on your computer.

3.      Before continuing any further, jump back to the previous tab in Unreal Engine to your account.
4.      Hit Profile and plug in your GitHub name to sync it to your Unreal account.

  Forking and Cloning a Repository:

1.      Back to the GitHub page, at the top right corner of Epic Game’s GitHub profile, hit Fork. Doing so will create a copy of the whole source code to your account.

2.      After doing this jump into the GitHub application that you installed.
3.      Hit + > clone.
4.      From there you should see Epic Game’s where you’ll have the option to cloning Unreal Engine or Unreal Engine Tournament. Clone Unreal Engine.
5.      Choose a destination you would like to clone the repository to on your computer.
6.      After doing so a folder of the repository shall appear on the desire designated location.

  Obtaining the Source Code:

1.      Go to the folder that was just created.
2.      Run the Setup.bat file
3.      After that’s completed run GenerateProjectFiles.bat
4.      Once the files have generated a solution file for visual studios called UE4.sln should be available.
5.      Open UE4.sln.
6.      Once Visual Studio has open up, in the solution explorer right click on UE4 > build. This may take some time to build.

Once the build has completed you shall have the entire source code project of Unreal Engine now officially on your computer plus giving you access to Leap Motion Controller Plug in. But the instructions doesn’t just end here! You still got to actually plug in the plug in in a project.

  Plugging in Leap Motion into an existing Project:

1.      Open the editor through clicking Epic Game’s Launcher or through going to Engine > Binaries > WIN64 > UE4Editor
2.      Once either or is clicked, Launch the most current version of the editor you have.
3.      Next, create a new project with whatever template you desire.
4.      Afterwards, go to Window > Devices and Enable Leap Motion. Doing so will restart your project to enable it.


There you have it. Leap Motion has been fully integrated in your project!