Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - TheMachine02

Pages: 1 ... 13 14 [15] 16 17 ... 32
211
TI Z80 / Re: Jumper for the +C
« on: November 11, 2013, 11:38:49 am »
Wow can't wait to see the result  :D

212
Computer Usage and Setup Help / Re: TI Connect being stupid (again)...
« on: November 11, 2013, 11:31:21 am »
indeed  :P

Ti connect don't really have problem with me (transfer etc work fine), but if I leave it on my computer, Ti connect made him crash ><

213
Other / Re: Atari2600 Cartridge Reader V2
« on: November 11, 2013, 09:46:48 am »
indeed that pretty interesting. Block transfer is really cool  :D

214
TI Z80 / Re: [Axe] - GLib TUTO
« on: November 11, 2013, 09:36:34 am »
Ui, a tutorial for this, that helps understand how it works a lot :)
* Sorunome hops people will start using it now

I hope too  :P  that why I make the lib a lot simpler (and a tuto)
The thing I found funny, is as I make the lib simpler, I make it faster  ;D

215
TI Z80 / Re: GLIB a graphics axe 3d librairy
« on: November 11, 2013, 09:30:36 am »
Is GCORE fully functional and finished now ?

Well there will have just some little modification in the shader code, but this is almost nothing  (and if I find optimization, I'll made update)
So, we can consider the GCORE as fully functionnal, yes

216
TI Z80 / Re: GLIB a graphics axe 3d librairy
« on: November 11, 2013, 07:47:30 am »
Update of the main lib !!  (the readme is not finalized, so please refer for the moment to the tuto)

*multiple camera handling
*vertex shader
*better system in general
*lot of optimisations

EDIT fixed version !!! shader now work proprelly, and file is clean : This is the final version =)

217
TI Z80 / Re: [Axe] Ikaruga X
« on: November 11, 2013, 07:39:43 am »
I like it  . japanese charater is cool :D

218
TI Z80 / [Axe] - GLib TUTO
« on: November 11, 2013, 07:38:34 am »
This is my first tuto ever, so please tell me is something is unclear, or ununderstandable.
New tuto using the new GCORE and final version !

I puting this here, to don't make confusion with other.


First of all, please download the file attached to this post, (not in the GLib main thread, 'cause I didn't update it) (GCORE).
Last version is 2.0 omega
Place it preferably in archive : warning ! this file is pretty huge (6400 bytes !!).


I THE BASIS

Let's create a rotating cube !

First of all, include the GCORE prog inside of your axe source :

Code: [Select]
prgmGCORE

Once you did this you have access to all the GLib functions.


