Thursday, June 19, 2008

It's a small world after all..

Yup. Managed to create a small world for our ninja. And it's wash day for our ninja right now so the red suit's gone - enter the yellowish suit. Also, someone commented out that the previous version of the ninja "gallops". =) That was supposed to be the running animation, but i guess i still have a lot to learn how to do smooth animation. So right now our yellowish ninja decided to just walk instead - though the walking is still somewhat unnatural. Here's the latest video:



I intentionally avoided the obstacles in the demo. There is still no collision detection yet in the program. That is the next thing i will do, i guess. And collision detection is also needed when our ninja finally fights.

Damn ninja, are you really a ninja.. or a robot?

Tuesday, June 17, 2008

The Ninja Walks. The Path is of Yin and Yang.

Sounds deep, man. But actually, the words above means what it means. Literally. Here's a video of the ninja that walks -- towards the path of Yin and Yang. It's just an update of the fragging game. It looks cool, I think, so I was thinking of a cool blog post title. Hmm, here's the video. Again don't mind the watermark, it's not cool. But Instant Demo is. Hehe.



I am quite happy with this update. A lot of things were accomplished in a few days time. Let's drink to that! Well, not now. Friday -- sure.

So what's new with the program?
  1. Windows mouse coordinates (which is 2D) transformation to OpenGl object coordinates. Think of it as clicking anywhere in the screen returns the exact object coordinates (3D) being clicked -- ray and object intersection. This was mainly accomplished with the help of the gluUnProject method.
  2. Mouse cursor in the form of a red katana. It's not very noticeable in the video. This is the biggest headache in this update. This needs good placement of push and pop matrices in the code. And it involves manipulation of projection and model view views. It WILL mess up gluUnProject if not invoked at the right place in the code. I learned this the hard way.
  3. Ninja movement in the direction of the mouse click. This is thanks to item 1, we now know where in the openGl world the mouse clicks. This involves transformations -- Linear math (Matrices)! Also, the transition moves between animations were added.
  4. Thanks again to #1, we now know where to put the Yin Yang animation!
  5. And lastly, Blending. Both the cursor and the Yin Yang symbol were blended. Notice how the Yin Yang vanish over time! It's because of blending.
Ok. Enough for now. My code is still kinda messed up so I'll probably clean it first before proceeding. Then after that the most logical step is probably -- environment loading!

Ok I forgot to level up Sensui. Uhm, level 5 now? Who cares? =)

The ninja is tired of walking. When is he gonna kick ass?

Sunday, June 15, 2008

Completed MilkShape Model to OpenGl Program Quest! Level 3!

Wow, leveled up again! Yeah, yeah, because I documented 10 days of work in just one night, that's why. Well, let me continue where we left off last time. This is the last work of I the Bard the Documenter (is there such a word? good thing for software engineers, we can freely invent words) before I Sensui the Ronin will take over. The bard tells the story, the ronin kills the monsters.

So we are at loading the MilkShape Model in an OpenGl Program, right? Right. But before tackling that problem, there should be an OpenGl program in the first place -- that problem assumes knowledge of OpenGl-C++ program integration. Fortunately for me, I already killed that monster a long time ago. I already wrote a number of OpenGl programs before, so no problem.

Well for those who are not familiar with OpenGl, it is just a graphics library specification, composed of graphics function calls. Those who are interested, visit: http://nehe.gamedev.net/. There are a lot of tutorials in there. That's where I started when I decided to learn OpenGl.

Hmmm, so to load the model in the program... refer to tutorial #31 by Brett Porter in the link above! I have now the excuse not to discuss this stuff in length. =) The tutorial lacks animation loading details and animation in general. Brett Porter has another tutorial regarding animation in this link: http://web.archive.org/web/*/http://rsn.gamedev.net/tutorials/ms3danim.asp. This is more detailed and very helpful if you want to understand loading and implementing animation.

The only thing that the tutorials lacked is that it can't handle multiple animation sequences. We'll we can't expect a tutorial to do everything for us. =) So using the custom file that contains the animation name and sequence bounding frames that i mentioned in the last post and the concepts in Brett's tutorial, I reimplemented how the joint transformations are updated based on the current animation sequence's (being executed) bounding frames. I also implemented code to smoothen the transition between animation sequences, say run and jump. Also, keyboard keys were tied to a particular action/animation sequence.

