[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);
            this.World.AddObject(obj);

            #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.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion

            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);
    this.World.AddObject(obj);

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))
   {
     engine.Run();
   }
  }
  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.

DONE !

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

Links

 

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

  1. #1 by Web Design Service in Australia on 24 de março de 2017 - 6:24 pm

    This paragraph gives clear idea in favor of the new viewers of blogging, that really how to do blogging and site-building.

  2. #2 by http://www.browardcountybusinesslist.com/specific/Alternative-Health.htm on 24 de março de 2017 - 6:24 pm

    At this time I am going to do my breakfast, after having my breakfast coming again to read additional news.

  3. #3 by tinder dating site on 24 de março de 2017 - 6:30 pm

    Very good Web-site, Stick to the very good work. Thank you!
    tinder dating site http://tinyurl.com/kws7ftc

  4. #4 by Aracelis on 24 de março de 2017 - 6:37 pm

    Aw, this was an extremely nice post. Spending some time and actual effort to generate
    a really good article… but what can I say… I put things off a whole lot and don’t seem to get anything done.

  5. #5 by http://milspecea.com/looking-for-the-key-secure-and-well-known-russian on 24 de março de 2017 - 6:41 pm

    Fortunately in our society it is now acceptable that folks probably will change careers and jobs several times before they finally find something that they love, something
    that they are fantastic at and are very happy to show up to 5
    days a week. Dye-sublimation printing is employed in medical imaging, polyester fabric printing, and graphic proofing.
    Allowing consumers to choose the charity, and even developing a revolving report on charities, results in as being a marketing incentive.

  6. #6 by Moupfsp on 24 de março de 2017 - 6:46 pm

    わたしの場合は、更に見た目(表層)の技術力がないので、意思のみ固く持った、あたかも隠れキリシタンのような存在になってしまった。 いつまでも中古では何かと不自由なので、今度は冒頭の製品を買おうかなと。 [url=http://www.anstoss4-planet.de/Scprite/Forum/wbb216neu/thread.php?threadid=72305&sid=]日本アニメ人気DVD box[/url]
    まあ、実害が今のところないので放っておきましょう。  自分が先日からSurface Pro 3のユーザーになったとはいえ、フルサイズUSB 3.0、microSDカードリーダーが付いているのは自分にはありがたいところです。
    [url=http://www.minkita.net/modules/d3forum/index.php?post_id=2027]ごぶごぶ BOX13/第13弾 DVD-BOX激安[/url] コレはWin10での計測そんでWin7の時はこんな感じw。 ASEM議長声明に「南シナ海問題」明記せず。
    [url=http://liyu023.forumcity.com/viewtopic.php?p=13177#13177]日本アニメ人気DVD box[/url]
    バージョンの確認方法:ProgramFiles / Internet Explorler / iexplor.exe を右クリック / プロパティ / 詳細。 あなたは Office365 PROPLUS へ今後の移行のための Office バージョンの使用状況データを収集する必要があります。 [url=http://www.goshuya.com/home/modules/d3forum/index.php?post_id=14478]日本アニメ人気DVD box[/url]
    通勤ラッシュに巻き込まれることは、健康にもよくありません。 手帳やノートのようにずっと書き留めておくものではなく、基本的には書いてすぐ消すって使い方になる。
    [url=http://forum.tsukaeru.net/viewtopic.php?p=31522#31522]日本アニメ人気DVD box[/url] 2~9I、PW 9本 シャフト  D/G センシコアS300 5I長さ  38.25インチ 5I重量  426g バランス  D3弱 グリップ  ゴルフプライド(交換不用) ※ 2番アイアンのみ別購入。 太陽光、太陽熱、地熱、燃料電池など新再生エネルギーの装備を住宅に設置すると、設置費の一部を政府が支援する事業だ。
    [url=http://blackhand.forumcity.com/viewtopic.php?p=3303#3303]韓国ドラマ 運命のように君を愛してる DVD-BOX[/url]

  7. #7 by http://altcoinsrigs.com/ on 24 de março de 2017 - 7:22 pm

    Direct the scene to your blog to allow them to
    share their thoughts about your statement. One other thing which you are
    required to take into account is limiting access towards the network, particularly if you embark on any type of secure printing or if you might have regions of the network which can be for secure files.
    But Apple features its own idea about the best way to watch video, and it has not even attempt to do with standards that other people
    creates.

  8. #8 by heading=h.vkp13hinmb94 on 24 de março de 2017 - 7:24 pm

    Excellent article! We will be linking to this particularly great article on our website.
    Keep up the good writing.

  9. #9 by Anita on 24 de março de 2017 - 7:26 pm

    Agora é hora de inovar as receitas, lembrando que em todas receitas modo
    de preparo é mesmo.

  10. #10 by http://www.tier1graphicsusa.com/auto-insurance-phoenix-arizona.html on 24 de março de 2017 - 7:32 pm

    What a pleasure to find someone who identifies the issues so clearly

  11. #11 by http://news.christianlouboutinreplica.pw/christianlouboutinreplicapw/139.asp on 24 de março de 2017 - 7:34 pm

    We have bought the brand out of bracelet some instances. Every one is ultra cute, manufactured very well, cannot tarnish and also important based on which a single you purchase and also just who one provide things towards.

  12. #12 by radiusworkshops.com on 24 de março de 2017 - 7:35 pm

    Direct the vista time for your site to allow them to share their
    thoughts about your statement. One other thing that you’d like to consider is limiting access towards the
    network, particularly if you take part in any kind of secure printing or if you’ve got areas
    of the network which can be for secure files. But Apple features its
    own idea about how to watch video, and it has absolutely nothing
    to do with standards that anyone else creates.

  13. #13 by endsleigh car insurance gloucester on 24 de março de 2017 - 7:39 pm

    Felt so hopeless looking for answers to my questions…until now.

  14. #14 by http://power-suppliers.info/2017/01/20/looking-for-the-most-safe-and-popular-russian-date/ on 24 de março de 2017 - 7:43 pm

    This device also governs the flow of power through the photovoltaic array to
    the grid and vice-versa. The three basic colors used by
    reproduction are cyan, magenta and yellow. Roughly equal amounts from the three primary colors give rise for the perception of white.

  15. #15 by didimit.com on 24 de março de 2017 - 8:07 pm

    Fortunately in the current society now it is acceptable that men and women will likely change careers and jobs
    several times before they finally find something that they enjoy, something that they are fantastic at and
    therefore are pleased to appear to days a week. This type of technology utilizes
    specialized equipment, teaching materials and services that can enable him or her perform and function in their
    surroundings. It was foreseen that this variety of 3D
    printers in homes and business establishments raises rapidly.

  16. #16 by Elana on 24 de março de 2017 - 8:09 pm

    Wow, amazing blog format! How lengthy have you been blogging for?

    you made running a blog look easy. The full glance of your site is fantastic,
    as neatly as the content material!

  17. #17 by sarveshtiwari.com on 24 de março de 2017 - 8:19 pm

    Job hunters could also setup their unique account, upload their resume, and setup notifications.

    Dye-sublimation printing is utilized in medical
    imaging, polyester fabric printing, and graphic proofing.

    Depending on the size and scope from the organization, these improvements can yield significant
    ROI.

  18. #18 by harta gono gini on 24 de março de 2017 - 8:20 pm

    This design is steller! You obviously know how to keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Wonderful job. I really enjoyed what you had to say, and more than that, how you presented it. Too cool!

  19. #19 by designatedconcierge.com on 24 de março de 2017 - 8:23 pm

    This device also governs the flow of power in the photovoltaic array for the grid and vice-versa.
    This type of technology utilizes specialized equipment, teaching
    materials and services that can enable they perform and function in their surroundings.
    It was foreseen that the amount of 3D printers in homes and business establishments increase rapidly.

  20. #20 by Download GE0-803 Certification Dumps on 24 de março de 2017 - 8:24 pm

    Every as soon as in a although we pick out blogs that we read. Listed below are the latest sites that we select

  21. #21 by movie2K on 24 de março de 2017 - 8:25 pm

    Hi there colleagues, how is everything, and what you desire to say about
    this article, in my view its really awesome in favor of me.

  22. #22 by http://www.warburtongallery.com/how-many-people-die-a-year-from-texting-and-driving.html on 24 de março de 2017 - 8:26 pm

    Absolutely first rate and copper-bottomed, gentlemen!

  23. #23 by 0 budget natural farming on 24 de março de 2017 - 8:27 pm

    usually posts some quite intriguing stuff like this. If you are new to this site

  24. #24 by movie2K on 24 de março de 2017 - 8:31 pm

    I’m not positive where you are getting your info, however good topic.
    I needs to spend some time finding out more or figuring out more.
    Thank you for fantastic info I was in search of this info
    for my mission.

  25. #25 by prospecting network marketing on 24 de março de 2017 - 8:35 pm

    What’s Taking place i am new to this, I stumbled upon this I have found It positively useful and it has
    aided me out loads. I’m hoping to contribute &
    aid other customers like its helped me. Good job.

  26. #26 by chuyennhuong247.com on 24 de março de 2017 - 8:36 pm

    This device also governs the flow of power through the photovoltaic array to
    the grid and vice-versa. This type of technology utilizes
    specialized equipment, teaching materials and services that will enable they perform and function of
    their surroundings. Allowing consumers to pick the charity, and even creating a revolving
    set of charities, finds as a marketing incentive.

  27. #27 by the fate of the furious cast members on 24 de março de 2017 - 8:38 pm

    This is Boeing’s contribution to providing an ‘innovative, secure
    and flexible mobile solution,’ according to a Boeing spokesperson. For example, you maybe the boss of a company and
    suspect your employee is abusing his or her phone privileges.
    This IP address then can be mapped to general geolocation data.

  28. #28 by http://news.christianlouboutinoutlet.win/christianlouboutinoutletwin/164.asp on 24 de março de 2017 - 8:44 pm

    This item had been at such a very good rate I do not considered that high quality is so that excellent. It’s perfect. That mom will like this on Holiday early morning once she opens gift therefore appearances like I spent a great deal more, but rates is simply great!!

  29. #29 by http://news.cheapmoncler.pw/cheapmonclerpw/153.asp on 24 de março de 2017 - 8:45 pm

    We have purchased this particular brand name of bracelet a few instances. Every one is super attractive, made very well, cannot tarnish plus meaningful depending on what definitely one you purchase furthermore who people award it on.

  30. #30 by http://news.cartierreplica.top/cartierreplicatop/36.asp on 24 de março de 2017 - 8:45 pm

    The device is with such a very good price I did not idea the particular grade is quite exceptional. It is pretty. This mom will appreciate information technology on top of Christmas early morning anytime she starts gift and it appears like I devoted even more, then again prices is simply great!!

  31. #31 by http://news.monclerjacketsoutlet.xyz/monclerjacketsoutletxyz/142.asp on 24 de março de 2017 - 8:46 pm

    Our device was in that ideal price I by no means idea your excellent is therefore excellent. It’s beautiful. This mother is going to really like things in Xmas morning whenever she opens up gifts therefore appearances as though I spent more, however prices ended up being just awesome!!

  32. #32 by stop working on 24 de março de 2017 - 8:47 pm

    Hello, I think your site might be having browser compatibility issues.
    When I look at your blog in Chrome, it looks fine but when opening in Internet Explorer, it has
    some overlapping. I just wanted to give you a quick heads
    up! Other then that, great blog!

  33. #33 by www.dadh.gov.tr on 24 de março de 2017 - 8:48 pm

    Job hunters may also setup their unique account, upload their
    resume, and setup notifications. The three basic colors useful for reproduction are cyan, magenta
    and yellow. But Apple features its own idea about the best way to watch video, and it
    has nothing to do with standards that anybody else creates.

1 2.079 2.080 2.081
(não será publicado)