[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 Darwin on 30 de abril de 2017 - 10:05 pm

    My spouse and I stumbled ߋver hеre from a different web address
    andd thoᥙght I may аs well ceck things out.
    I like what I see so i am just foⅼlowing yoᥙ. Look forward tо
    checking out your web pagᥱ for a second time.

  2. #2 by Wyatt on 30 de abril de 2017 - 10:15 pm

    Whoa! Thiss blog lookks exactlу like mmy
    olⅾ one! It’s on a togally diffeгent topic but it has pretty mᥙch tɦe same layout and
    design. Superb choice of colors!

  3. #3 by tinder dating site on 30 de abril de 2017 - 10:28 pm

    Excellent Web site, Continue the fantastic work. Thanks a ton.

  4. #4 by Bella on 30 de abril de 2017 - 10:34 pm

    I’m not that much οf a online rearer tօ be honest bսt үοur blgs really nice, kᥱep it սp!
    I’ll go ahead aand bookmark yⲟur site to ϲome ƅack down thе road.

    Ϻany thanks

  5. #5 by xxxxx on 30 de abril de 2017 - 10:36 pm

    Hi, Neat post. There is a problem together with your website in web explorer, could check this?
    IE nonetheless is the marketplace leader and a good element of other folks will leave out
    your wonderful writing due to this problem.

  6. #6 by sildenafil on 30 de abril de 2017 - 10:58 pm

    Keep on writing and chugging away!

  7. #7 by gedstl on 30 de abril de 2017 - 11:12 pm

    ↓仙台国分町にあるミネルバのネットショッピングはこちら★/お電話でもご注文を承っております。 ↓仙台国分町にあるミネルバのネットショッピングはこちら★/お電話でもご注文を承っております。 [url=http://en.ayur-garden.com/croix/moncler_1/index.html]モンクレー モンクレール[/url]
      アイテム 今回ご紹介する品は、冬の大本命アウター『ダウンコート』です。 あなたのジャケットが本当に汚れている場合それを洗浄するそれ自身の上の暖かい水で最初に、その後洗剤でも悪くはないです。
    [url=http://www.psse-kamien.pl/jackets/moncler_1/index.html]モンクレール グルノーブル[/url] ディズニー エコカイロモンクレール ダウンベスト メンズ Moncler モンクレール ダウンベスト充電式の湯たんぽがいいよ 寒い冬のお布団もすぐにポカポカ!エネタンポは、充電式湯たんぽ。 お電話でのご注文の場合、代金引換のみ、送料はお客様負担となります。
    [url=http://ibbotechnologies.com.br/lucie/moncler_1/index.html]モンクレール ダウン レディース 2017[/url]
    また、あなたのコーティングMoncler ダウン ジャケット化合物ソリューションを少なくとも一度毎年毛皮の天然オイルを補充してあなたの特定のコートは、美しい色と輝きに来て何年も維持することを確保するために専門的に掃除してください。 ジッパー刻印 LANPO ボタン刻印 FIOCCHI ITALY注意事項ヨーロッパの現地バイヤーより買い付けしました、正規並行輸入商品です。 [url=http://apievaikus.eu/souka/moncler_1/index.html]モントレー ル ダウ[/url]
    これもメーカーはより魅力的な製品と機能を維持するように注意する必要があるし、のニーズを満たす顧客を意味します。 お久しぶりです!昨日から急に冬のような北風寒くなりましたね~風邪・インフルエンザ流行ってます。
    [url=http://conronca.flop.jp/veyle/moncler_1/index.html]モンクレール バジーレ[/url] 秋には、Moncler ダウン ジャケットすべての女の子だけスタイリッシュではないいくつかキャンディー色のニットのコートに始まるべきであるし、寒さを保持することができます。 正義の味方なのにちょっとコワいかも?!是非仙台ミネルバへお越し頂き、8種類の中からお好みの1枚を見つけてみて下さい!!お待ちしております。
    [url=http://ibbotechnologies.com.br/lucie/moncler_1/index.html]モンクレール ダウン レディース 2017[/url]

  8. #8 by curso de sublimação em fortaleza on 30 de abril de 2017 - 11:16 pm

    excellent submit, very informative. I wonder why the opposite
    experts of this sector do not understand this.
    You must continue your writing. I am confident, you’ve a huge readers’ base already!

  9. #9 by http://news.cheapmoncler.xyz/cheapmonclerxyz/433.asp on 30 de abril de 2017 - 11:24 pm

    This particular system was in such a great price I did not considered the particular high quality would be hence excellent. Its awesome. This mama might prefer it at Holiday day anytime she opens gift and it looks like I spent way more, however rates was only awesome!!

1 2.226 2.227 2.228
(não será publicado)