Development: 3D mouse, drag to walk, SSAO, screen effects with anti-aliasing, triangulation, X3D 3.3, soft shadows demo, VisibilitySensor, 3D world improvements for games

May 12, 2012
Manor designed using RoomArranger, shown by view3dscene
House floor designed using RoomArranger, shown by view3dscene
First stages of RoomArranger viewer using our engine
Final stages of RoomArranger viewer using our engine, with more controls and SSAO
New GUI of examples/lazarus/model_3d_viewer, with screenshot and navigation types buttons, and engine logo
Demo of avatarSize[2] (configure the tallest object that you can climb, e.g. which stairs you can climb on)
SSAO (Screen-Space Ambient Occlusion) without Anti-Aliasing
SSAO (Screen-Space Ambient Occlusion) with Anti-Aliasing
Fountain model; no SSAO
Fountain model; SSAO
Fountain model with textures; no SSAO
Fountain model with textures; SSAO
German Pavillion in the Universal Expo of Barcelona of 1929 (by Victor Amat)
German Pavillion in the Universal Expo of Barcelona of 1929 (by Victor Amat)
Soft shadows, adapted from nVidia SDK 9, but using a PoissonDisk sampler (by Victor Amat)
VisibilitySensor demo

Hi everyone! We have a lot of news about new features and improvements in our engine and view3dscene. No new release yet, we just announce what is available in SVN (and can be tested by downloading view3dscene from snapshots). I really have to start making these news posts more often, otherwise they get ridiculously long, well.. as long as this one :)

Oh, and before we start: if you like seeing the engine grow so much, please consider donating. I really appreciate it, especially as I plan to spend next year without a regular job, focusing mostly on the development of "Castle 2", a new great open-source game using our engine.

