PDA

View Full Version : qt: Nurbs, Primitives and more



Lionheart008
13-01-2009, 18:28
hi all,

my little question to the mainly programming and core design of thinbasic..

- it's possible to build new primitives (n-gons) or nurbs* (nurbscurves) or subdivision surfaces with one of the next thinbasic releases ???
* nurbs are: "Non-Uniform Rational B-Splines"

- what do you need for this new options to build organic or nurbs forms ???

- I have some special nurbs stuff here around... but don't know how the programming part should looks like... and if it's possible at all... it would be very nice to see one day these feature for thinbasic to build new applications, environments and new 3d worlds :)

- info stuff you can find here for example:
"http://en.wikipedia.org/wiki/NURBS"

good evening, lionheart

ps: you can create with nurbs even hairs or grass or fur ;) see the pictures below
! pps: the green object (left side) included 36 control points to size this nurbs faces on a 2dimensioned ground floor

Petr Schreiber
13-01-2009, 20:56
Hi!,

you can use nurbs even now, they are part of OpenGL library.
I attach 3 samples for you :)

Code is +/- based on RedBook samples.


Petr

P.S. I am not sure whether NURBS are done in hardware or not. Hardcore people use geometry shaders to create NURBS :)

Lionheart008
13-01-2009, 22:59
dear petr, hey, that's really GREAT !!! :-D

Perhaps nobody has checked it here what this example can open new big horizont ;) for tbgl and thinbasic and modeling !!! :) uargh, must laugh ... so in this way we can also modelling in cad mode, isn't it ??? or can build different shapes and bodies...

I have played around (after very stressy squash playing with friends) with the solid example and proof it for improvements...

my new little nurbs-solid example I add here, perhaps you see what can possible with a grid and a solid! :)

I changed the structure with intention to see what happened :D

Many thanks, give you an applause for it !

I would very like to push these new features for next thinbasic releases :twisted:

ciao and servus, Lionheart (Frank)

ps: perhaps we can build here at the board a new "nurbs-modeling modul" ???
pps: I will try to make a new example with tbgl entities structure :)

Michael Hartlef
13-01-2009, 23:34
Cool Petr, you beat me to it. I was looking it up too. :D

Michael Hartlef
14-01-2009, 07:49
ps: perhaps we can build here at the board a new "nurbs-modeling modul" ???

Well, new module? Maybe. What functions do you need?

Lionheart008
14-01-2009, 11:20
Hi michael, good morning! :)
hi petr, hi all:)


Well, new module? Maybe. What functions do you need?

Yes: I will make up my mind to collect some examples to show you what I have in my mind ;) A nurbscurve you can control by drawing (with mousepointer) would be nice by handling the knots (dots) of the curve... like you know it from hexagon or even in 2d mode by corel draw or adobes illustrator.

I can imagine there are much more possibilities to explore with CAD power and TBGL new meshes and open gl features (you can see by the example of the currently nurbs scripts from petr or my example)...

wait a little I need time to collect my ideas and show it with examples :-D

=> I have tried to write a "Bezier curve" script for tbgl, but need help to adept it for thinbasic as I don't know what the tbgl language can translate with open gl libraries power...


'- The following code displays the control points as dots
TBGL_PointSize 5
'-TBGL_LineWidth 5 ' This will set the default line width to 5 pixels
TBGL_Color 255, 0, 0
TBGL_BeginPoly(%GL_POINTS)
for i = 1 to 4
glVertex3fv(&ControlPoints i/0.0) '- this line is a problem ;)
next
TBGL_EndPoly

'void reshape(int w, int h)
'{
' TBGL_Viewport(0, 0, (GLsizei) w, (GLsizei) h);
' TBGL_MatrixMode(GL_PROJECTION);
' TBGL_LoadIdentity();
' if (w <= h)
' glOrtho(-5.0, 5.0, -5.0*(GLfloat)h/(GLfloat)w,
' 5.0*(GLfloat)h/(GLfloat)w, -5.0, 5.0);
'else
' glOrtho(-5.0*(GLfloat)w/(GLfloat)h,
' 5.0*(GLfloat)w/(GLfloat)h, -5.0, 5.0, -5.0, 5.0);
'TBGL_MatrixMode(GL_MODELVIEW);
'TBGL_LoadIdentity();
'}

the first part of the script is nearly correct, I have managed it, but I haven't any idea to proof the rest of compatibility for thinbasic language...

if these lines are cleared we have a bezier curve script for tbgl and thinbasic :) I add a 80 per cent solving result ;)

best wishes, Lionheart
ps: Walking again with the through winter landscape with doggy :)

pps: Have add a second script you can move the nurbs/bezier curve with up, down, left, right arrow keys :)

Michael Hartlef
14-01-2009, 14:59
I have to look at your code later, cause I'm at work now.

About the "Nurbs" module. Please think about it on a command level. Means, how the functionality you want to get is controlled by thinBasic commands.
OpenGL allready has good support for Nurbs as you saw allready. You can use OpenGL right our of thinBasic. So new commands for thinBasic would only make sence, if they make things easier or are much faster.

Michael

Michael Hartlef
14-01-2009, 18:36
'glVertex3fv(&ControlPoints i/0.0) '- this line is a problem


Can you tell me the link where you got that from? It looks odd to me.

The rest of the script is not needed as it just deals with the perspective.

Lionheart008
14-01-2009, 19:51
Hi michael,

the code is original from open gl organization, resources... redbook and belongs to a bezier script, but perhaps it was my confusion last night to mix nurbs and bezier curves and looked for another script... can be it's the same or a similar script...

the nurbs script I have changed a little bit works very well :), I know, but I have thought there might be a special rendering options for nurbs and wanted to see the nurbs curve knots to manipulate them for a later moment...

see you, I will check it this evening...
have add a second script in my last post :)

Lionheart

Michael Hartlef
14-01-2009, 21:54
Yes check it as this command takes 3 float parameters. You have one parameter, mixed from several things. I think you didn't read the book right.

Petr Schreiber
14-01-2009, 22:48
Hi,

glVertex3f takes 3 float parameters (SINGLE), glVertex3fv takes just pointer to first element of array of SINGLE, or name of array in ThinBasic.

C like


ControlPoints[i][0]

...would translate to ThinBasic as something like


ControlPoints(i, 1)

... because those brackets mean array indices in C, and TB arrays are 1 based, not zero. So even the value of i should be shifted to match this.