15,877,915 members
Articles / Multimedia / OpenGL

# Explore 3D

Rate me:
15 Aug 2013CPOL7 min read 24.4K   4   6
OpenGL based 3D learning software

## Explore 3D Desktop Software

Explore 3D software would target the Education catagory for use on Windows 8 tablet PC's. Its purpose would be to allow students (and adults) to explore 3D from a lower level, allowing them to work with 3D using a 3D scripting language, as well as using drag and drop via touch or the mouse.

The purpose would be to help students grasp basic concepts about 3 dimensional modeling. This would be accomplished via two different approaches in the software.

First, would be a low level 3D primitive definition scripting language. This would allow students to define simple 3D models by combining multiple 3D primitives together. This would allow students to better appreciate how 3D objects are defined in a 3D coordinate system (X,Y,Z) using 3D coordinates they can type in. The objects can be combined to create more complex models.

For example using very simple 3D primitives more complex models can be created.

Here is a simple script which defines the model above using 3D primitives:

VB
```{P}1(-75, 40,-200)  2(-75, 40,200)  3(-75, 40,0)
4(-75,-30,-200)  5(-75,-30,200)  6(-75,-30,0)
7(100,-30,0)     8(-100,-30,0)   9(-180,-30,0)
10(190,0,0)      11(-120, 5,150) 12(-120, 5,-150)
13(-20, 5,150)   14(-20, 5,-150) 15(-120, 5,50)
16(-120, 5,-50)  17(-20, 5,50)   18(-20, 5,-50)
19(175,-30,-75)  20(175,-30,75)  21(175,-30,0)

WINGS:

{W}(1,.05,1)
{M}(1)
{C}(100,100,30,10,400,3)
{X}(1){D}(100,0,30,10,1)
{X}(0){D}(100,0,30,10,2)
{C}(100,100,30,10,400,6)
{X}(1){D}(100,0,30,10,4)
{X}(0){D}(100,0,30,10,5)

TAIL:

{W}(.5,.05,1)
{C}(100,100,30,10,150,21)
{X}(1){D}(100,0,30,10,19)
{X}(0){D}(100,0,30,10,20)

FUSELAGE:

{M}(2)
{W}(.5,.6,1)
{X}(2){C}(50,10,30,10,250,7)
{X}(2){C}(50,50,30,10,150,8)
{X}(0)
{W}(2,.6,.5)
{S}(50,12,12,9)

RUDDER:

{W}(.6,1,.1)
{S}(50,12,12,10)

WING STRUTS:

{W}(1,1,1)
{X}(4)
{M}(3)
{C}(3,3,6,6,78,11)
{C}(3,3,6,6,78,12)
{C}(3,3,6,6,78,13)
{C}(3,3,6,6,78,14)
{C}(3,3,6,6,78,15)
{C}(3,3,6,6,78,16)
{C}(3,3,6,6,78,17)
{C}(3,3,6,6,78,18)```

First by defining coordinates for points and then using those points to define triangles, quads (rectangles), disks, spheres and cylinders, a more complex model can be created. Material ID's can defined, as well as scaling and rotation for some objects.

STL 3D prototyping models

To better appreciate how powerful 3D is, the second feature of the software would be the ability to display complex 3D models in the STL file format. Unlike 3D model formats used in games which literally "fake" realism by using low polygon count models with high quality texture maps, the STL file format is designed to display high polygon count models which gain realism simply from the high polygon count, even when just a single color. STL format is used in rapid prototyping in 3D printing. While the initial design of this software will only be for display of STL models, future versions could take advantage of the 3D printing features soon to be added to Windows 8.1. For this contest though, only display will be supported.

The software would be designed to support fast loading and display of high polygon count STL models, even on minimal hardware such as the Atom CPU used in many Windows 8 tablets. The software would be able to load and display 3D models with hundreds of thousands polygons (triangles) in a few seconds. Even models with a few million polygons will be able to be loaded and displayed in a very reasonable amount of time. For example, when tested on a legacy PC with a 3.2 ghz Pentium D CPU (dual core) with a common \$50 range, off the shelf, 3D video card, a 3D model with over 2 million polygons can be loaded in less than 5 seconds and display instantly (a few frames per second).

## Goals

The software would encourage interest in and a better understanding of 3D modeling from a more practical perspective. Rather than from a gaming perspective, it would encourage the use of 3D modeling in business and education (practical uses). The low level 3D primitive scripting language would promote a better understanding of 3D coordinate systems and how 3D models are simply made up of many simple polygons. It would also improve understanding of 3D objects in a 3D space (perspective).

