Book Image

PlayStation Mobile Development Cookbook

By : Michael Fleischauer
Book Image

PlayStation Mobile Development Cookbook

By: Michael Fleischauer

Overview of this book

With the PlayStation®Mobile SDK you can create stunning games for the PlayStation®Vita and PlayStation™Certified devices (PS Certified devices). It includes everything you need to get started, including an IDE for developing your code and even an emulator to test your creations. "PlayStation®Mobile Development Cookbook"| is an exciting and practical collection of recipes that help you make the most of this exciting new platform. It provides you with everything you need to create complete 2D or 3D games and applications that fully unlock the potential of the SDK. After quickly covering the basics, you'll learn how to utilize input sources like touch, gamepads, and motion controls, and then move on to more advanced content like creating and animating 2D graphics, networking, playing sound effects and music, adding physics, and then finally jumping into the world of 3D.
Table of Contents (17 chapters)
PlayStationMobile Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Publishing Your Application
Index

Adding lighting to your scene


If you take a look through the PlayStation Mobile documentation, you may notice there is no functionality in the SDK for lighting. How then do you add lights to your scene? Well, shaders of course! In this recipe we are going to do exactly that.

Getting ready

Load PlayStation Mobile Studio and create a new project. Once again, we will use the prior recipe as a base for this recipe. The complete project is available as Ch7_Example6.

How to do it...

  1. Using AppMain.cs from Example5, edit Main to match the following (the new code is highlighted):

    Vector3 lightPosition = new Vector3(0.0f,10.0f,-3.0f);
    textureShader.SetUniformValue(textureShader.FindUniform("vecLightPos"),ref lightPosition);
    Vector4 ambientLightColor = new Vector4(0.05f,0.05f,0.05f,1.0f);
    
    bool done = false;
    while(!done) {
  2. Then further down, edit the event loop to match the following code snippet:

    while(!done) {
    graphics.Clear ();
    
    var viewWorldProjection = camera.GetMatrix();
    textureShader.SetUniformValue...