[PloobsEngine] Tutorial 0 – Basic 3D Scene

This first tutorial with teach you the basic concepts of the PloobsEngine and how to create a simple 3D scene. (tutorials series here)

We plan to make a serie of tutorials, some will be about using the engine, others will explain how the engine implement its internal features. We will range from the basic to the advanced. Our plan is to release at least one tutorial each week.


For those who does not know ploobs yet, the PloobsEngine is an engine for creating games and graphics applications developed in XNA 4.0, C #. Net 4.0 and HLSL. It is designed to be simple and easy to use even for those unfamiliar with computer graphics programming.

First of all, i recomend you to read this post that presents the engine and its capabilities. Also, download the Visual Studio 2010 Templates (you will find it in that post) and install on your computer, we will use them in this tutorial.

Our first sample will be a very basic 3D scene (an island with some directional lights, see the screenshot in the end of the article =P). BUT, before start coding, is essencial to learn the basic architecture about the PloobsEngine.

PloobsEngine Architecture

We will focus in 3D in this tutorial, The PloobsEngine can be seen as the following class diagram (in a point of view of the users):


Simple Class Diagram



The class EngineStuff is our “Entry Point”, it is responsible for transparently interact with the XNA (and sometimes with the underlying system), you normaly dont access/use this class when making your application.

The EngineStuff class contains an instance of ScreenManager, that is responsible for managing (add, remove, load, update internal states and draw ) the IScreens.

The IScreen represents an abstraction to a container of components that will be updated and maybe draw in your application. The engine provides some implementation of this class, the most used ones are: IScene (for 3D world) and MovieScreen (to play a avi file).

  • IScene: Container specialized in 3D World management, contains an instance of IWorld and IRenderTechnich (like you saw in the class diagram =P).
  • MovieScreen: Specialized in playing videos  (used in cinematics for example)

For this first tutorial, we will only talk in depth about IScene implementation.

As said, each IScene contains an IWorld that acts as a container of objects, triggers, lights, cameras, particles and 3D sounds. It also take care of updating, adding and removing these components.

The objects that are draw in the screen are represented by the entity called IObject, that is composed by others classes:

  • IModelo, Responsible for storing geometric (vertices and indices) and texture informations of the object.
  • IPhysicObject: Responsible for represent the object in the physic world. The engine has lots of implementation for this class, the most used are BoxObject, that represents the object as a box, and the TriangleObject, that represents the object as a colection of triangles. All physic simulation will be done considering the IPhysicObjects, not the IModelo data. For example, we can see a detailed dragon in the screen (IModelo being draw), but the physic system simulates it as a simple box.
  • IMaterial: Responsible for rendering the IModelo in the screen using the progamable pipeline. The IMaterial is just a “dummy”, the IShader class does the real work. The engine provides lots of classes that implements this interface, each one gives a diferent appearance to the associated object.

The IScene also contains a IRenderTechnich that draw the objects in the screen (using the objects’s IMaterial and others internal stuffs) .

When building a simple application in the PloobsEngine, you should only worry about extending the IScreen class (or one specialization of it like the IScene) and overrides some of its methods (like the initialize and the LoadContent). This is what we are going to do in the next section.


Getting your hands dirty

Before coding, you should have:

  • XNA 4.0 Game Studio installed.
  • The Visual Studio 2010 Templates or Donwload the PloobsEngine xna 4.0 version DLLs (both can be found here)

If you prefer dont use the Visual Studio Templates, you can create a simple Windows XNA 4.0 Game Project (the one that ships with XNA 4.0 Game Studio), download the DLLs of the engine and add it to the project:

  • The PloobsEnginePipelineDebug.dll Must be added in the Content Project (not used in this demo)
  • The PloobsEngineDebug.dll must added in the main project projeto principal (the PloobsEngineDebug.xml file must be in the sampe folder of PloobsEngineDebug.dll)

If you choose to use the templates, you dont need to download the DLLs, just create a project using it and everything will be configured.

