Is there an example for 3D CAD Tool with CGE?

Hi,
my name is Michael and i am new to CGE. I was working in last 20 years on an 3D CAD program using Delphi 5.

I have plans to port it to Lazarus using OpenGL. at first i was playing with GLScene package. but it seems to be abandoned. so i found CGE and in the docs i have read that it is possible to make a 3D CAD Application with it. Im looking now for an simple example that goes in that direction.

Hi!

A number of CGE examples could be considered a CAD example, albeit with limited editing. We don’t really have a full CAD example (e.g. with mesh editing), but it is possible to do this in CGE, as we expose all necessary tools (interactions and ability to build/modify all 3D things by code).

First of all play with the editor (run it and create a “New Project” following “3D FPS game” template). Then see the manual, in particular we have resources about building geometry from code on

Let me know if you’re looking for a particular CAD feature example.

Hi,
thank you for the quick reply. In latest Lazarus 2.3.0 with FPC 3.3.1 is a change that crashes Lazarus if package GLScene is compiled in. Same with CGE. Classes that inherits from TForm need do have a RegisterWSComponent Method. For GLScene this patch resolved the problem. I don’t know which changes has to make in CGE to resolve that problem

Index: Source/DesignTime/GLSceneForm.pas
===================================================================
--- Source/DesignTime/GLSceneForm.pas	(revision 7332)
+++ Source/DesignTime/GLSceneForm.pas	(working copy)
@@ -139,6 +139,7 @@
   public
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
+    class procedure WSRegisterClass; override;
     procedure DestroyWnd; override;
 
     property IsRenderingContextAvailable: Boolean read
@@ -219,6 +220,17 @@
   inherited Destroy;
 end;
 
+class procedure TGLSceneForm.WSRegisterClass;
+const
+  Registered : Boolean = False;
+begin
+  if Registered then
+    Exit;
+  inherited WSRegisterClass;
+  RegisterWSComponent(TGLSceneForm, TGLSOpenGLForm);
+  Registered := True;
+end;
+
 // Notification
 //
 
@@ -793,7 +805,7 @@
 
 procedure GLRegisterWSComponent(aControl: TComponentClass);
 begin
-  RegisterWSComponent(aControl, TGLSOpenGLForm);
+//  RegisterWSComponent(aControl, TGLSOpenGLForm);
 end;
 {$endif}
 
Index: Source/GLViewer.pas
===================================================================
--- Source/GLViewer.pas	(revision 7332)
+++ Source/GLViewer.pas	(working copy)
@@ -29,14 +29,19 @@
 {$I GLScene.inc}
 
 uses
-  GLContext,
+  GLContext, WSLCLClasses, GLWidgetContext,
 
   GLLCLViewer;
 type
 
-  TGLSceneViewer = GLLCLViewer.TGLSceneViewer;
+  { TGLSceneViewer }
 
+  TGLSceneViewer = class(GLLCLViewer.TGLSceneViewer)
+  public
+    class procedure WSRegisterClass; override;
+  end;
 
+
 procedure SetupVSync(const AVSyncMode : TVSyncMode);
 
 implementation
@@ -60,6 +65,20 @@
     end;
   end;
 end;
+
+{ TGLSceneViewer }
+
+class procedure TGLSceneViewer.WSRegisterClass;
+const
+  Registered : Boolean = False;
+begin
+  if Registered then
+    Exit;
+  inherited WSRegisterClass;
+  RegisterWSComponent(TGLSceneViewer, TGLSOpenGLControl);
+  Registered := True;
+end;
+
 {$ENDIF}
 {$IFDEF Linux}
 begin
Index: Source/Plateform/GLWidgetContext.pas
===================================================================
--- Source/Plateform/GLWidgetContext.pas	(revision 7332)
+++ Source/Plateform/GLWidgetContext.pas	(working copy)
@@ -258,7 +258,7 @@
 
 procedure GLRegisterWSComponent(aControl: TComponentClass);
 begin
-  RegisterWSComponent(aControl, TGLSOpenGLControl);
+//  RegisterWSComponent(aControl, TGLSOpenGLControl);
 end;
 {$ENDIF}
 

We do not have any class in CGE descending from TForm . Can you point me to the details, bureports / mailing list threads etc.?

  • Why and when is this necessary,
  • is it a temporary problem in Lazarus trunk or something that will remain, and codebases like GLScene / CGE need to adjust.

Oh sorry, that was my fault. CGE produces no errors.
I will now inspect the editor and the examples.

1 Like