The STL 3D portion of the software would build understanding and better appreciation for the use of 3D modeling in practical settings (ie. business, 3D prototyping, 3D printing).

## Development of the software

The software is being developed in two stages. The first stage is basically complete (with just a few minor updates planned to add Windows 8 touch capabilities). The first stage of the software is created using pure WIN32 programming using the PowerBasic native code compiler. This generates 32 bit software capable of directly accessing the native WIN32 API's in Windows. This allows building dynamic software capable of changing itself depending upon which version of Windows it is run on. This means the software will run on all versions of Windows from Windows XP to Windows 8 (actually even earlier versions are supported also).

Stage one is the building of a complete GUI engine which replaces the need to directly access the Windows API. The GUI engine has the following goals:

• run on multiple versions of Windows from XP to Windows 8
• only use the WIN32 APIs so no dot net runtimes required
• designed for minimal hardware (less than 1 gig memory and 1 GHZ CPU or greater)
• no Direct-X required, but based on OpenGL 2.0 standard (for 3D) common to SOCs (systems on a chip)
• designed for minimal hard drive space, especially SSD's (solid state drives)
• core runtime of GUI engine will be about 1 megabyte in size in DLL format (no COM required)
• supports all basic native window classes (controls) including most common controls and richedit
• supports the common dialogs

This GUI engine is designed to replace the need to access the Windows API at all. All GUI functionality for the software is in the GUI engine.

Stage two will be building the actual application using the above GUI engine for all GUI functionality (including OpenGL 3D) using the GUI engine and its own Visual Designer (drag and drop) for code generation, along with the PowerBasic compiler.

The GUI engine used is not a third party tool, but was completing designed from scratch, over the last ten years, by this developer (author of this article) and is a commercial product with proprietary code in it. It was developed using solely the PowerBasic compiler and the Windows WIN32 API (and OpenGL 2.0 API). Because this tool has its own Visual Designer/Code Generator (built using the GUI engine), the application discussed here can be rapidly prototyped in a short time. At minimum, two core runtime DLL's will be distributed with the final application executable, totally less than 1 megabyte in runtimes.

The application will not require any component installations (ie. COM components), nor any Microsoft compiler runtimes, nor any dot.net runtimes. The application will also be transportable, meaning it can simply be copied and run. For example, the application could easily be copied from a hard drive to a USB drive and run from the USB drive. It also should be able to be run even from a Microsoft SkyDrive folder.

The software will be developed using the PowerBasic compiler and EZGUI 5.0 Professional (developed by this author).

## The Code

The intial GUI code (Forms and Controls) will be prototyped using the EZGUI 5.0 Visual Designer (also written by this author). This will allow rapid prototyping of the application. The OpenGL features will be implimented by the glCanvas control in the EZGUI runtime library. This control is a hybrid control which merges a 2D Canvas control with an OpenGL 3D layer on top (for 3D objects). Coding for the glCanvas control is done simply by sending it string commands which contain the built in 3D scripting language supported by the control. Here is some example code from a simple 3D demo I created:

VB
```GLOBAL App_My3DModel\$

SUB InitModel()
LOCAL T\$
T\$="{P}1(-75, 40,-200)  2(-75, 40,200)  3(-75, 40,0)"
T\$=T\$+"4(-75,-30,-200)  5(-75,-30,200)  6(-75,-30,0)"
T\$=T\$+"7(100,-30,0)     8(-100,-30,0)   9(-180,-30,0)"
T\$=T\$+"10(190,0,0)      11(-120, 5,150) 12(-120, 5,-150)"
T\$=T\$+"13(-20, 5,150)   14(-20, 5,-150) 15(-120, 5,50)"
T\$=T\$+"16(-120, 5,-50)  17(-20, 5,50)   18(-20, 5,-50)"
T\$=T\$+"19(175,-30,-75)  20(175,-30,75)  21(175,-30,0)"
T\$=T\$+"{W}(1,.05,1){M}(1){C}(100,100,30,10,400,3)"
T\$=T\$+"{X}(1){D}(100,0,30,10,1){X}(0){D}(100,0,30,10,2)"
T\$=T\$+"{C}(100,100,30,10,400,6){X}(1){D}(100,0,30,10,4)"
T\$=T\$+"{X}(0){D}(100,0,30,10,5){W}(.5,.05,1)"
T\$=T\$+"{C}(100,100,30,10,150,21){X}(1){D}(100,0,30,10,19)"
T\$=T\$+"{X}(0){D}(100,0,30,10,20){M}(2){W}(.5,.6,1)"
T\$=T\$+"{X}(2){C}(50,10,30,10,250,7){X}(2){C}(50,50,30,10,150,8)"
T\$=T\$+"{X}(0){W}(2,.6,.5){S}(50,12,12,9){W}(.6,1,.1){S}(50,12,12,10)"
T\$=T\$+"{W}(1,1,1){X}(4){M}(3){C}(3,3,6,6,78,11){C}(3,3,6,6,78,12)"
T\$=T\$+"{C}(3,3,6,6,78,13){C}(3,3,6,6,78,14){C}(3,3,6,6,78,15){C}(3,3,6,6,78,16)"
T\$=T\$+"{C}(3,3,6,6,78,17){C}(3,3,6,6,78,18)"
EZ_DoGL "DMain", %DMAIN_GLCANVAS1, "NEWMODEL <USER1>"+T\$
END SUB

SUB Change3DStuff()
LOCAL J&
STATIC IFlag&
STATIC Distance!, DPlus!
IF IFlag&=0 THEN
IFlag&=1
EZ_DoGL "DMain", %DMAIN_GLCANVAS1,"LIGHTYX 45,45|
EZ_DoGL "DMain", %DMAIN_GLCANVAS1,"QALL 1|BGCOLOR "+STR\$(RGB(0,32,64))
END IF
IF Distance!=0 THEN
Distance!=20
DPlus!=.1
END IF
Distance!=Distance!+DPlus!
IF Distance!<15 THEN
Distance!=15
DPlus!=.1
END IF
IF Distance!>50 THEN
Distance!=50
DPlus!=-.1
END IF
EZ_DoGL "DMain", %DMAIN_GLCANVAS1,"PERSPECTIVE "+STR\$(Distance!)

STATIC RD!, RD1!
RD=RD+2
IF RD>360 THEN RD=0

RD1!=RD1!+1
IF RD1!>360 THEN RD1!=0

IF EZ_StartGL("DMain", %DMAIN_GLCANVAS1) THEN
EZ_GL "ROTATE 1000,"+STR\$(RD)+","+STR\$(RD)+",0"
EZ_GL "SROTATE 1000,0,"+STR\$(RD1)+",0"
EZ_GL "ROTATE 1001,"+STR\$(RD)+","+STR\$(RD)+",0"
EZ_GL "SROTATE 1001,0,"+STR\$(RD1)+",0"
EZ_GL "ROTATE 1002,0,"+STR\$(RD)+",0"
EZ_GL "SROTATE 1002,0,"+STR\$(RD1)+",0"
EZ_GL "ROTATE 1003,0,"+STR\$(RD)+",0"
EZ_GL "SROTATE 1003,0,"+STR\$(RD1)+",0"
EZ_GL "ROTATE 1004,0,"+STR\$(RD)+",0"
EZ_GL "SROTATE 1004,0,"+STR\$(RD1)+",0"
EZ_GL "ROTATE 1005,0,"+STR\$(360-RD)+",0"
EZ_GL "SROTATE 1005,0,"+STR\$(RD1)+",0"
EZ_GL "ROTATE 1006,0,"+STR\$(RD)+",0"
EZ_GL "SROTATE 1006,0,"+STR\$(RD1)+",0"
EZ_EndGL
END IF
END SUB

SUB InitObjects()
LOCAL J&, T\$, P\$
IF EZ_StartGL("DMain", %DMAIN_GLCANVAS1) THEN
' last paramater of LOADNEW command is as follows:
' 1 - AutoScale to Resize Object to aproximately window size
' 2 - AutoScale and swap X,Y axis
' 3 - AutoScale and swap X,Y axis and autogen Normals
' 4 - AutoScale and autogen Normals
EZ_GL "BGMODE 0"
EZ_GL "MATPAT 990,&H0088FF,100,100,6,0,8"
EZ_GL "DEFPAL 2,81,82,83,84,85,111"
EZ_GL "ADD CUBE, 1000, -100,50,0, 1,1,1,38,0"
EZ_GL "MAT 1000,2,2"
EZ_GL "SCALE 1000,.33,.33,.33"
EZ_GL "ALIAS 1000,1"
EZ_GL "ADD USER1,1001, 125,50,0, 1,1,1,35,1"     ' 81
EZ_GL "SCALE 1001,.5,.5,.5"
EZ_GL "SCALE 1002,3.0,.25,.25"
EZ_GL "WIRE 1002, 1"
EZ_GL "LWIDTH 1002, 3.0"
EZ_GL "ALIAS 1002,1"
EZ_GL "ADD SPHERE_Q,1003,125,-50,0, 1,1,1,89,0"     ' 74
EZ_GL "SCALE 1003,.25,.25,.25"
EZ_GL "SCALE 1004,.25,.25,.25"
EZ_GL "ALIAS 1004,1"
EZ_GL "SCALE 1005,.33,.33,.33"
EZ_GL "WIRE 1005,1"
EZ_GL "ALIAS 1005,1"
EZ_GL "SCALE 1006,.25,.25,.25"
EZ_EndGL
END IF
END SUB
'<<END>>

GLOBAL App_Show3DObjects&
GLOBAL App_3DSpeed&

SUB DMAIN_GLCANVAS1_Events( MyID&, CMsg&, CVal&, Cancel&)
SELECT CASE CMsg&
CASE %EZ_Click
InitModel
Change3DStuff
InitObjects
App_Show3DObjects&=0
EZ_StartPrivateTimer "{ME}", MyID&,1
CASE %EZ_PTimer
IF App_Show3DObjects& THEN
LOCAL N&
IF App_3DSpeed&<=0 THEN App_3DSpeed&=1
FOR N&=1 TO App_3DSpeed&
Change3DStuff
EZ_RedrawControl "{ME}",MyID&
NEXT N&
END IF
END SELECT
END SUB```