We are interested in building 3D worlds, so we begin extending the IScene class  as show in the following list: (the template already contains an IScene implementation of this class, you can replace it or just change  some parts):

using Microsoft.Xna.Framework;
using PloobsEngine.Cameras;
using PloobsEngine.Light;
using PloobsEngine.Material;
using PloobsEngine.Modelo;
using PloobsEngine.Physics;
using PloobsEngine.Physics.Bepu;
using PloobsEngine.SceneControl;

namespace IntroductionDemo4._0
    /// Basic Deferred Scene
    public class BasicScreenDeferredDemo : IScene
        /// Sets the world and render technich.
        protected override void SetWorldAndRenderTechnich(out IRenderTechnic renderTech, out IWorld world)
            world = new IWorld(new BepuPhysicWorld(), new SimpleCuller());

            DeferredRenderTechnicInitDescription desc = DeferredRenderTechnicInitDescription.Default();
            desc.UseFloatingBufferForLightMap = true;
            renderTech = new DeferredRenderTechnic(desc);

        /// Load content for the screen.
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
            base.LoadContent(GraphicInfo, factory, contentManager);            

            SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");
            TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
            DeferredNormalShader shader = new DeferredNormalShader();
            DeferredMaterial fmaterial = new DeferredMaterial(shader);
            IObject obj = new IObject(fmaterial, simpleModel, tmesh);

            #region Lights
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.4f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo.Viewport));

        protected override void Draw(GameTime gameTime, RenderHelper render)
            base.Draw(gameTime, render);
            render.RenderTextComplete("Demo: Basic Screen Deferred", new Vector2(GraphicInfo.Viewport.Width - 315, 15), Color.White, Matrix.Identity);

The method SetWorldAndRenderTechnich always must be override. It is responsible for creating the IWorld and the RenderTechnich that the scene will use.

In this example, we are creating a simple IWorld, passing a Bepu physic world implementation called BepuPhysicWorld (responsible for collision detection and physic simulation, the user can create its own physic World (not an easy task =P), just need to extend the IPhysicWorld interface). We also provide an ICuller implementation, in this sample we created a SimpleCuller (responsible for accelerating the render proccess). The Ploobsengine provides others implementations forICuller like the OctreeCuller class.

After we create the IRenderTechnich.  The engine provides two implementation for this class: the ForwardRenderTechnich that implements the classic renderization technich called Single Pass Multi-Lightning and the DeferredRenderTechnich that implements DeferredShading.

Some olders computers and the Windows Phone 7 plataform does not run DeferredShading and must use the other. Most of our effects like shadow are only implemented in Deferred Shading, if possible, we always recomend users to choose this option. For this tutorial we first create a DeferredRenderTechnicInitDescription (in the following tutorials we will talk about how to configure this object to create interesting effects) and feed it to the DeferredRenderTechnic.

The next method overrided is the LoadContent. Here we create and populate the IWorld.

To create a simple IObject, we use the following code:

    SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");
    TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
    DeferredNormalShader shader = new DeferredNormalShader();
    DeferredMaterial fmaterial = new DeferredMaterial(shader);
    IObject obj = new IObject(fmaterial, simpleModel, tmesh);

In the first line we create the IModelo, passing in the first parameter an intance of the graphic factory (responsible for creating every stuff related to graphics, the engine provides it). The second parameter is the name of the model used (can be a .x or .fbx) and the last one is the diffuse texture name (if you dont provide, the engine will try to find it inside of the model) . If you are using effects (will be explained latter) that need more textures like bump mapping, you should use other SimpleModel constructor, or use one of the IModelo methods to load it). The model used in this demo can be found in this project (the code is also there, with lots of others examples)

In sequence, we instantiate the physic representation of the object. We used a TriangleMeshObject passing the IModelo, position, rotation, scaling and physic material properties (like friction and mass). Remember that Triangle Meshes cannot be moved, they act as they have infinite inertia.