We need to define the 3D coordinates of each point of the cube, so we can rotate and display them afterwards.
Those points are just a bunch of data, so no real explanations are needed here :
Code: [Select]
Data(40r,-40r,40r)->GDB1
Data(40r,40r,40r
Data(-40r,-40r,40r
Data(-40r,40r,40r
Data(40r,-40r,-40r
Data(40r,40r,-40r
Data(-40r,-40r,-40r
Data(-40r,40r,-40r

Just remember that a 3D point is always defined as X,Z,Y using the standard 3D axis (X goes from left to right, Y from down to up and Z from near to far). Each coordinate takes 2 bytes, so don't forget the r.

By default GLib has no camera defined. So we must specify what type of camera we want to use.
In this example, I want to be able to rotate my cube : this is a GMODELVIEW camera (I don't want the camera to move, only the model to rotate). If we actually wanted to have a worldview (fps mode) camera, we would use the °GWORLDVIEW constant.

The function to define a camera is :

Code: [Select]
GNewCam(pointer to camera)
.Destroys r1

**But but but .... I don't know how to create my camera, and I need a pointer to it !
STOP don't worry, GLib provides two pointers to some really basic cameras ! These are the °GMODELVIEW and °GWORLDVIEW cameras.

So I just give one of those pointers to the function and my new camera is created :

Code: [Select]
GNewCam(°GMODELVIEW)
Glib also need a special structure, allowing easy vertex processing/clipping. It's called a VBO : vertex buffer object. Basically, it's just a ram area.
You need at the begining of your program to generate such structure :

This is the command used :
Code: [Select]
GGenVBO(size,data_to_match)
.destroy r1,r2
your size is the number of vertices you want to have.
data_to_match is the raw (not processed) vertices coordinates (here it's GDB1)
It also set the current VBO to the one created , so it will be used by all other command.

The function return a special value, that you have to store somewhere : it's the VBO id.
We now have this :

Code: [Select]
GGenVBO(8,GDB1)->G
.I used G, but you can used any way to save this value


Now we can start the main loop, with 3D calculations :

Code: [Select]
While 1
GUpdateVBO(G,0,7)

this piece of code "update" (transform the vertices) for the specified VBO. You can see that we are passing the id we have previously store.
0 and 7 are the start and the end of vertices we should transform. Here it transform from the vertx 0,...., to the vertx 7 (the last one)

And now we want display our points.
GLib provide the
Code: [Select]
GVBOPoint(id_vertex)
.destroy r1
function to retrieve a point from VBO. It's store the x-coord and y-coord on screen to GScreenX and GSreenY var (alias OP1 and OP1+2)
It also return in hl a clipping information : 0 if the point is visible, anything else (=/= from 0)

We can now write this :
Code: [Select]
For(M,0,7)
GVBOPoint(M)
!If
Rect(GScreenX,GScreenY,2,2
End
End

the code loop from the first vertice, to the last one, retrieve on screen coordinate and then disp it if it is visible.


We need now to handle the arrow keys, so we can rotate our cube. GLib provides an in-built function, which handles everything (life is beautiful isn't it  :P)

It's the GGetkey function.
The call is:
Code: [Select]
GGetkey()

End of the code :

Code: [Select]
GGetkey()

DispgraphClrdraw   // we want to have something on screen !
EndIf getkey(15) // stop the While loop if [clear] is pressed


Now time to compile it ... aaaaaaaaaand ...



It works ! :D

II Let's put some line


Well, let's take the previous code we used. He only display dot point, that not super funny. So let's put some line in there !!
In fact, there is almost nothing more to add to your code.
I want to display line, and possibly clipped lines between them. We don't want to draw point, so the previous for() loop is useless.

GLib provide one function for this :
Code: [Select]
GClipLine(ID_vertex1,ID_vertex2)
.destroy r1 to r6
This is assuming that a VBO has been set.

We need however to know what vertices will be linked with. So let's create a list of ID's. Just to remember though :

Code: [Select]
Data(40r,-40r,40r)→GDB1    .vertex ID 0
Data(40r,40r,40r           .vertex ID 1
Data(-40r,-40r,40r         .vertex ID 2
Data(-40r,40r,40r           ...
Data(40r,-40r,-40r
Data(40r,40r,-40r
Data(-40r,-40r,-40r
Data(-40r,40r,-40r

The link between vertices will be handle by an for loop and a constant list (containing the correct vertex ID to link)

so we now have :
Code: [Select]
Data(0,1,2,3,4,5,6,7)->°LinkList
Data(0,2,2,4,4,6,6,0
Data(1,3,3,5,5,7,7,1

and :
Code: [Select]
For(M,0,11)    .there is 12 line to draw in a cube
GClipLine({M*2+°LinkList},{M*2+1+°LinkList}
End

combining all of this , aaaaaaaaand  (yes I like big and) :



well I fail in the link data list --'
exercice : find the right data list :p

the whole code, as ever :

Spoiler For Spoiler:
Code: [Select]
.TEST
prgmGCORE

Data(40r,-40r,40r)→GDB1
Data(40r,40r,40r
Data(-40r,-40r,40r
Data(-40r,40r,40r
Data(40r,-40r,-40r
Data(40r,40r,-40r
Data(-40r,-40r,-40r
Data(-40r,40r,-40r

Data(0,1,2,3,4,5,6,7)->°LinkList
Data(0,2,2,4,4,6,6,0
Data(1,3,3,5,5,7,7,1


GNewCam(°GMODELVIEW)
GGenVBO(8,GDB1)->G

While 1

GUpdateVBO(G,0,7)

For(M,0,11)    .there is 12 line to draw in a cube
GClipLine({M*2+°LinkList},{M*2+1+°LinkList}
End


GGetkey()

DispgraphClrdraw
EndIf getkey(15)


correction of the exercice :
Spoiler For Spoiler:
Code: [Select]
Data(0,1,2,3,4,5,6,7)->°LinkList
Data(0,2,2,6,6,4,4,0
Data(1,3,3,7,7,5,5,1


III Shaders (part 1)

you may wonder what is a shader, and what you can do with it. In fact, the shader is a way to override the static pipeline of the 3D calculations. You are able then to do a lot of thing with it. However, some vars, (r3 to r6) musn't be used inside shader functions, due to GLib using these.

Well, anyway, let get started !
The standard function to set a shader is :

Code: [Select]
GVertexShader(adress_of_function,sub_adress_projection)
.destroy r1,r2
you can of course get the adresse with the L operator.
sub_adresse_projection is kindy tricky. It is the adresse in your shader, where th projection calculation starts.

Once you've put this code, anywhere in your  program, GLib's functions will get override.

So let's see what you have to put inside this function.

Code: [Select]
Lbl Shader
GRestoreHL

Return

because some function need a correct hl you mostly want to restore it. As GLib do a goto before, hl get ecrased. But we have a variable to restore it  ;D

a very basic shader (do nothing more than the GLib's GVertex command) would be then this:

Code: [Select]
Lbl Shader
GRestoreHL
GRotate()
Lbl SubShader   .the famous sub_adress
Goto GProject


it's first call the fuction who convert the r1,r2,r3   (and need r3 in hl) to the rotated coordinate in 3D space into OP1+6
Code: [Select]
GRotate(x,z,y)
.destroy r1-r3
.write to OP
You will then have the vertex rotated coordinate to these variable :

Code: [Select]
GVertexX
GVertexY
GVertexZ

Then it call the projection function to retrieve the x,y coordinate on screen

Code: [Select]
GProject()
.need the 3D coordinate Inside OP1+6 (°GVertex+6)

...and you can retrieve the 2D coordinate to these vars : (note that this function keep the 3D coordinates safe)

Code: [Select]
GScreenX
GScreenY

Based on this you can either :
-modify the vertex position before any rotation or after
-build your own rotation routine and projection (for example to have more precision)
-and everything you want...

Once you've done with the shader, you can disable it by doing :
Code: [Select]
GVertexShader(°GLIBFUNC)
yep it's the same function  :P  pretty easy isn't it ?

let's create a custom shader then  ;D
The goal is to make the camera moving up and down like in old fps. When the player is not moving, there should be no mouvement.
Let create a vars T who hold the current active/not active state. Each frame, compare the X,Y coordinate of the player with previous stored one. (A,B) - if it different, increase the Z var, use to hold an angle : the cosinus will give us the mouvemnt.

We now have this as shader :
Code: [Select]
Lbl TEST
GRestoreHL
GRotate()
Lbl TESTSUB
GProject()
!If T
signed{Z^256+°GCos}//32+GScreenY+2->GScreenY
End
Return

for each vertex, the point will be move on screen.

And then in the main loop, add this:

Code: [Select]
0->T
!f A-GCPosX   .GCPosX is the X coordinate of the camera
!f B-GCPosY
+1->T   .hl abuse...
End
End

GCPosX->A
GCPosY->B
If T
96->Z
Else
Z+8->Z   .increase the angle, so we can have the mouvement
End


and with variables initialisation :

Code: [Select]
0->A->B->T

So the whole code is :
(note that I change vertices to be more a world thing)
Spoiler For Spoiler:
Code: [Select]
.TEST
prgmGCORE

Data(-64r,0r,64r)→GDB1
Data(64r,20r,64r
Data(-64r,0r,64r
Data(-64r,20r,64r
Data(64r,0r,-64r
Data(64r,20r,-64r
Data(-64r,0r,-64r
Data(-64r,20r,-64r

Data(0,1,2,3,4,5,6,7)->°LinkList
Data(0,2,2,4,4,6,6,0
Data(1,3,3,5,5,7,7,1


GNewCam(°GWORLDVIEW)
GGenVBO(8,GDB1)->G

0->A->B->T
GVertexShader(LTEST,LTESTSUB)  .actually the small liste operator.

While 1

GUpdateVBO(G,0,7)

For(M,0,11)    .there is 12 line to draw in a cube
GClipLine({M*2+°LinkList},{M*2+1+°LinkList}
End

0->T
!f A-GCPosX   .GCPosX is the X coordinate of the camera
!f B-GCPosY
+1->T   .hl abuse...
End
End

GCPosX->A
GCPosY->B
If T
96->Z
Else
Z+8->Z   .increase the angle, so we can have the mouvement
End

GGetkey()

DispgraphClrdraw
EndIf getkey(15)
Return

Lbl TEST
GRestoreHL
GRotate()
Lbl TESTSUB
GProject()
!If T
signed{Z^256+°GCos}//32+GScreenY+2->GScreenY
End
Return

well, screen have different vertices but run the same shader :



One thing to remember :
DO NOT USE r4 to r6 !!. r1-r3 are fine though (but only after rotating)


IV And then come polygons.... [WARNING OUTDATED ]


the polygon system is in a separate library. So to use it, download the GPOLYGON file, and then put :

Code: [Select]
prgmGPOLYGON

a little warning : GPOLYGON is in alpha, bug may still there ! (and so ram clear too =\)

at the begin of your program, after the inclusion of the GCORE file. You can then acess all the new functions !

There is 3 extremely important function :
Code: [Select]
GDrawArray(adr_array,nb_of_poly)
.destroy r1 to r6
GPrimitive(start_adr)
.destroy r1 to r6
GSetColor(flag)
.destroy r1


I'll first explain GSetColor and GDrawArray, later GPrimitive

GSetColor is I guess pretty obvious. It is used to set the current drawing color.
Two flag are possible :
°GBLACK or °GWHITE (yes, it's constants)

every polygon drawn will have the color you set. Black is the default color.

GDrawArray can draw polygons according to a big bunch of datas. Data have a particular structure :

Code: [Select]
Data(Type_polygon,Color
Data(idVertex1,idVertex2,...
.all of this is one byte value

This function handle 3 type of polygon, with a special one :
-triangles       type is °GTRI
-quadrilater    type is °GQUAD
-sphere          type is °GSPHERE

the number of vertices you want to put is obviously the number of vertices in the polygon.

Why I say sphere is a special thing ? Cause data structure is different :

Code: [Select]
Data(type,color)
Data(centerVertexId,radius

where the centerVertexId is the id of the vertex representing the center of the sphere.

and then the GPrimitive function. I guess this is the most difficult.

the GPrimitive function take in input the pointer to a list of vertices' id, an you must set a particular variable before the call ; the GPolygon var.
Simply put the type ( the constant ) in it. The call will the look like this :

Code: [Select]
GSetColor(°GBLACK)
°GTRI->Gpolygon
GPrimitive(Data(0,1,2))

it wil draw, in black, a triangle between the first three vertex.

One last thing before the test code though, you remember the GVAdr and GVStr variables for the line clipping ? Well polygon work the same. Every function need correct value in these var.
Meaning that you have to rotate your vertex, store them, before call the Polygon function.  :P  If a polygon you draw goes crazy, look if you don't forget this part.

And now, a little test program:


Code: [Select]
.TEST
prgmGCORE
prgmGPOLYGON

Data(40r,-40r,40r)→GDB1
Data(40r,40r,40r
Data(-40r,-40r,40r
Data(-40r,40r,40r
Data(40r,-40r,-40r
Data(40r,40r,-40r
Data(-40r,-40r,-40r
Data(-40r,40r,-40r

Data(0,1,2,3,4,5,6,7)->°LinkList
Data(0,2,2,4,4,6,6,0
Data(1,3,3,5,5,7,7,1

Buff(8*6)→GDB2


GNewCam(°GMODELVIEW)
GDB1→GVAdr
GDB2→GVStr

While 1

GDB1→r5
GDB2→r6

For(8)
GVertex({r5}r,{r5+2}r,{r5+4}r
copy(°GVertex,r6,6
r6+6→r6
r5+6→r5
End

For(M,0,11)    .there is 12 line to draw in a cube
GClipLine({M*2+°LinkList},{M*2+1+°LinkList}
End

°GQUAD->GPolygon
GPrimitive(Data(0,1,3,2))
.warning ! vertex must be clockwise or anticlockwise!

GGetkey(°GMODEL)

DispgraphClrdraw
EndIf getkey(15)


not much change ,heh ?
and the screen =)


still pretty strong, running at 20fps with a fully clipped model.

V VBO, extra functions, and pipeline informations...

We have already talked about VBO ... but how they work precisely ? follow the guide !

VBO are just a free place in memory, with an particular structure, and an id.
What is a VBO Id ? In fact, it is no more than the adress of the start of it.
Base on that, we can perfectly create our own VBO, without passing by the GGenVBO() command.You can perfectly, is L3 has been perfectly set up use this :
Code: [Select]
GSetCurVBO(L3)
.destroy r1

Bascially this command will change the current active VBO (read : used for rendering) to the one you specify.
So, what is this particular structure ? It is the following :

Code: [Select]
.1 bytes                              -- reserved field for GLib's, used for delete VBO (you don't really need this)
.2 bytes                              --number of vertices the VBO should handle at max
.2 bytes                              --raw vertices adress
.5*number of vertices bytes --the vertex on screen position, with their respective cliping code
.6*number of vertices bytes --the rotated vertices coordinates.

the screen coordiante is separate as follow :

Code: [Select]
.2 bytes X coordinate
.2 bytes Y coordinate
.1 byte clipping code

the cliping code can be computed, if the vertex position to classify is in the GVertexX to GVertexZ vars with :
Code: [Select]
GInFrustrum()/256
.destroy nothing
and return vertex status in hl :
-0 if the point is visible
-anything else if not


Now more about the GLib's pipeline. In fact, when you want to draw a line, or any polygon, the classical pipeline will be :


-green : vertex operation
-red : shader
-blue : geometric operation
-white : outside GLib data operation.

Indeed, this is a simplified one - especially into the graphics commands. The last stage can be decomposed in many other one, but the GCORE lib doesn't really touch these. It's more the goal of the GPOLY lib (wich is for the moment outdated).


Other tutorials are coming, I will then organize this post with them.

219
Axe / Re: AlphaCS Project
« on: November 10, 2013, 01:30:24 pm »
well, I can see a lot of optimisation, especially is some structure like :

Code: [Select]
If value=0
0->D
Else
1->D
End

wich can be optimisated as :

Code: [Select]
If value
1
End
->D

every

Code: [Select]
If value=0
can be change to
Code: [Select]
!If value

You can is some case use the hl register, like in this case :

Code: [Select]
value->r1
If r1=-1
...
to :

Code: [Select]
value->r1
!If +1
...

this is little tips, I will see if more  better optimisations can be done in structure of the program

EDIT : this topic may help you to optimize your code : http://ourl.ca/8520

220
TI Z80 / Re: GLIB a graphics axe 3d librairy
« on: November 06, 2013, 10:19:39 am »
Do you use a rom-dumped rom for wabbit? If not, do it, the others have some wierd bugs.

yep it's a calc dumped rom  :P, but this bug still weird

221
TI Z80 / Re: GLIB a graphics axe 3d librairy
« on: November 05, 2013, 12:58:06 pm »
no, the glitchy line appears everywhere, due I think to a value who become is some case negative in the triangle draw routine and mess up everything  <_<
The clipping however work for every polygon, except quad in some rare case, when the clipping algo gave me 5 vertices, it's just draw only one triangle and exit.

222
TI Z80 / Re: GLIB a graphics axe 3d librairy
« on: November 05, 2013, 12:30:30 pm »
Well some screen about what I've done recently  :P  : polygon clipping

The shadow thing strangely make everything crash in Wabbit (it open the debugger automatically each time), whereas the prog work fine on the calculator  :crazy:

223
TI Z80 / Re: [Axe] Faces, a 3D space shooter
« on: November 02, 2013, 01:21:49 pm »
I have no surface texturing, it's only inidividual 3D dots placed on faces o.O

Well I guess so, seeing the speed of the  whole thing  :P  surface texturing is slow

224
TI Z80 / Re: [Contest 2013][Axe] Unnamed SHMUP
« on: November 02, 2013, 01:19:42 pm »
look great  :D especially like how the enemies are moving.

225
General Calculator Help / Re: Wabbitemu?
« on: November 02, 2013, 01:15:35 pm »
If I rember well this way should work ( this is what I use) : http://www.cemetech.net/forum/viewtopic.php?p=204320

Pages: 1 ... 13 14 [15] 16 17 ... 32