Castle Lines 2D

Castle Lines 2D is a set of two components for Castle Game Engine

Castle Lines 2D makes it possible to create geometry from polygons directly in the CGE editor.

Castle Lines 2D consists of classes inherited from TCastleAbstractPrimitive:

TCastleLine2D - polyline.

TCastlePolygon2D - potentially non-convex polygon.

To enter the editing mode, use the drop-down menus in the object hierarchy window

Left mouse button - add a point, move a point.

Right mouse button - delete a point.

Middle mouse button - open a window for editing a point.
EditModeOn

Detailed usage instructions:

  1. Get TCastleLine2D code.
  2. Point your project to TCastleLine2D sources. E.g. add this to CastleEngineManifest.xml:
    <compiler\_options>
      <search\_paths>
        <path value="code/" />
        <path value="../../../CastleLines2D/src/" />
      </search\_paths>
    </compiler\_options>
  1. Add to CastleEngineManifest.xml the line editor_units="CastleLine2D,CastlePolygon2D".
    See CastleEngineManifest.xml docs for examples.
  2. Open your project in CGE editor and use “Project → Restart Editor (With Custom Components)”
  3. In Lazarus don’t forget to add the source path to “Project Options → Compiler Options → Paths → Other unit files”
  4. Be sure to also add CastleLine2D, CastlePolygon2D to some uses clause, to register components at runtime.

Documentation

For detailed documentation, see Castle Lines 2D

Examples

For examples, see /CastleLines2D/examples

preview1 preview2 preview3

3 Likes

! This is fantastic :slight_smile: And you added screenshots and documentation - perfect, thank you! I will post about it soon (in 1-2 days) on Castle Game Engine news Castle Game Engine – Open-Source 3D and 2D Game Engine and will mention it on our “Additional Components” page Additional Components | Castle Game Engine .

Many thanks, and more news soon :slight_smile:

1 Like

Added various ways to apply texture. This allows you to create 2D platforms of any shape.
preview4

More details - Castle lines 2D: Introduction

Thank you again!

  1. I made a news announcement about it: Draw 2D geometry inside CGE editor using Castle Lines 2D components – Castle Game Engine . If I missed anything or said wrong, of course go ahead and let me know.

  2. I also submitted 2 small issues:

  3. I noticed that in each example, like examples/gallery/data, you have layer_physics_simulation.castle-user-interface and gizmos ( CastleLines2D/examples/gallery/data at main · KumurTash/CastleLines2D · GitHub ) that (judging from the names) are a copy of CGE editor data, castle-engine/tools/castle-editor/data at master · castle-engine/castle-engine · GitHub . Can you explain why do you need it? You should not need to copy this data (even though you use a custom editor – it should access the data of the original editor). I’m wondering

    • why do you need them

    • what can I improve in CGE so that you will not need them :slight_smile:

    Because hosting this copy of data is problematic (if you assume that it will always match the editor) – in the future, we may change these files in CGE editor data, change their names, organization etc.

1 Like

I am very glad that you appreciated my project.
In News:

The line can have non-trivial thickness

I plan to make a dynamic line thickness based on TPiecewiseCubicBezier in the next version.

About “gizmos” and “layer_physics_simulation”

If i open “castle_game_engine/examples/advanced_editor/custom_component/”. Try to open in a file “gameviewmain.castle-user-interface”. I get the error:
Error1
The error disappears if you copy the gizmos directory.
After the error appears:
Error2
The error disappears if you copy the “layer_physics_simulation.castle-user-interface” file.
The same happens with my components. I thought it was a feature of CGE.

Oh it was an ordinary bug :slight_smile:

I see the problem, and I can reproduce the case when the custom castle-editor indeed will not find the CGE location (thus it will not find the original editor data). The problem slipped my testing, because I usually define CASTLE_EDITOR_PATH environment variable, and then this problem doesn’t exist. But users should not need to define CASTLE_EDITOR_PATH.

… and fixed. Luckily custom CGE editor can still depend on build tool to detect proper CGE location.

Fixed in Fix custom CGE editor build - it must find CGE location, so build tool · castle-engine/castle-engine@e6e448c · GitHub . If you use binary builds on CGE from Download | Castle Game Engine , give Jenkins 6-8 hours and they will be updated with the fix. Afterwards, please test and you should see the problem gone, i.e. things should work without the need to copy the CGE editor data into each example.

2 Likes