Next, we create the IShader and the IMaterial, we used the DeferredMaterial implementation (That works with the DeferredRenderTechnich) and the DeferredNormalShader.

The engine provides lots of options for shaders (in this context, we use this word meaning graphich effect) like DeferredCustomShader that supports Normal Map, Specular Map and Glow Map. The DeferredNormalShader supports only simple phong illumination (with diffuse texture only), you can only customize the Specular Intensity and Specular Power (look at the shader constructor) of it.

Now that we have all the necessary stuffs, we just create the IObject passing the created auxiliar instances and add it to the IWorld.

To finish the LoadContent method, we create five Directional Lights (without shadow) and a First Person Camera (can be controlled by mouse and keyboard). We will talk more about this in the next tutorials.

The last stuff we did in the IScene class is overriding the method Draw just to write something on the screen. (things must be draw after the call to the base.draw())

To show the IScreen on the screen =P, we need to start the PloobsEngine. The following code does this job:

using System;
using PloobsEngine.Engine;
using PloobsEngine.SceneControl;
namespace IntroductionDemo4._0
  static class Program
  /// The main entry point for the application.
  static void Main(string[] args)
   InitialEngineDescription desc = new InitialEngineDescription("PLoobsDemos",800, 600, false, Microsoft.Xna.Framework.Graphics.GraphicsProfile.HiDef, true, true, true);
   using (EngineStuff engine = new EngineStuff(ref desc, LoadScreen))
  static void LoadScreen(ScreenManager manager)
    manager.AddScreen(new BasicScreenDeferredDemo ());

The InitialEngineDescription is an object that contains lots of initial parameters of the engine (things like Antialiasing options, VSync, use of MipMap, internal Clock update method, screen resolution and the name of the application), experiment changing this parameters =P

The EngineStuff recives two parameters: the description and a the function (LoadScreen in our case) that creates the first IScreen and add it to the ScreenManager.


The first tutorial id finished. If you run it, you will see the following image (move the mouse and the ASDW QZ keys to control the camera).

Tutorial 0 Image


We are using deferred shading, so even if you enable Antialiasing in the Engine, it wont work. The following tutorials will teach you how to enable/use our Post Process antialiasing.

The code for this demo can be found in our Introduction Demos package, you can download it here. (there are lots of others demos in this package, we will explain each of them in the next tutorials)

In the following post we intend to explore some of the basic resources of the engine. The next one will talk about the Input System and the Physic System.

Any doubts, critics, suggestions, pls go to our forum or leave a comment here.

See you guys =P



, , , , , , , , , , , , , , ,

  1. #1 by automated trading algorithms on 27 de julho de 2017 - 2:58 am

    “You built some beneficial details there. I did a look for within the matter and observed most folks will consent with your webpage.”

  2. #2 by Jak dostac skiny on 27 de julho de 2017 - 2:58 am

    Hello my loved one! I wish to say that this article is amazing,
    nice written and include approximately all vital infos.
    I’d like to look extra posts like this .

  3. #3 by bellitanner.pearlcyclesstore.com on 27 de julho de 2017 - 3:03 am

    But it is important is usually to pick something which is comfortable to wear.
    However, prior to buying any product, you need to first know what works best
    for you. In fact, it’s Victoria’s Secret and Fredericks along with
    the fact they spend millions on advertising as to why their costs are so
    high and you may be thinking this is not a choice for you due to the economy.

  4. #4 by Grirmsor on 27 de julho de 2017 - 3:12 am

    Hello it’s me Fiona, I am also visiting this web site regularly, this site is in fact fastidious and the visitors are actually sharing good thoughts.
    Teenage brunette girl loves to toy her wet and thight pussy

  5. #5 by warcraft full movie on 27 de julho de 2017 - 3:13 am

    While Warcraft bringing in $320 million worldwide
    is not out of the land of possibility, the notion that it will do
    so is starting to appear as fantastical as the movie’s plot, if
    the planned U.S. opening weekend number is anything to go by.

1 2.472 2.473 2.474
(não será publicado)