Feature request: Built-in commands for creating 3D primitives?

Previous topic - Next topic

Yodaman Jer

Hey Gernot,

I've been playing with GLB for a bit now and I was just wondering how hard it would be to create a set of commands that create 3D objects?

What I mean is, rather than the user developing their own functions for  creating spheres, cubes, torus' etc., they could simply type in...

Code (glbasic) Select
//Create a sphere
CreateSphere(objNum, objSize)


Instead of...
Code (glbasic) Select
FUNCTION CreateSphere: num, r, n, col
LOCAL i,j, theta1, theta2, theta3, pi
pi = ACOS(0)*2
IF r < 0 THEN r = -r
IF n < 4 THEN n = 4

X_AUTONORMALS 2 // smooth edges
X_OBJSTART num
FOR j=0 TO INTEGER(n/2) -1
theta1 = j * 2*pi / n - pi/2;
theta2 = (j + 1) * 2*pi / n - pi/2;
FOR i=0 TO n
theta3 = i * 2*pi / n;
X_OBJADDVERTEX r*COS(theta2) * COS(theta3), r*SIN(theta2), _
r*COS(theta2) * SIN(theta3), i/n, 2*(j+1)/n, col
X_OBJADDVERTEX r*COS(theta1) * COS(theta3), r*SIN(theta1), _
r*COS(theta1) * SIN(theta3), i/n, 2*j/n, col
NEXT
X_OBJNEWGROUP
NEXT
X_OBJEND
ENDFUNCTION // n


And then calling...
Code (glbasic) Select
CreateSphere(sphere, 18, 12, RGB(255,255,255))

It's just something that seems a little more user-friendly for beginners, especially those who don't understand geometry all that well (like me!). :P

The best part could be that the user could still manually create the objects via code instead of the compiler auto-generating it through one command, allowing for more advanced users more options.

What do other, more seasoned users of GLBasic think?
Click the pic to go to my development blog!

Ruidesco

There is a number of such functions in Samples/Common/3DPrimitives.gbas

Yodaman Jer

Hmm, I'll have to check that out!

Still, the user would have to include that file and then learn the parameters for each function, as opposed to just memorizing a list of commands. Wouldn't it just be easier to make a list of default 3D object commands, so that the user wouldn't have to include a functions file and learn multiple parameters?

Click the pic to go to my development blog!

Kitty Hello

do you want that code linked with your GP2X Wiz game all the time? I don't. Why do people so dislike libraries?

spacefractal

I guess a external help system could been nice. its a commandlist found.

Its could been found in the "Jumps" by a folder or by a extra tab named "library" and then do a list of functions found in same style. That could help to avoid flipping what a lib did that. My self I do often have more than one gbas used for easier to find the function required (example comon functions in own gbas file).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

matchy

3D is not the issue. For example, DRAWCIRCLE is not a command but is a classic BASIC statement. Whatever the case a library is required and the commands are practically just functions and routines. Although, I like the idea of simplifying commands for new, young GLB users but any simpler would require a game construction kit (because there's no in-between). Perhaps something like "Extended GLBasic", like for example C64's Simon's BASIC?

Yodaman Jer

Quote from: Kitty Hello on 2011-Dec-23
do you want that code linked with your GP2X Wiz game all the time? I don't. Why do people so dislike libraries?

I don't dislike libraries, I just thought having some commands like DarkBASIC has, for example, "Make Object Sphere", would be easier for new users to use and understand, and as they progressed along they could learn how to manually build them with code. :)
Click the pic to go to my development blog!