PDA

View Full Version : TBGL-DisplayList-Tinker-Tool



ReneMiner
06-11-2012, 23:57
I proudly present: my first thinBasic-3d-program

it's called "DisplayList-Tinker" and currently just of use to people which program TBGL-applications, so I serve the whole code uncompiled, plain and straight to be used and changed by tB-users needs - I got myself tB for free - the best basic-language I've ever had in all my life - so what's the deal? that's the least I can give back:

What for:

DLTinker allows to create meshes and helps to create displaylists visually instead of typing them in.
You can create colored symbols, arrows and all that stuff that might be needed for a 3d-gui, just all the things you create display-lists for.

Functions overview:

Draws shapes:
- triangles
- parallelograms
- boxes
- tubes
- discs (=cones)
- rings

Special tools:
- mirrored drawing functions
- pull vertices
- grab vertices (very special, you have to try out!)

Clipboard:
- copy your mesh or parts of it to clipboard
- insert clips rotated, rescaled = draw clips

Load and Save:
- to *.dList-file
plain thinBasic-code that you can open with any text-editor to copy it instantly to your script
Save:
- to *.m15-format

Undo-Redo:
- of course!
- almost unlimited (limit is the capacity of your hard-drive)

At the time it's restricted to no use of textures.
self-explaining, on-screen-console, help-on-board

You do not need to click any menus or buttons! Just use the "buttons" of your keyboard and access all functions without searching for the right switch in some hidden submenu

Additional shipped:
- DisplayListLoader-Function to use displaylist-files due runtime.

Have fun,
suggestions welcome :D

EDIT: New Version, 21.11.2012

ErosOlmi
07-11-2012, 00:16
Rene ... WOW :o
I'm not an expert in 3D but wow.

I played with LOAD command plus some CTRL and/or SHIFT movements arrow key or mouse. Great.
Command system and onscreen help is very nice.
All is moving and running fine.

The only problem is that the main WHILE/WEND loop is very CPU intensive but this can be in some way reduced in future versions. Maybe Petr can help on this.

Thanks a lot for this great present.
An image is better than 1000 words

ReneMiner
07-11-2012, 00:54
you see, the answers you all gave me to those countless questions had their reason and I made the best of it since I use thinBasic for three or four weeks now...
There's still a few things that I want to build in, maybe some 3D-fonting-function, so you type letters into 3d-screen, or a clipboard would be handy, but the add-file function does at least a little bit of that :)
Terrain-Builder would also be possible, but I think that needs textures...

One question, how is that? I have a german-layouted keyboard, so I don't know if all keys work for everyone. but you can always exchange them yourself to meet your needs, would just be interesting to know...

EDIT:
FOUND BUGS!
I have re-uploaded it (see first post), one is still in there but's just because I'm used to 0-based arrays. on program-end it does not delete the last undostage :oops:

Petr Schreiber
07-11-2012, 10:12
Rene,

congratulations on great program, really well done! I like how it leads the user, so everything is under control. And I like the fullscreen viewport approach, I used it previously in ThinEdge and ModelEd too - it gives the artist more space to look at.

Regarding the CPU usage - you might consider using periodic function approach instead of While/Wend.

How does it work? Instead of doing infinite loop, it launches the render function in discrete time intervals using internal timer.
Little example on this is posted here (http://www.thinbasic.com/community/showthread.php?9811-Back-to-the-future-little-taste-of-new-TBGL&p=74175#post74175).

Another factor improving CPU footprint could be enabling V-sync, you can do it from TBGL like:


TBGL_UseVsync(1)


This makes sure the drawing is not done faster than refresh of the screen.


Petr

ReneMiner
07-11-2012, 14:42
thanks for your advice, I've already changed that and built the periodic call in but it's really too slow...

Now I experience some strange behaviour:

if I set the interval of the periodic call less than 20ms it crashes complaining some variable has already been defined.
it does not if i set it to 20 ms! why is that? I wanted to set it on 16 so it goes together with 60Hz and VSync, 20 feels so wobbly. how can I prevent the crash if it doesnt finish the mainloop whithin in 20 ms? that might very well be if one has some hundred vertices on screen and uses a function like "sort all triangles".

I' will add some rotation and starting a clipboard function today, i dreamed last night how to...

Michael Clease
07-11-2012, 15:46
Hello Rene,

When you use the timer function I find its important to kill the timer on the way into the routine and create a new one on the way out. If you don't do this the timer routine would have multiple calls while the old routine is still running.

This should fix it.


Case %WM_TIMER
If CBWPARAM = %IDC_TIMER Then
Dialog Kill Timer CBHNDL, %IDC_TIMER
Do_my_stuff_here()
Dialog Set Timer CBHNDL, %IDC_TIMER, %TIMER_DELAY
End If

ReneMiner
07-11-2012, 15:54
it's not the regular timer-function that I used but a tbgl-specific one, i used this



TBGL_BindPeriodicFunction( hWnd, "Main_Sub", 20 )

TBGL_ProcessPeriodicFunction(hWnd)


now i went back to some good old While-Wend and count sheep, is there a "tbgl-do-OS-Events" that I can call if running windowed?

Michael Clease
07-11-2012, 15:57
from the help

To stop periodic execution from inside of called procedure, you should call TBGL_UnBindPeriodicFunction

ReneMiner
07-11-2012, 16:02
thanks Michael, that works fine now. can go back to work now and add some new tools to the program :)

Michael Clease
07-11-2012, 16:08
No problem, its given me a new direction for my simple level scroller script I've been working on and will release for anyone to use V. soooooon.


Mike C.

ReneMiner
08-11-2012, 19:59
New version of DLTinker attached to first post (http://www.thinbasic.com/community/showthread.php?11938-TBGL-DisplayList-Tinker-Tool) of this thread.


I had some major problem, but that is solved now through some workaround. I will create an issue (http://www.thinbasic.com/community/project.php?issueid=367) for that.

btw.: I want you to get your eyes on this: http://www.thinbasic.com/community/project.php?issueid=364#note2286

ErosOlmi
09-11-2012, 07:49
Issued replied, but I was not able to replicate reported problem.

ReneMiner
20-11-2012, 18:58
There's a new Version of DL-Tinker ( first post (http://www.thinbasic.com/community/showthread.php?11938-TBGL-DisplayList-Tinker-Tool) of this thread) due I had to fix some bug caused by this:

( http://www.thinbasic.com/community/project.php?issueid=372 )

and some of my own that affected drawing of discs and cones that are not centered at 0,0,0.

Edit:
-added rounding and merging functions for vertices,
-fixed uneven start-end-pos-vertex for circular shapes that made vertex-normals at seams look odd sometimes.