Recent

Author Topic: [Solved]3D Graphics  (Read 5137 times)

Arctic_Eddie

  • Jr. Member
  • **
  • Posts: 91
[Solved]3D Graphics
« on: February 03, 2016, 04:01:19 pm »
I'm working on a project to display phased array sonar data. I need to show a map of the lake bottom with left/right in the horizontal axis, front/back skewed at about 45°, and depth vertical. I've used BGRA several years ago so have some experience there. I also tried OpenGL and never understood how it worked or had any success. Before updating my BGRA package, is this a good one to use for my project?

Thanks
« Last Edit: February 04, 2016, 05:49:30 pm by Arctic_Eddie »

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: 3D Graphics
« Reply #1 on: February 03, 2016, 08:09:49 pm »
It depends if you need to refresh the 3d scene in real-time or not.

BGRA can be used to generate one 3d scene and render it once. Well you can render more times, but it is not very fast. You can have a look at some examples to see if the speed is sufficient for your need:
https://sourceforge.net/p/lazpaint/code/HEAD/tree/bgratutorial3d/
http://wiki.freepascal.org/BGRABitmap_tutorial_15

If you need real-time update, you would need a library dedicated to 3d graphics using OpenGL.
Conscience is the debugger of the mind

Arctic_Eddie

  • Jr. Member
  • **
  • Posts: 91
Re: 3D Graphics
« Reply #2 on: February 03, 2016, 10:14:44 pm »
The update rate is about 3Hz. Most of the image will slide a little bit to the lower-left. The piece that is the oldest at the bottom will be lost. A new piece will appear at the top. Most of the new frame will overlap previous frames and be averaged.

I'll look at the examples in your links and give OpenGL another try. My first attempt a few years ago was a total loss as I never able to add a JPG image onto one of the cube faces as a texture.

Arctic_Eddie

  • Jr. Member
  • **
  • Posts: 91
Re: 3D Graphics
« Reply #3 on: February 03, 2016, 11:04:07 pm »
I tried some of the examples in the first link but many failed to load certain items. The project inspector shows my BGRA package is too old and I may be missing some elements of BGRABitmapPack. I'll update that and try again. The 2D example did run and it alone looks encouraging. It's fast enough and has a skewed, parallelogram window. This is exactly what I need as I'll paint a simulated 3D image on a 2D canvas.

Another related question. My package editor shows I have an older version of BGRAControls1.4 installed but the BGRABitmap6.9 & 7.2 packages are in the other window on the right. To update both packages, BGRABitmap8.7 and BGRAControls3.6, do I overwrite both or move the BGRAControls to the right window then compile/install both of the new ones.

PS
The second link, 3D example, looks even more encouraging.
« Last Edit: February 03, 2016, 11:09:20 pm by Arctic_Eddie »

Arctic_Eddie

  • Jr. Member
  • **
  • Posts: 91
Re: [Solved]3D Graphics
« Reply #4 on: February 04, 2016, 05:48:31 pm »
 :D
Problem is solved, thank you Circular. Initially, most of the examples in the first link did not run as my BGRA package was too old. I've just finished an update to V3.6 Controls and V8.7 Bitmap. Most examples run with a few complaining that a unit could not be found. After looking at the 3D examples, I'm somewhat overwhelmed as to the capabilities of the BGRA package. This will be more than adequate for my needs.

Thank you again, Circular.

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: [Solved]3D Graphics
« Reply #5 on: February 04, 2016, 08:20:19 pm »
Cool  :)

Indeed, new versions are produced mostly to incorporate new features.

If you have a question on something particular you would like to do, or some particular function, feel free to ask about it here.

Regards
Conscience is the debugger of the mind

Arctic_Eddie

  • Jr. Member
  • **
  • Posts: 91
Re: [Solved]3D Graphics
« Reply #6 on: February 04, 2016, 08:53:31 pm »
Thanks for the offer and I'll likely need some help. For now, I'll be studying the 3D code to learn as much as I can.


Arctic_Eddie

  • Jr. Member
  • **
  • Posts: 91
Re: [Solved]3D Graphics
« Reply #7 on: February 05, 2016, 03:07:52 pm »
Circular
I'm not sure that 3D is going to solve my problem. Let me explain how the data is collected and organized.

This is a phased array sonar on a radio controlled twin pontoon barge, about four feet long. A single TX module, 50W 40KHz ultrasonic cleaning tank transducer, sends a burst downward in a 60° cone. Four RX sensors arranged around the TX in a diamond shaped pattern about one foot square collect the echo data using four Arduino Nanos running PlainADC at 51.2KHz. They are each triggered by a common interrupt to all four Nanos. Each set of 512 uint16_t is accumulated in an Arduino Mega2560 via I2C running at 800Kbps. The Mega sends it to a shore station, another Mega, by NRF24. That Mega sends it to a laptop via UART at 1Mbps. In the laptop, it is stored in:

sonarArray   :Array[1..NUM_SONAR, 0..TSAMPLES] of Word;

The 3D examples I saw are all textures painted on surfaces. I need to see a translucent volume simulated in 2D. At this point I envision analyzing the data by creating 512 horizontal slices. The i'th indexed data from each sonar will create a slice showing the presence or absence of an object. Signal strength will determine the rainbow color of a pixel in that plane from faint blue for weak to medium red for strong. The slices will be stacked in 2D, rotated and tilted, to simulate a 3D stack effect showing volume. The viewing position will be to the back-right of the barge and looking downward at 45°.

Does this sound do-able in 2D BGRA? One of the 2D examples shows a canvas that appears to be viewed from this position.



CaptBill

  • Sr. Member
  • ****
  • Posts: 435
Re: [Solved]3D Graphics
« Reply #8 on: February 05, 2016, 04:25:09 pm »
I think you are on the right track by doing 2d slices. This is how DICOM files are arranged used for cat scans and 3d volumes in the medical field. Search for 'dicom viewer'. There is a good one done with bgrabitmap too.

Cool project. Is it opensourced?

Arctic_Eddie

  • Jr. Member
  • **
  • Posts: 91
Re: [Solved]3D Graphics
« Reply #9 on: February 05, 2016, 06:29:37 pm »
The 2D BGRA slice possibility is encouraging. I can somewhat envision how to do it and your suggestion will be checked this afternoon. I am attempting to do a CAT scan of the lake from surface to bottom so the intent is similar. The purpose of this project is to find the bodies of drowning victims and other evidence for local law enforcement agencies. The boat has been referred to as the Body Barge but that will change as surviving family members will be there on the shore waiting for some news.

I'll look at the 2D examples again and try stacking some tinted slices onto a virtual screen. Thanks for the heads-up on Dicom.

The project might go open source but will take some time to document. It uses one laptop and eight Arduinos, six for the sonar part and two dedicated to barge motion control via twin water jet using bilge pumps.


 

TinyPortal © 2005-2018