• Welcome to Theos PowerBasic Museum 2017.

BassBox

Started by Patrice Terrier, October 08, 2007, 10:57:44 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Patrice Terrier

#165
This patch applies to BassBox BBplugin.inc.

There are two new procedures: BBP_GetReg and BBP_SetReg.

They are being used in PLUG007.BAS to save CX, CY, CZ coordinates to retrieve the current settings between sessions or while switching from one plugin to another.

In the BBP.Init message:

'        // Retrieve CX, CY, CZ from registry
         sDataString = BBP_GetReg(0, $RegistryKey, $RegistryPluginCXYZ)
         IF PARSECOUNT(sDataString) = 3 THEN
            Cx = VAL(PARSE$(sDataString, 1))
            Cy = VAL(PARSE$(sDataString, 2))
            Cz = VAL(PARSE$(sDataString, 3))
         ELSE
            Cx = -499: Cy = -180: Cz = -23
         END IF


In the BBP.Destroy message:

         '// Save CX, CY, CZ to registry
         IF CX OR CY OR CZ THEN
            sDataString = STR$(CINT(CX)) + "," + STR$(CINT(CY)) + "," + STR$(CINT(CZ))
            CALL BBP_SetReg(0, $RegistryKey, $RegistryPluginCXYZ, (sDataString))
         END IF


Like in PLUG005, now you can reset PLUG007 CX, CY, CZ to their default values, using the "space bar".

See below the attached BassPatch40.zip

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Kent Sarikaya

Downloaded and enjoying the latest version, thanks guys.

I was wondering, is it better to store things in the registry or in an ini file where the main app is located? I was just wondering how you determine when to use which.

Patrice Terrier

--Kent

Using the registry, then no need to check first if we are running from a writable media (CD/DVD).
As an alternative you could use the "temp" folder for that purpose (because "temp" folder is always on a writable media).

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Kent Sarikaya

Thanks Patrice, never thought about writable media or not to save... learn something new each day, thanks.

Charles Pegge

Picking individual objects in space is fundamental to computer games and 3D CAD. Because the relationship between the projected image in pixels and the spatial co-ordinates of objects is so complex, Opengl provides a special rendering mode to collect the names of objects whose surfaces project onto the mouse pointer position. In the case of overlapping objects, we choose the one which has a surface with the smallest z distance from the view plane.

When the left mouse button is clicked, the x y position is stored and  a flag is set to initiate this special render, which is executed on the next rendering. Nothing gets written to the frame buffer until the normal rendering mode is restored, and the view construction procedes in the normal way.

If  an object has been succesfully picked the the mouse movements are used to alter its rotational or translational displacement.




You can pick the forground objects on move them in various ways with the mouse.

By clicking anywhere in the scene, rotation can be started and stopped.

By dragging on the backgoround all the forground objects move together.

Patrice Terrier

-- Charles,

That's a very interresting OpenGL feature, I didn't know it.

Thank you.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Charles Pegge

Patrice, It is possible to implement a complete GUI within Opengl, with all 3D components - even the individual characters in a text can be identified with this technique, so one could, if so desired, design a complete word processor, as well as innumerable varieties of switches, levers, dials and joysticks.

Kent Sarikaya

This is stuff I need to really brush up on, thanks Charles!

Patrice Terrier

#173
--Charles

Indeed I knowed already that we could do amazing things with OpenGL, this is the reason why I have asked Ryan Cross if he would like to join the fun  8)

He is a great designer and he does already a complete GUI written entirely in OpenGL, as you can see it there:

Quote
I do a lot of 2D graphics in OpenGL, I have never used DirectX.

To render sprites in OpenGL you draw them as textured quads, so its a little different than using GDI. OpenGL does not have its own native functions to load any type of image format. You must either write your own or use a compatible library. I wrote my own function that loads 32-bit alpha blended PNGs (I got some help from Patrice on it).

I used to use GDI(+) for a lot of my graphics, but ever since I switched to OpenGL I have never looked back. Blazing fast compared to GDI.

(Please note: this is a work in progress and is for a full touch screen application, many of the icons are place holders)

Some screen shot examples of what he is currently working on:













Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Petr Schreiber

Hi Charles,

very nice ! It is also possible to pick object using less comfortable way ( but without need to enter special mode ).

- Store somewhere clickable objects position and bounding volume parameters ( in UDT for example )
- use glReadPixels and gluUnproject to get clicked 3D coordinate:
Quote
glReadPixels( winX, winY, 1, 1, %GL_DEPTH_COMPONENT, %GL_FLOAT, winz ) ' -- WinZ will be retrieved BYREF

' -- Get OpenGL matrices
glGetIntegerv(%GL_VIEWPORT, viewport(0) )
glGetDoublev (%GL_MODELVIEW_MATRIX, mvmatrix(0))
glGetDoublev (%GL_PROJECTION_MATRIX, projmatrix(0))

' -- Unproject coordinate to BYREFed dX, dY, dZ
gluUnProject (winX, winY, winZ, mvmatrix(0), projmatrix(0), viewport(0), dX, dY, dZ )';
- Then test is picked point( dx, dy, dz ) is inside bounding volume

Patrice, Ryan Cross's OpenGL GUI looks very tasty, really best I have seen so far. Did he accepted the invitation ?


Bye,
Petr
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Charles Pegge

Patrice, The Ryan Cross controls are superb. They not only look good but also have great visual clarity. The controls have soft edges that allow the eye to focus on the essential content at the centre of each control.

With textures, you can resolve many of the jagged edge problems that often occur using color and vertices alone.


Thanks Petr, that is computationally less expensive. The advantage of the named objects method is that you are not dependent on evaluating a bounding volume to identify the object. Even if you have several spaghetti monsters fighting each other, you will be able to pick one from the others, assuming you can catch one of its tendrils.

Kent Sarikaya

Petr has been telling me about making GUI's with openGL, and even made nice examples. I will need to listen to him more :) 
Those pictures of the gl gui are very very nice and motivational.

Charles and Petr, Ok, which system of picking should I use? Let's have a battle of the picking systems demo :)

Patrice Terrier

Not to fool you, most of the drawing are done with PhotoShop then saved as PNG files and translated into OpenGL texture to be used as background or textured sprite objects.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Charles Pegge

Kent,
Petr's method returns positional information. This is fine if you know which control is where in space, but if the spaghetti monster steals  your hypertransport console, taunting you by waving it about in the air, it is going to be very complicated to work out the spatial position. Its tentacles gyrate through several rotation, translation and scaling transforms, and unless you have done all the calculations yourself, only Opengl knows where your console is. If it gets swallowed, Opengl will also know that it is now located inside the monster and is no longer accessible to you, even if you can accurately point to where it has gone.

Kent Sarikaya

I like that description a lot Charles and that sort of accuracy is something else :)