Stefan's profileeXtreme's PlacePhotosBlogListsMore Tools Help

Stefan Virag

Occupation
Location
Interests
AI Game Programming Wisdom 3
Game Physics Engine Development
Game Programming Gems 6
Introduction to 3D Game Programming with Direct X 9.0c
Real-Time Collision Detection

eXtreme's Place

April 26

BasicEffect: Lights / Part 1

BasicEffect is not that basic, if you take another look at it!

It has lots of properties and with addition of PerPixelLighting it's nice 'n' quick solution for rendering models.

This article was written to show you how just a few lines of code can make your render stand out..Of course as title suggest, we're going to stick to lighting, at least in this article..

So basicEffect.enableDefaultLighting() gives you standard lighting rig which, honestly, in lot of cases work just fine:

But what if you wanted to render a model at night, or scene with one source of light, what then? Using DirectionalLight would be ideal if you ask me, so why not try it..

basicEffect.DirectionalLight0.Enabled = true;
basicEffect.DirectionalLight0.Direction = new Vector3(0.2f, 0.0f, 0.5f);
basicEffect.DirectionalLight0.DiffuseColor = new Vector3(0.2f, 0.4f, 0.2f);

So after you've added these lines of code, which simply define diffuse color and light's source's direction..

As you can see it already looks much better, but for a final touch we're going to adjust specular power and color a bit.If you aren't sure what I'm talking about, Shawn's post might be good introduction to it

basicEffect.SpecularColor = new Vector3(0.5f, 0.5f, 0.5f);

basicEffect.SpecularPower = 8;

For the specular color I'm using a light white color, and I've set a specular power to 8..Something not to shiny and plastic, but not too flat either..

Not too much of a difference, but that's mostly because we have used white color both as a light's color as well as specular color..You can play around with values and see different results!

April 21

How to implement GameService?

If you're working on a game that is made of several GameComponents, and you find out that "Skybox" component needs access of Matrix world, view and projection founded inside "Camera" component, then you're pretty much in trouble if you don't know how GameService works!

Trying to make a instance of the Camera component (in this case) in Skybox, is simply impossible - because Camera component requires us to pass a game reference to it..Trying few other ways will fail as well..

That's where GameServices comes into play.A game service is nothing more than a simply interface, which you can use for passing fields, methods..Now there another problem occurs - wait we can't use fields in Interfaces right? Well that's not really a problem when you have the field you want into component itself..
Below is the example of using Player's (component) view Matrix inside Skybox (component):

// Player Component
public interface
IPlayerShipService
{
         Matrix View
        {
                get;
                set;
        }
}

public class
Player : DrawableGameComponent, IPlayerShipService
{
        private
Matrix view;

        public
Matrix View
        {
                get { return view; }
                set { view = value; }
        }

        public Player(
Game game) : base(game)
        {
                game.Services.AddService(
typeof(
IPlayerShipService), this);
        }
}

// Skybox
public partial class
Skybox : DrawableGameComponent
{
         Matrix view;
         Matrix proj;

         public override void Update(
GameTime gameTime)
        {
                 IPlayerShipService playerService = (
IPlayerShipService)Game.Services.GetService(typeof(IPlayerShipService));
                view = playerService.View;
                proj = playerService.Proj;
        }
}


So this is working example, as you can see later inside Skybox/Update(), we can simply assign view and proj to the Player's view and proj.The reason why I'm doing this inside Update() is so they will be updated.

The reason why I'm inheriting interface IPlayerShipService from Player GameComponent is because we need to assign interface to that component.We finish that off by writing line of code in constructor..Later we simply use GetService in the Skybox Update() method to get all the things we need from the interface IPlayerShipService..

So that will wrap up this article - GameService and how they work! I hope you've enjoyed reading it and learned something from it, because this is really, I mean, really important if you're dealing with GameComponent..
If you have any question just drop a comment and I'll respond as soon as I can!

Cheers
April 13

Update(Skybox) && Information(Game)

Hello, today I'm going to show you some features that has been added to the game, as well as give out more information about game and...well you'll see!

First thing first, here's what this post is mainly all about - Skybox has been added! It has been painful and tendious task I must admit because this is first time I ever done it..But it was worth it!

Image Hosted by ImageShack.us

Image Hosted by ImageShack.us
(Environment you see here isn't really for space game right? But that can be changed with a click of a mouse!)

As you can see, the ship is still the same, even tho I said I'm going to change it as soon as possible..Well I thinked so "I'm 3D artist so it won't be a problem." But it's actually.I'm not going to do any 3D graphics for this game for simply reason - there's a big chance that next morning I'm not going to open the XNA, instead I will open Maya (3D modeling package I was working in)..

FAQ - Well not that many many peoples have asked me this, but I guess that are the questions you might be interested to hear the answers for!

What's it?
Spaceship's Journey is a 3rd personal space shooter!It will be simply game with objectives such as destroy boss-ship and so on...After all this will be the first 3D game I ever made entirely by myself! Later on, it can be expanded with more features as I learn more and more!

What's release date?
No idea!

Is this entry for DBP Challenge?
Depends on what will the game looks like on the end, and will it be completed till deadline!

Any demo, video?
Yes, very soon! Next stage will be about collision and shooting, and I'll be sure to video tape that if not release demo of it!

Tutorial perhaps?
I wanted, if anything goes smoothly through end, to release full, in-depth tutorial on making this game from scratch..Of course if you're interested and if it would help you in any way!

More about hearth of game - Engine!
I was thinking something today and came up with idea, to make this game mod-driven..The idea is to make this game very easy to change completely.So from Space Shooter you'll get WWII battle game and vice versa.

Right now if you take out HUD and change it, take out spaceship and change it, pick different skybox, you've got a completely different looking game and I will prove it in the next couple of days! I'll show the images in order (before/after).

Cheers!
April 11

Update - Interfaces, Menu

Alright, here's another update - this time onto interfaces!
I through I wouldn't be able to make such images in photoshop, but apparently I was wrong

Game got nice(if you ask me) startup screen:
Image Hosted by ImageShack.us

As well as simple HUD:
Image Hosted by ImageShack.us

And of course pause mode so you can rest:
Image Hosted by ImageShack.us

Gameplay have not been changed, except from fixing few bugs here and there, and implementing smooth movement which really doesn't deserve some attention..Next step is make point system, and start working onto game itself - implementing shooting, enemies..

Cheers till next update!
March 19

Update - 3rd Person Camera

I just wanted to inform you that 3rd person camera has been added to Spaceship's Journey game! It still too rought and I need to come up with a way of smoothing it but it's working thanks to John Sedlak who has been helping me out!

Screenshot (CMD Shows It!)
Image Hosted by ImageShack.us

By making 3rd person camera I have only added more to my "Objective list" but this is very important step in making any kind of game..

Feature I still need to implement:
-Smooth movement
-Camera rotation around model
-Collision detection
-Shooting
-HUD
-Menu

Cheers!
 
Photo 1 of 12