So at the end of it all, Sensui the Ronin presents you with these screenshots and a video file. The water mark in the video is from the software I used to capture my screen activity. It's called Instant Demo Software.



























So what's the next monster to kill? Level/dungeon loading. Character navigation in levels/dungeons. Collision detection. Fragging effects. Don't worry, there's still a lot to kill.

For now, sleep, Sensui, sleep.

Level 2! Character Modeling Attribute increased!

I hacked a number of monsters in the last few days. These are:
  • How to model and texture a human character in MilkShape
  • How to create multiple animation sequences in MilkShape
  • How to load Milkshape models in an Opengl program
  • How to handle multiple animation sequences in an OpenGl Program
With these monsters dead, I think my increase in level is justified. =)

Modeling Characters in MilkShape


Man, modeling a human character in three dimensions, two dimensions at a time is just pain, man, well, at first. It was a struggle. But the good thing about us gamers is that we have ruthless determination to do what we need to do. Vertex by vertex (where every vertex==sweat), my human model took shape. By the time the head and the upper body of the model were done, the vertex by vertex operation seemed natural. I decided to create a ninja model, so that I don't have to deal with the facial features at the moment.

The same is also true with texturing. It was hard at first. But when you are done discovering the proper technique, everything will proceed smoothly, and you'll be happy.

By the way this helped me a lot, so feel free to check this out if you want to learn how to model in MilkShape:
http://blackboard.cottages.polycount.com/tutorials.htm


Here's a snapshot of my final ninja model in MilkShape.














Multiple Animation Sequences in MilkShape

So MilkShape allows you to add Joints (or Bones) to your model and attach the necessary vertices (the Flesh) to the joints. It also allows you to animate your Joints, hence the vertices, in between Key Frames through interpolation. A Key Frame is a frame in your animation where you specifically defined the position(s) of one or more joints. This is all good. But there's a problem: MilkShape only allows one animation sequence. This means when you parse the Milkshape file later on and execute the animation in an OpenGl program, you only see one animation sequence. How can you make a single model, say, capable of walking, running, and jumping when your program recognize only a single sequence?

My solution is quite simple. Create multiple animation sequences in the MilkShape animator. Create a file that records the boundaries of each sequence, and the animation name. Load this file when the Milkshape file is loaded. If we want a particular animation to be executed, just refer to the data from the file so that we know what frame range is needed to be considered in the animation. Simple, isn't it?

Here are videos of my ninja animation sequences. The other video shows the same model in a different skin. Of course I still need to add some more animation sequences, say attacking, defending, etc.







Well,I the Bard, will just continue writing my exploits in the next post. Not that I have so much to say about loading the MilkShape file and my custom animation file in an OpenGl program, and implementing the multiple animation stuff in the program. I just feel that these things deserve their own post title. That, and the fact that at 2am, Sensui the Level 2 Ronin is already tired. =)

Sensui the Level 1 Ronin, Summoned!

So yeah I am my own avatar and I summoned myself to conquer this task at hand. What task you ask? To code a fragging game, of course! This will be an RPG game, no definite story line yet, but, there'll be lots of blood and gore for sure! The story line is not the priority. The priority is graphics, then game play. Sound next. Story line last.

I will be updating the game design. There seemed to be none right now. The Level 1 Ronin is only interested on learning how to code and to model, the basics. One step at a time.

Here are my starting items:
  • Visual Studio 2007, for coding and debugging
  • MilkShape 1.8.3 (Trial Version, oh man!), for modeling characters and items
  • Gimp 2.0, for image editing
  • Beginning OpenGl and More OpenGl Game Programming books
  • Swords and Circuitry, RPG design book
Here are my starting attributes:
  • Advance C++ knowledge
  • Intermediate OpenGl knowledge
  • Can dig Matrices and Transformations
  • Zero Quaternion knowledge
  • Noobish Modeling Skills
  • Noobish Image Editing Skills
So there that's your Level 1 Ronin!

Hack, Slash, Hack, Slash! Grow Ronin, grow!