Difference between revisions of "Castle Game Engine"

From Free Pascal wiki
("Kambi VRML game engine" renamed to "Castle Game Engine", URLs changed etc.)
(Update for new engine 3.0.0 api: TCastleControl, TCastleScene.)
Line 16: Line 16:
  
 
Major components that you can drop on the form:
 
Major components that you can drop on the form:
# TKamOpenGLControl: descendant of the standard TOpenGLControl that makes it easy to add our engine 2D controls. In particular you can add a scene manager to handle and render your 3D world.
+
# TCastleControl: descendant of the standard TOpenGLControl that makes it easy to add our engine 2D controls and 3D objects. Has a scene manager instance (as TCastleControl.SceneManager) that collects information about your whole 3D world.
# TKamVRMLBrowser: more simplified descendant of TKamOpenGLControl, with scene manager already created. Allows you to easily load any 3D model, acts as a ready VRML browser.
+
# TCastleScene: loaded 3D model (that may contain animation etc.).
  
You just drop TKamVRMLBrowser on the form, and call
+
You just drop TCastleControl on the form, and call
  
<delphi>Browser.Load(FileName);
+
<delphi>Scene.Load(FileName);
Browser.Scene.Spatial := [ssRendering, ssDynamicCollisions];
+
Scene.Spatial := [ssRendering, ssDynamicCollisions]; // if you want collisions
Browser.Scene.ProcessEvents := true;</delphi>
+
Scene.ProcessEvents := true; // if you want animations and interaction
  
and you're done. Animations work, rendering in OpenGL works, navigation and key/mouse sensors work, etc. For more advanced uses, you can add 2D controls to Browser.Controls list, and 3D objects to Browser.SceneManager.Items.
+
Control.SceneManager.MainScene := Scene;
 +
Control.SceneManager.Items.Add(Scene);</delphi>
  
To install Lazarus components, download the engine sources, and see inside "<tt>packages/</tt>" directory. You want to install packages <tt>kambi_base.lpk</tt> and <tt>kambi_components.lpk</tt>.
+
and you're done. Animations work, rendering in OpenGL works, navigation and key/mouse sensors work, etc. For more advanced uses, you can add 2D controls to Control.Controls list, and more 3D objects to Control.SceneManager.Items.
  
For more examples, see inside engine sources --- look for "<tt>examples</tt>" subdirectories.  For example VRML/X3D browser (and viewer for other 3D models) done with Lazarus, see inside <tt>kambi_vrml_game_engine/examples/lazarus/vrml_browser/</tt> directory.
+
To install Lazarus components, download the engine sources, and see inside "<tt>packages/</tt>" directory. You want to install packages <tt>castle_base.lpk</tt> and <tt>castle_components.lpk</tt>.
 +
 
 +
For more examples, see inside "<tt>examples</tt>" subdirectory in engine sources.  For example VRML/X3D browser (and viewer for other 3D models) done with Lazarus, see inside <tt>castle_game_engine/examples/lazarus/model_3d_viewer/</tt> directory.
 
Full [http://castle-engine.sourceforge.net/reference.php API reference] and more high-level [http://castle-engine.sourceforge.net/vrml_engine_doc.php documentation about VRML/X3D handling] are available.
 
Full [http://castle-engine.sourceforge.net/reference.php API reference] and more high-level [http://castle-engine.sourceforge.net/vrml_engine_doc.php documentation about VRML/X3D handling] are available.
  

Revision as of 03:32, 1 January 2012

Features

Castle Game Engine (previously "Kambi VRML game engine") allows you to render 3D models in various formats. In particular, support for VRML / X3D format is very versatile. You can define animations, interactions, scripting, shaders and many more in VRML/X3D, so you get quite capable 3D game engine in the end.

Rendering is done through OpenGL. We can use OpenGL context initialized in any way, including Lazarus TOpenGLControl component, our own TGLWindow class (which allows you to create windows with OpenGL context, menu bars and dialog boxes, completely without the LCL), or any other library capable of creating GL context (glut, SDL).

The engine homepage is http://castle-engine.sourceforge.net/. In particular, this page lists all the engine features.

Engine is open-source (core engine may be used under GNU LGPL, with "static linking exception" like FPC RTL), developed in nice object-oriented way, only for FPC/Lazarus. The engine is not dependent on LCL, Lazarus components are just comfortable "extras".

Screenshot (VRML/X3D browser in Lazarus)

kambi vrml browser.jpg

Lazarus components

Major components that you can drop on the form:

  1. TCastleControl: descendant of the standard TOpenGLControl that makes it easy to add our engine 2D controls and 3D objects. Has a scene manager instance (as TCastleControl.SceneManager) that collects information about your whole 3D world.
  2. TCastleScene: loaded 3D model (that may contain animation etc.).

You just drop TCastleControl on the form, and call

<delphi>Scene.Load(FileName); Scene.Spatial := [ssRendering, ssDynamicCollisions]; // if you want collisions Scene.ProcessEvents := true; // if you want animations and interaction

Control.SceneManager.MainScene := Scene; Control.SceneManager.Items.Add(Scene);</delphi>

and you're done. Animations work, rendering in OpenGL works, navigation and key/mouse sensors work, etc. For more advanced uses, you can add 2D controls to Control.Controls list, and more 3D objects to Control.SceneManager.Items.

To install Lazarus components, download the engine sources, and see inside "packages/" directory. You want to install packages castle_base.lpk and castle_components.lpk.

For more examples, see inside "examples" subdirectory in engine sources. For example VRML/X3D browser (and viewer for other 3D models) done with Lazarus, see inside castle_game_engine/examples/lazarus/model_3d_viewer/ directory. Full API reference and more high-level documentation about VRML/X3D handling are available.

Enjoy! Author: Michalis Kamburelis