* * *

Author Topic: BGRABitmap Helix  (Read 1591 times)

scons

  • Jr. Member
  • **
  • Posts: 95
BGRABitmap Helix
« on: February 25, 2017, 12:46:14 pm »
Hi all,

Question:
Can you display a Helix with this module (at least 1 revolution), then divide (put X-number of points) the length of this curve and export this data (length of curve, x-y-z coördinates of start + endpoint + all created points in between) ?

Tricky (maybe) part is to display in runtime the Helix + points in a 3D-view (turntable wise) or seperate 2D-views (front/top/bottom).

I was wondering if this can be done... think so, although not sure.

Thanks
Windows 10-64bit Lazarus 1.6.4 FPC 3.0.2

lainz

  • Hero Member
  • *****
  • Posts: 1978
  • Nace una flor, todos los días sale el sol...
    • BGRABitmap
Re: BGRABitmap Helix
« Reply #1 on: February 25, 2017, 01:09:56 pm »
There's support for SVG and 3D so yes you can, the problem is how.

3D Rotation is supported also.

I don't know how to do it also, but must be possible.  :'(

circular

  • Hero Member
  • *****
  • Posts: 2594
    • Personal webpage
Re: BGRABitmap Helix
« Reply #2 on: February 25, 2017, 09:29:21 pm »
You can display a 3D object and rotate. However you need to build the object. So you need to formula of a helix, which is rather simple, it is a circle in (x,y) and the coordinate z proportional to the angle. However if you want to display in wireframe, you would need to override the rendering and draw the lines using the projected 2D coordinates.

To see a sample of 3D rendering, I suggest you look at /test/bgratutorial3D folder (in repository or in zip file).

To override the rendering, look for example in ex1.pas. You can override Render or RenderGL (if you want to use OpenGL rendering but that's probably not great because lines are not antialiased).

After calling inherited Render, the vertices will have their coordinates computed so you can use them to draw lines.

In the Create method of the scene, you can see how the 3D object is created. The vertices are of type IBGRAVertex3D. They have a property called ProjectedCoord which contains their 2D coordinates.
Conscience is the debugger of the mind

scons

  • Jr. Member
  • **
  • Posts: 95
Re: BGRABitmap Helix
« Reply #3 on: February 26, 2017, 03:25:07 pm »
Oke thanks guys, no I can do a focused search.
Windows 10-64bit Lazarus 1.6.4 FPC 3.0.2

scons

  • Jr. Member
  • **
  • Posts: 95
Re: BGRABitmap Helix
« Reply #4 on: March 01, 2017, 02:05:18 am »
oke, started on the 2D layout and a question popped up:

When I use the openspline function, it draws a closed spline ??

Code: Pascal  [Select]
  1.   ctx.moveTo(0, 0);
  2.   ctx.beginPath;
  3.   setlength(pts,11);
  4.   pts[0] := PointF(-150,150);
  5.   pts[1] := PointF(-140,110);
  6.   pts[2] := PointF(-110,70);
  7.   pts[3] := PointF(-70,50);
  8.   pts[4] := PointF(-30,20);
  9.   pts[5] := PointF(0,0);
  10.   pts[6] := PointF(30,-20);
  11.   pts[7] := PointF(70,-50);
  12.   pts[8] := PointF(110,-70);
  13.   pts[9] := PointF(140,-110);
  14.   pts[10]:= PointF(150,-150);
  15.   ctx.openedSpline(pts,ssInside);
  16.   ctx.closePath;
  17.   ctx.stroke();
  18.  

What am I doing wrong ? I want to get rid of the straight line in the front view that connect the start and endpoint of the spline.

I can not seem to find much info about this spline draw function.

Thanks
Windows 10-64bit Lazarus 1.6.4 FPC 3.0.2

scons

  • Jr. Member
  • **
  • Posts: 95
Re: BGRABitmap Helix
« Reply #5 on: March 01, 2017, 11:17:02 am »
Oke, don't know if it is correct but this did the trick: slice

Code: Pascal  [Select]
  1.   ctx.openedSpline(slice(pts,11),ssCrossing);
  2.  
Windows 10-64bit Lazarus 1.6.4 FPC 3.0.2

circular

  • Hero Member
  • *****
  • Posts: 2594
    • Personal webpage
Re: BGRABitmap Helix
« Reply #6 on: March 01, 2017, 11:31:36 am »
Hmmm I suppose it is rather because of closePath. This asks to draw a line from the current point to the beggining of the path. Otherwise you don't need to call closePath.

But you still need to call beginPath to clear the content of the path when you start a new path.
Conscience is the debugger of the mind

scons

  • Jr. Member
  • **
  • Posts: 95
Re: BGRABitmap Helix
« Reply #7 on: March 01, 2017, 11:38:54 am »
Hah you're right, removing the closePath also opens it. I was looking for a solution in the wrong direction.

Thanks
Windows 10-64bit Lazarus 1.6.4 FPC 3.0.2

circular

  • Hero Member
  • *****
  • Posts: 2594
    • Personal webpage
Re: BGRABitmap Helix
« Reply #8 on: March 02, 2017, 06:44:43 pm »
You're welcome
Conscience is the debugger of the mind

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus