SergioFeitoza Posted March 3, 2019 Share Posted March 3, 2019 I have a Delphi codes using Delphi with Glscene dodo 3D visualization. I use the excellent GLScene library to do technical things like this http://www.cognitor.com.br/TR074ENGFigures.pdf . It works well for years. GLScene team helped me a lot along these years. I am now finishing the conversion of my VCL code to run in the browser. I am succeeding to do the conversion using UNIGUI. The only missing thing is the 3D GLscene part because Unigui do not accept non-Unigui components. In the forum GLScene – SourceForge , (Jerome D - BeanzMaster) suggested me to try with pas2js :https://github.com/Kryuski/pas2js-for-delphi . I am downloading it to try. This colleague gave also very interesting idea - suggestion that I am posting here for Unigui team consideration. He wrote that if you have the source code of Unigui , could try making a wrapper of TGLSceneViewer like in the next lines. Can Unigui team or users comment on this??. Unfortunately, I do not have Unigui code nor sufficient knowledge to do the wrapper and to implement the wrapper. // The WRAPPER //////////////////////////: Type TGLUniguiSceneViewe = Class(TUniGuiControl) private FGLSCeneViewer : TGLSceneViewer; public // or in protected ?? procedure Paint; override; // Put GLsceneViewer paint in property GLSceneViewer : TGLSceneViewer Read FGLSceneViewer; end; or something like this (I think is a better way) Type TGLUniguiSceneViewer = Class(TUniGuiPanel) private FGLSCeneViewer : TGLSceneViewer; procedure CreateGLSceneViewer; public // or in protected ?? constructor Create(AOwner: TComponent); override; published property GLSceneViewer : TGLSceneViewer Read FGLSceneViewer; end; procedure TGLUniguiSceneViewer.CreateGLSceneViewer; begin FGLSCeneViewer := TGLSceneViewer.Create(Self); FGLSCeneViewer.Align := alClient; FGLSCeneViewer.Parent := Self; FGLSCeneViewer.Visible := True; end; constructor TGLUniguiSceneViewe.Create(AOwner: TComponent); begin inherited Create(AOwner); SetSubComponent(True); CreateGLSceneViewer; end; Link to comment Share on other sites More sharing options...
SergioFeitoza Posted March 27, 2020 Author Share Posted March 27, 2020 I posted this in the past but no answer. Maybe something changed in the last one year so, I am trying again Did any of you any cide Unigui using 3D resources , for example like the free library GLscene or other one ? Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted March 27, 2020 Share Posted March 27, 2020 GLScene is a VCLcomponent. It is not possible to show it on the website. You need to find something that developed with core JavaScript like d3. Link to comment Share on other sites More sharing options...
SergioFeitoza Posted March 27, 2020 Author Share Posted March 27, 2020 Thank you ASLAN. Could you please tell me what is d3. If there are ganes running in the browser it is possible to create something like a wrapper for GLScene GLscene is a free code library. I will continue checking. There are so many Delphi codes using Delphi + GLSceme that I imagine that someone found a solution for this. Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted March 27, 2020 Share Posted March 27, 2020 9 minutes ago, SergioFeitoza said: Thank you ASLAN. Could you please tell me what is d3. If there are ganes running in the browser it is possible to create something like a wrapper for GLScene GLscene is a free code library. I will continue checking. There are so many Delphi codes using Delphi + GLSceme that I imagine that someone found a solution for this. d3 is a GL library for the web. Can you please share a photo that is your goal to achieve? Link to comment Share on other sites More sharing options...
SergioFeitoza Posted March 27, 2020 Author Share Posted March 27, 2020 Hi ASLAN Yes I can show. Maybe you gave me the "path of the stones". GLscene also came from OPENGL . It is an OPENGL for Delphi. I will check tomorrow but maybe D3 is what I am looking for . What I need to do with 3D is simply to visualize some figures in 3D . I do need to do animations Although it is great to do them with GLScene. Take a look in the figure attached I produced them with GLScene. This is what I want to do . If you need any info more just ask me Link to comment Share on other sites More sharing options...
SergioFeitoza Posted March 27, 2020 Author Share Posted March 27, 2020 I went to https://d3js.org/ By the figures I saw there, in the same way Unigui is a kind of "Delphi for the Web", D3 is the predecessor (like OpenGL) of the library (in Delphi and not C++) I need Link to comment Share on other sites More sharing options...
DFong Posted March 28, 2020 Share Posted March 28, 2020 You can try using WebGL https://get.webgl.org/ Link to comment Share on other sites More sharing options...
SergioFeitoza Posted March 28, 2020 Author Share Posted March 28, 2020 Thank you DFong . I will check WEBGL today. Seems that WebGL advanced a lot and I am not updated Link to comment Share on other sites More sharing options...
SergioFeitoza Posted March 28, 2020 Author Share Posted March 28, 2020 I cheked both D3 and WebGL doing a fast view of the demos. To try to convert my Delphi + GLscene code I am trying to create an association between these two tools and the codes I am used with (Delphi +GLscene). My question is : do you know any small code , as simple as possible, using Delphi to call D3 or WebG ?. If I see something like this possibly I will advance alone after. Link to comment Share on other sites More sharing options...
DFong Posted March 28, 2020 Share Posted March 28, 2020 I've only run WebGL with UniGUI by creating my own scenes via HTML and running them in a TUniHTML component. Within that HTML, you can insert Ajax events triggered by click actions etc. within the 3D scene to communicate with UniGUI on the server-side. Here's a basic example of rendering a 3D scene in HTML. Good luck! <head> <style> body { background: #333; overflow:hidden; } </style> <script src="files/three.min.js"></script> <script src="files/Detector.js"></script> <script src="files/OrbitControls.js"></script> <script> function drawCube() { if ( ! Detector.webgl ) Detector.addGetWebGLMessage(); var width = window.innerWidth; var height = window.innerHeight; // create a scene var scene = new THREE.Scene(); scene.fog = new THREE.FogExp2( 0xe5f3ff, 0.002 ); // renderer (canvas) var renderer = new THREE.WebGLRenderer({antialias: false}); renderer.setClearColor( scene.fog.color, 1 ); renderer.setSize( width, height ); body.appendChild( renderer.domElement ); // set a camera var viewAngle = 80; var aspect = width / height; var near = 1; var far = 1000; var camera = new THREE.PerspectiveCamera( viewAngle, aspect, near, far ); camera.position.z = 500; controls = new THREE.OrbitControls( camera ); controls.damping = 0.2; controls.addEventListener( 'change', function(){renderer.render( scene, camera );}); scene.add( camera ); // Grid var size = 500, step = 50; var geometry = new THREE.Geometry(); for ( var i = - size; i <= size; i += step ) { geometry.vertices.push( new THREE.Vector3( - size, -100, i ) ); geometry.vertices.push( new THREE.Vector3( size, -100, i ) ); geometry.vertices.push( new THREE.Vector3( i, -100, - size ) ); geometry.vertices.push( new THREE.Vector3( i, -100, size ) ); } var material = new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.2 } ); var line = new THREE.Line( geometry, material ); line.type = THREE.LinePieces; scene.add( line ); // set a directional light var directionalLight = new THREE.DirectionalLight( 0xffffff, 5 ); directionalLight.position.z = 3; scene.add( directionalLight ); // cube geometry (200 x 200 x 200); var geometry = new THREE.CubeGeometry(200, 200, 200); var material = new THREE.MeshPhongMaterial( { color: 0x660000 } ); var cubeMesh = new THREE.Mesh( geometry, material); cubeMesh.position.set(-200,0,0); scene.add( cubeMesh ); renderer.render( scene, camera ); } </script> </head> <body> <button type="button" onclick="drawCube()">Draw Cube</button> </body> Link to comment Share on other sites More sharing options...
SergioFeitoza Posted March 28, 2020 Author Share Posted March 28, 2020 Thank you very much DFong. I think I understtod your idea. I will study it and will post here soon. Link to comment Share on other sites More sharing options...
Recommended Posts