Because the OpenGL is implimented via a real custom window class (control), this means the application need not be just a single OpenGL window. The application will be a real multi-windowed application (similar to what one might do with WinForms in a Microsoft language) with as many instances of an OpenGL control as desired. For example a material gallery could be defined using one OpenGL control while another OpenGL control would display the current 3D world and another could be used to display individual models being used. The challenge will be making the user interface comfortable for tablet users and a touch screen. Also the application will be designed to be scalable, utilzing the auto-resize engine built into the GUI engine.

## The Developer

The developer of this software is Chris Boss, owner of a small independent programming tools company which targets PowerBasic programmers. He was first exposed to programming in 1975 and started his own custom programming business in the 1990's. He has been a WIN32 programmer for over ten years now, using PowerBasic and his primary product is the EZGUI development system. EZGUI consists of two parts. First a GUI engine which replaces the need to directly access the WIN32 API's. The engine supports not only all the basic GUI features (forms, controls, common dialogs, etc.), but also supports a built in drag and drop engine (for building visual designers), low level features (ie. subclassing, ownerdraw, superclassing, threads), a number of custom controls including a Canvas control with low level DIB engine and proprietary 2D sprite engine, an OpenGL based Canvas control with a built in proprietary 3D scripting language, an MCI control, Properties Listbox control and more. EZGUI is used by a number of commercial companies for developing commercial software.

Written By
Software Developer Computer Workshop
United States
Chris Boss is the owner (and programmer) of a small software development business in rural Virginia, called the Computer Workshop. For the last ten years or so he has been developing tools for use by Powerbasic programmers (see: http://powerbasic.com ). His main product called EZGUI (Easy GUI) is a high level GUI engine with Visual Designer and code generator. It is in its fifth generation now. He is an experienced Windows API programmer (more low level) and has experience in writing GUI engines (forms/controls), drag and drop Visual Designers, Graphics engines (printing and to the screen) and one of his favorites is a Sprite engine (2D animated movable images). His current project is version 5.0 of his main product EZGUI, adding such features as multi-monitor support, component engine, custom control engine, superclass engine and the latest project a 3D OpenGL based custom control. One of the goals he has is to push the limits of Windows software development, while making it easy, fast execution speed, small footprint (size of executables) and code reusability while providing a more graphic experience in user interfaces, while still being able to write software which can fit on a floppy disk (small footprint), use minimal amount of memory and able to run on multiple versions of Windows from 95 to Win8.

 First Prev Next
 Thumbs Up Manikandan1018-May-14 5:56 Manikandan10 18-May-14 5:56
 Thanks for entering the Intel AIC 2013! Kevin Priddle16-Aug-13 8:47 Kevin Priddle 16-Aug-13 8:47
 Re: Thanks for entering the Intel AIC 2013! Chris Boss16-Aug-13 9:21 Chris Boss 16-Aug-13 9:21
 Re: Thanks for entering the Intel AIC 2013! Kevin Priddle21-Aug-13 6:06 Kevin Priddle 21-Aug-13 6:06
 My vote of 5 DrABELL15-Aug-13 17:04 DrABELL 15-Aug-13 17:04
 My vote of 5 Abhishek Nandy12-Aug-13 22:16 Abhishek Nandy 12-Aug-13 22:16
 Last Visit: 31-Dec-99 18:00     Last Update: 14-Apr-24 10:10 Refresh 1