Features and improvements implemented in the last months:

  1. First of all, great news — we have new developer working on our engine: Jan Adamec. He's also the author of Room Arranger, a shareware program to design your room, apartment, house and more. The next version will use our engine for the internal viewer of generated VRML models :) Here' a movie of our engine used to render a house model from RoomArranger:

  2. Thanks to Jan Adamec, we have a lot of new features and improvements to navigation in Walk/Fly modes:

    • We support 3D mouse devices in all our tools (like view3dscene and all engine examples, games etc.). Only under Windows for now — contributions for other OSes are welcome, of course.

      The video below shows how 3D mouse works in various navigation modes:

    • Navigation by mouse dragging is now possible in Walk/Fly modes (similar to other VRML/X3D viewers). Drag with left mouse button to move forward, backward and rotate. Drag with right mouse button to move sideways (strafe) and fly up/down.

    • Holding Shift during movement allows to run (speed increases * 2).

    • Mouse wheel (look up / down) works for cameras inside Lazarus control (just like in TCastleWindow).

    This nice screen summarizes most new controls used in Walk/Fly modes: Walk/Fly navigation controls

  3. Also thanks to Jan Adamec, we have Screen Space Ambient Occlusion implemented inside our engine. Available as comfortable view3dscene menu item "View -> Screen Effects -> Screen Space Ambient Occlusion" (for developers: TCastleAbstractViewport.ScreenSpaceAmbientOcclusion.) Works on arbitrary models out-of-the-box :) Uses our screen effects framework.

  4. Screen effects cooperate now wit multi-sampling (anti-aliasing). Previously, any screen effect (like SSAO, or view3dscene effects, or effects in VRML/X3D files like demo_models/screen_effects/ from demo models) was disabling anti-aliasing.

    Now we can use OpenGL ARB_texture_multisample to have multi-sample textures used with screen effects. The GLSL code of every screen effect is linked with some helper screen_xxx functions. If you use them, your effects will work both with and without multi-sampling. The new functions are documented in future Screen Effects docs (this will replace the current Screen Effects docs at the next release). All existing engine effects, like SSAO and other view3dscene effects in "View->Screen Effects", are already ported to use scene_xxx functions and cooperate with anti-aliasing.

  5. Triangulator fixes for complicated concave polygons. Various fixes to account for duplicated vertexes and (more general) collinear triangles inside polygon. Previously, they could cause problems, with normal vectors of polygon and ears determined incorrectly, and allowing invalid non-empty ear triangles. The video below visualizes how our simple triangulation algorithm (by ear clipping) works:

  6. X3D 3.3 handling. See X3D 3.3 specification for details.

    • UNIT statement handled (in both classic and XML encoding), see demo_models/x3d/units*. Angle and length conversion is actually done.

      For example, you can now express angles in degrees by simple declaration at the beginning of X3D file. This affects interpretation of these fields:

      • all SFRotation, MFRotation
      • all creaseAngle
      • TextureTransform.rotation
      • Background.skyAngle,groundAngle
      • Arc2D.startAngle,endAngle
      • ArcClose2D.startAngle,endAngle

      Length conversion is also possible. This is less useful IMHO — you can as well just wrap your model in a Transform with some scale. Actually, that's exactly our implementation of "UNIT length" for now — we simply add appropriate scale (calculated looking at length unit of inlined model (inner), and looking at length unit of inlining model (outer)).

    • MetadataBoolean node added.

    • GravityPhysicsModelNode renamed to ForcePhysicsModelNode (spec was mistakenly confusing these two names). (Only parsing.)

    • Added SliderJoint.sliderForce (Only parsing.)

    • DISEntityTypeMapping has X3DUrlObject as ancestor (Only parsing.)

    • The only relevant thing still missing from full X3D 3.3 implementation is the new, very exciting for me, Volume rendering component. I would like to tackle it at some point, as it may be quite fun, impressive and useful. (But no deadline yet, so if you're really interested in seeing it implemented — contact me, patches are welcome :)

  7. Victor Amat send us some very nice 3D model of German Pavillion in the Universal Expo of Barcelona of 1929, see the screenshots on the right, with very nice water and reflections.

    And, also from Victor Amat, a nice soft shadows demo based on shadow maps. It's an adaptation from nVidia SDK 9, but using a PoissonDisk sampler instead of a jittered grid pattern. You can see a screenshot from it on the side. The source X3D file is inside demo models SVN, see subdirectory demo_models/shadow_maps/soft_shadow_poisson_sampling/. Thousand thanks!

  8. The X3D feature to specify height of the tallest object you can climb inside NavigationInfo.avatarSize[2] field is now correctly supported. The demo model is inside demo models (open demo_models/navigation/avatar_climb_stairs.x3dv; only in SVN for now, until next release).

  9. VisibilitySensor node is implemented (looking only at frustum for now). See the testcase sensors_environmental/visibility_sensor.x3dv in demo models SVN.

  10. The speed of Examine rotation by keys is now capped at a maximum constant, to prevent accidentally making wildly fast (and, as such, useless and confusing) rotations.

  11. view3dscene gets the "Screenshot" button on the toolbar (as it's an often used feature).

    Making a screenshot in view3dscene doesn't capture GUI controls (like toolbar buttons). Previously, it was inconsistent, e.g. "movie screenshot" was not capturing toolbar but "single image screenshot" was capturing them (unless it was initiated from command-line...). The general rule now is: screenshot avoids the buttons, visualizations (bounding box), and such. You can always capture a screenshot using external application, with window frames and all features you want. view3dscene screenshot's purpose is to capture your scene — not any GUI cruft.

  12. Our Blender X3D exporter updated to be compatible to Blender 2.62 (and as close as possible to distributed original Blender exporter).

  13. Memory and speed optimizations for scenes with many shapes (iteration by "is nested" callbacks instead of temporary lists, better opaque/transparent detection and more). Also, Lazarus package settings are now more suitable for production use (no assertions, no range/overflow checks, optimization level = 2).

    This also causes an upgrade of our requirements for FPC version: we require now FPC >= 2.6.0. We need the "is nested" feature, which I like a lot — it allows to utilize callbacks in more places, making things like traversing various trees more optimized and at the same time comfortable.

  14. Developers: A lot of T3D class improvements to unify collision detection for all 3D objects. We now make all collision checks (every 3D object vs all others) go through exactly the same methods and look at the same properties. Of course you can customize it (e.g. player may not want to collide with items, to allow picking up items by stepping on them), but it's all uniform in the base T3D class. Previously, various collisions in "The Castle" (player vs level/creatures/items, creature vs level/other creatures/player etc.) had specialized hacky code.

    Also more useful base 3D objects, transformed in more ways, aware of the world around them. The idea is to move "Castle 1" creatures AI to the engine, to make it trivial to use creature AI in your own games. I want to allow both using existing AI (like our walk-attack state AI), and easy designing of your own AI for specific game needs. Details:

    • New T3DMoving, T3DLinearMoving classes, and T3D.Pushable property: perfect for implementing elevators, moving platforms, and anything else than can move and push other players/creatures/items.
    • New T3DOrient, to orient any 3D models to given position/direction/up. Good for things that have a sense of up and direction, like creatures and player avatar.
    • Since player descends from T3DOrient, it's now trivial to position 3D items relatively to player. Both "Castle 1" weapons are now always displayed in 3D (when attacking or not), this simplifies a lot previous code.
    • New T3DAlive class, for keeping track of things that have life/maxlife and can be hurt (with a possible knockback effect).
    • Methods like MyMove, MyHeight and MyMoveAllowed, to easily check your own collision vs the rest of the world. The idea is that you can trivially derive new classes from T3DTransform or T3DOrient (T3DAlive any many others descend from T3DOrient too), and use MyHeight and MyMoveAllowed to implement your own artificial intelligence. It's very easy now.
    • TCastleSceneManager.Player property, to guide camera (for 1st perspective view) and to be a target for hostile creatures (if you use default AI in CastleCreatures).
    • Both walk-attack and missile creatures get a uniform FallingDownSpeed (units per second) property.
    • Many other unifications and simplifications to creature, players, items handling.
  15. Developers: a lot of improvements to game data handling, to make developing new games (like "Castle 2") more comfortable.

    • XML sounds/index.xml file improvements: now you can add new sounds to the game (castle, and future castle2) merely by adding them to necessary XML files. No need to reference the sound from ObjectPascal code.
    • KAnim usage in "The Castle" improved: all castle animations are now separate kanim files, and can be browsed e.g. by view3dscene. "Castle 2" will not use kanim at all.
    • T3DResource class, which can be loaded with reference-counting. This is a much generalized and reworked previous castle TObjectKind class.
    • XML files for each creature, item and level and now separate. The idea is to allow you to add things such as a new creature, new item, and new level to the game data without the need to recompile or to edit any central "index" file. You just add some subdirectories with index.xml files inside, and the game automatically picks them up. See documentation of index.xml files in castle data.
  16. Developers: picking improvements with T3D hierarchy: unified "The Castle" style of picking, common to FPS games (pressing the "e" button when looking at item, stateless interaction with 3D items) with VRML/X3D pointer sensors (operating with TouchSensors and drag sensors, that is stateful, tracks isOver/isActive and generally more powerful). Now it all goes through T3D.PointingDeviceActivate/Move, that can be overridden at each T3D.

    The user-visible benefit from this is that you can now pick creatures to see their name and health status. (Press "e" (interact key) to see info about creature or item at the center of the screen.) The real benefit is that new games can use picking easily, for more purposes.

  17. Developers: camera classes improvements: their input shortcuts are now published (making it possible to customize them from Lazarus object inspector), they do not descend from TUIControl (as you should only use cameras on SceneManager.Camera), TCastleSceneManager.DefaultVisibilityLimit, better Camera.Radius treatment.

  18. Developers:Various improvements to example examples/lazarus/model_3d_viewer/, based on Jan Adamec patches: buttons to change navigation mode, to make a screenshot, and nice engine logo.

  19. Website stuff:

    1. As you may have seen at our header, our small website joined the protests against the bad legislations being pushed lately — pretending to be about anti-piracy, in fact being about censorship and anti-privacy. Stop PIPA and SOPA in USA, Stop ACTA (in Polish) (list of ACTA issues in English here.)

    2. (crowdfunding for software) has shut down in March/April. It was one of the ways to donate to our engine, where you could donate to a development of a particular feature (suggested by you or someone else). It's sad that the site bankrupted, as I liked the idea very much (even if my particular project didn't yet earn anything this way). Fortunately, I found quite a few alternatives for crowdfunding specifically for FOSS projects:

      3. (it seems the guys are looking for someone to take over the website, or to close it down... So it's probably not a good idea to jump on it now.)

      If you have any experience with these sites and would like to suggest some of them (or others), please share on our forum :)