• Welcome to Jose's Read Only Forum 2023.
 

The Viewer Project

Started by Charles Pegge, August 23, 2007, 08:56:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Charles Pegge


This is a continuation of the Viewer2 project which demonstrated a variety of Opengl techniques to display moving, colliding objects, 3d object picking and an enlargeable GUI.

This project starts with the incorporation of the $ script engine, which carries out its work in between frames.

I will post frequent updates in the ZIP file below replacing previous versions as the project progresses, and just make 'news' postings as features are added or modified.

The zip includes the source code, resources and windows executables needed to run the program without compilation.
The script engine source for the &.dll  is available separately on this board.

In the coming weeks, I hope to make the code much clearer and more modular, so that the components may be extracted and made use of with a minimum of entanglement.

So, with this one, I am putting myself in a glass box. :)


Charles Pegge

#1
Embedding the $ Script Engine

Today's effort was to take $ and incorporate it into the original viewer2 frame cycle and do a few tests to establish basic functionality.

There have been no fundamental changes to the original viewer code. It runs autonomously, but the script engine does its work by controlling the linked variables - a bit like the brain and the body.

The Initialisation code looks like this:
PowerBasic

    #INCLUDE "inc\script\$.INC"                ' Script Engine
....


  'SCRIPT ENGINE

  DIM tp AS GLOBAL table_of_tables_ptr
  tp.ii=tables()
  DIM tb(0) AS GLOBAL table_of_tables AT tp.tp
  DIM vsi(%paramax) AS GLOBAL LONG    AT tb(0).vsi
  DIM vcd(%paramax) AS GLOBAL DOUBLE  AT tb(0).vcd
  i=mains(0) ' initialise and return index to linkable varaibles
  'link some variable arrays to the script engine's variables
  LinkLongs  (i+0,maxob)   ' maximum number of objects
  LinkDoubles(i+1,m(0))    ' mass
  LinkDoubles(i+2,s(0))    ' size
  LinkSingles(i+3,cl(0,0)) ' color


The Frame Cycle code looke like this:

IF vcd(10)<>1 THEN mains(0) ' script


and here is the test script, which reads the mass,size and color of the moving objects then turns object no.5 a grey color.



  '========================'
  |  $ script for Viewer5  |
  |  23 Aug 2007           |
  |  Charles E V Pegge     |
  '========================'

'============================|
                             |
function main()              | starting function
                             |
state()                     | obtain state of engine including index of next available
                             | local variable @16
new maxob,mass,size,rgba    |
                             |
set @10=2; @16              | trigger a suspension at the end of this line and return @16
                             | which provides the index for linking to our local variables.
-----------------------------|
' Host operations ...Reentry |
-----------------------------|
                             | firsr execute any commands inserted by the host
                             |
new i=1                     | check interface by displaying some values in the log (log.txt)
                             |
numbers ("3")               |
{                           |
  $ `i` `mass[i]`  `size[i]`  `rgba[i*4]` `rgba[i*4+1]` `rgba[i*4+2]`
  if ++i LE maxob then repeat|
}                           |
'----------------------------|
i=5*4 // r g b a            | set object object 5 color to grey
rgba[i+0]=.5                |
rgba[i+1]=.5                |
rgba[i+2]=.5                |
                             |
"okay"?
end function                 |
                             |
'============================|
                             |
                             |


Kent Sarikaya

Charles your viewer is something else!! Whenever I play with it I am amazed!!

I have been trying to figure out what $ since I have been seeing the posts. Why the need for $? Just for fun and to do something like it?

Also, what advantages does using $ to do things for you compared to powerBasic or freeBasic? Sorry for my ignorance and easily confused state, but I get like that very easily anymore it seems :)

I am going to tap into those great controls of objects with the mouse routines you wrote. It just works so well!! I have a lot to learn till I get to it, but it is in my mind. Thanks again!

Petr Schreiber

Thanks for the update Charles,

very interesting !


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

psch.thinbasic.com

Charles Pegge

Why $?

Thanks for raising the questino Kent. It's really an experimental language, which I use to try out new ideas. It evolved form a Dbase3 like system, which I deployed when I used to work for an organisation called Intermediate Technology Developemnt Group, where it saved a small fortune in license fees and also integrated nicely with WordPerfect. As far as I know, the system remained in use till around 2000.

$ however is a minimalist language, with most of its Dbase trappings stripped away. I am always trying to find ways of making it simpler, smaller while improving its functionality. One feature in particular is its use of XML-like markup to define objects with unlimited extensibilty, which I think will be very useful for games and simulation. This sort of thing is hard to achieve with raw compiled basic or C++ for that matter. I hope to illustrate this with my dome-designing project, which generates X3D models of dome frames and cladding and the lists of components and the dimensions for building them.

I'll create another glass box for this project.


Kent Sarikaya

So $ can also be a stand alone language and not tied into a compiled language?

Anyways, whatever magic it performs you are putting out great stuff, thanks, really enjoying them!