• Glib : a 3D graphics axe library 5 1
Currently:  

Author Topic: Glib : a 3D graphics axe library  (Read 28086 times)

0 Members and 1 Guest are viewing this topic.

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Glib : a 3D graphics axe library
« on: October 10, 2012, 09:13:11 am »
hello everyone.

I would like to present a new axe librairy I devellope for my game NEMESIS.

The main goal of it is to create real-time 3D environnements, and this even at 6MHz
It is always in developpement, so you can wait new updates  :P

enjoy


LAST UPDATE : http://www.omnimaga.org/ti-z80-calculator-projects/glib-a-graphics-axe-3d-librairy/msg383996/#msg383996
TUTO : http://www.omnimaga.org/ti-z80-calculator-projects/(axe)-glib-tuto/

lot of things have change ... make sure to read the topic =)

What is implement so far:
-texture    (but outdated)
-rotation/projection
-perfect 3D cliping
-vertex/pixel/geometry shader (!!!)
-polygon drawing

TODO
-light
-backface culling
-implementation of texture shader and precalculated normal, binormal and tangent
-polygon sorting
-reimplement proprely polygons drawing and pixel/geomety shader
« Last Edit: September 26, 2014, 09:44:12 am by TheMachine02 »
AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline DJ Omnimaga

  • Now active at https://codewalr.us
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55821
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: GLIB a graphics axe 3d librairy
« Reply #1 on: October 10, 2012, 03:19:40 pm »
What are the controls?
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF


Bandcamp|Reverbnation|Facebook|Youtube|Twitter

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: GLIB a graphics axe 3d librairy
« Reply #2 on: October 11, 2012, 09:04:29 pm »
The arrows move around, i think it starts out where you cant see a wall, but moving around (turning right i think) and you can see it.

Very nice work TheMachine02!
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: GLIB a graphics axe 3d librairy
« Reply #3 on: October 12, 2012, 01:26:55 am »
One quick thing: You should have the lines for the tops and bottoms draw even when one of the vertexes it connects to isn't visible. If one of them is there, it should draw.

Oh, and it's not really 3D... :P Raycasting is the word, but it's pretty fast.
« Last Edit: October 12, 2012, 01:29:09 am by willrandship »

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Re: GLIB a graphics axe 3d librairy
« Reply #4 on: October 15, 2012, 06:31:23 am »
Oh, and it's not really 3D... :P Raycasting is the word, but it's pretty fast.

well... it's not real 3d, but it's not raycasting to...
« Last Edit: October 15, 2012, 06:31:31 am by TheMachine02 »
AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7917
  • Rating: +373/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: GLIB a graphics axe 3d librairy
« Reply #5 on: October 15, 2012, 08:32:16 pm »
wow, this is sounding far to awesome!
hopefully with this a lot more new 3d games will be made :D
« Last Edit: October 15, 2012, 08:32:34 pm by Sorunome »

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Re: GLIB a graphics axe 3d librairy
« Reply #6 on: October 16, 2012, 11:11:40 am »
I hope so.  ;D
AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Re: GLIB a graphics axe 3d librairy
« Reply #7 on: October 25, 2012, 03:50:18 am »
hey fire work !!   ;D

else, I have little probleme with a scaling spirite routine that allow scale something like that

 
 /!
/ !
--

-> the side of the surface doesn't need to be vertical or horizontal

->it's very buggy, and I am not sure of the algorithm....

if anyone have a little idea to do this , it's will be really helpful !  :)
AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline DJ Omnimaga

  • Now active at https://codewalr.us
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55821
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: GLIB a graphics axe 3d librairy
« Reply #8 on: October 26, 2012, 04:35:44 pm »
You should probably ask in the proper sub-forum, else fewer people will find your question.
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF


Bandcamp|Reverbnation|Facebook|Youtube|Twitter

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Re: GLIB a graphics axe 3d librairy
« Reply #9 on: November 12, 2012, 06:41:45 am »
You should probably ask in the proper sub-forum, else fewer people will find your question.

it's true.

Update :
-fire
-new polygones
-a first screen
-buggy clip line
-more Z precision


AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: GLIB a graphics axe 3d librairy
« Reply #10 on: November 12, 2012, 01:52:21 pm »
The fire looks cool, but the engine itself looks a bit slow. Is the screenshot taken at 8 or 15 MHz and does it slow down a lot when adding more polygons and game mechanics?

Also, I like the splash screen.

And:
else, I have little probleme with a scaling spirite routine that allow scale something like that
 
 /!
/ !
--

-> the side of the surface doesn't need to be vertical or horizontal

->it's very buggy, and I am not sure of the algorithm....

if anyone have a little idea to do this , it's will be really helpful !  :)
If you mean textures by that, I have some code lying around, but it's in asm. But I can give you the algorithm if you want too.
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Re: GLIB a graphics axe 3d librairy
« Reply #11 on: November 13, 2012, 11:28:56 am »
Also, I like the splash screen.

thank you.

The fire looks cool, but the engine itself looks a bit slow. Is the screenshot taken at 8 or 15 MHz and does it slow down a lot when adding more polygons and game mechanics?
the screenshot still in 6MHz and in the principal loop I have put a pause 200;
for the walls, if walls are very close and all visible, yes it will slow, but if walls are distants, then it will not slow down.
I don't extensively test the fire (he is not totally finish), but I think it's little slow routine (so I will try to speed up it).

If you mean textures by that, I have some code lying around, but it's in asm. But I can give you the algorithm if you want too.

yes it's texture. If you can give me the algorithm it's will be great and really helpfull. :D
AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline DJ Omnimaga

  • Now active at https://codewalr.us
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55821
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: GLIB a graphics axe 3d librairy
« Reply #12 on: November 13, 2012, 02:28:06 pm »
I actually think that at 15 MHz the rotation speed might have to be slowed down lol. Also you got animated graphics?? O.O
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF


Bandcamp|Reverbnation|Facebook|Youtube|Twitter

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: GLIB a graphics axe 3d librairy
« Reply #13 on: November 13, 2012, 02:40:33 pm »
I already explained it earlyer by PM too someone else. I hope you don't mind that I basically just copy-paste it here.

Quote from: PM
The most frequentely used shape for mapping textures is a triangle, so first off all, we are going to need a triangle drawing routine. For that, we need the points. We'll define point1 as (x1, y1, u1, v1), point 2 as (x2, y2, u2, v2) and point3 as (x3,y3,u3,v3). The u's and v's represent texture coordinates. We don't really need then yet, but implementing them now will make things easyer later on. The variables are all integers, preferably 8-bit.

We are going to draw the triangle using a horizontal scanline than moves down. To do this, we first need to sort the three points based on their Y coordinate, from smallest to largest. You can do that like this: (pseudocode)
Code: [Select]
if(Y1>Y2){
  exchange X1 and X2
  exchange Y1 and Y2
  exchange u1 and u2
  exchange v1 and v2
}
if(Y2>Y3){
  exchange X2 and X3
  exchange Y2 and Y3
  exchange u2 and u3
  exchange v2 and v3
}
if(Y1>Y3){
  exchange X1 and X3
  exchange Y1 and Y3
  exchange u1 and u3
  exchange v1 and v3
}
Now the points are sorted. Before we start drawing, we need to calculate some values. Similar calculations will have to be done with the texture coordinates, but we'll leave those for later. For these calculations, you need at least 8.8 fixed point numbers. Higher accuracy might be needed if you're drawing big textured surfaces which are for a large part outside of the screen. When it will be almost fully inside the screen, 8.8 should be fine.

Code: [Select]
du1 = (x2-x1)/(y2-y1)
du2 = (x3-x1)/(y3-y1)
du3 = (x3-x2)/(y3-y2)
These values represent the angle of the edges of the triangle. This is used to check how our scanline should change when we move a row down.
Before we start the drawing loop, there are still 4 more variables to initialize: tx, tx1, tx2 and ty.tx1 and tx2 are the x of the start and end of the scanline. They are fixed-point variables, to keep it reasonably accurate. ty and tx are integer values. ty represents the Y of a scanline, tx represents the x of the pixel we're drawing in the scanline. We'll initialize those the following way:
Code: [Select]
tx1=tx2=x1
ty=y1

Now, we can finally start with the drawing loop:
Code: [Select]

Drawn = 0

DrawingLoop:
while (ty < y2){
  //draw the scanline
  //to see if the rest is working, you can use axe's built-in line drawing routine, to see if the rest is working. Replace the code below this line by Line(tx1,ty,tx2,ty)
  tx = min(tx1,tx2) //only take integer part, or round.
  while (tx<=max(tx1,tx2)){
    SetPixel(tx,ty)
    tx += 1
  }
  //the code below this line is important even if you have used axe's line drawing routine
  tx1 += dx1
  tx2 += dx2
}

if(drawn == 0){
  y2 = y3
  dx2 = dx3
  drawn = 1
  goto DrawingLoop
}
Now you should have a working triangle drawing routine. If the triangle looks weird, try exchanging some dx variables. If it draws nothing at all, or fills the entire screen or gets stuck in an infinite loop, check if the points are ordered well. When you got it to work, don't forget to change the Line( instruction by the pixel-by-pixel scanline drawing code. You'll need this for the textures.

To draw the textures, we need some additional variables for the texture coordinates. Those are calculated very simular to the variables to change the x-position for every scanline.

We'll start by adding something to this code:
Code: [Select]
du1 = (x2-x1)/(y2-y1)
du2 = (x3-x1)/(y3-y1)
du3 = (x3-x2)/(y3-y2)

I just noticed I made a mistake yesterday. The du's should be renamed into dx's. Then we'll add similar code with u's and v's instaed of x's. So the code will become this:
Code: [Select]
dx1 = (x2-x1)/(y2-y1)
dx2 = (x3-x1)/(y3-y1)
dx3 = (x3-x2)/(y3-y2)

du1 = (u2-u1)/(y2-y1)
du2 = (u3-u1)/(y3-y1)
du3 = (u3-u2)/(y3-y2)

dv1 = (v2-v1)/(y2-y1)
dv2 = (v3-v1)/(y3-y1)
dv3 = (v3-v2)/(y3-y2)

The du's and dv's stand for differences in texture coordinates.
Behind that code, there was this:
Code: [Select]
tx1=tx2=x1
ty=y1

Now, we'll add the texture coordinates to it:
Code: [Select]
tx1=tx2=x1
tu1=tu2=u1
tv1=tv2=v1

ty=y1

The rest of the code is a bit different, but it shouldn't be too hard to implement in your program
Code: [Select]
Drawn = 0

DrawingLoop:
while (ty < y2){
  //initialize some variables for the texture
  if(tx1<tx2){
    tdu=(tu2-tu1)/(tx2-tx1)
    tdv=(tv2-tv1)/(tx2-tx1)
    tu=tu1
    tv=tv1  //unlike tx and ty, tu and tv are fixed-point variables
  } else {
    tdu=(tu1-tu2)/(tx1-tx2)
    tdv=(tv1-tv2)/(tx1-tx2)
    tu=tu2
    tv=tv2  //unlike tx and ty, tu and tv are fixed-point variables
  }
  //draw the scanline
  while (tx<=max(tx1,tx2)){
    #if(8x8_texture) //whit this, I mean that you have to shoose between 8x8 and 16x16 for textures. Don't actually code it as an if.
      if(bit(round(tu),(Texture+round(tv))){
        setPixel(tx,ty)
      }else{
        resPixel(tx,ty)     //res means white, set means black
      }
    #else if(16by16_Texture)
      if(bit16(round(tu),(round(tv)*2+Texture)){  //IMPORTANT: use a 16-bit bit checking instruction (make it yourself if you're programming in asm)
        setPixel(tx,ty)
      }else{
        resPixel(tx,ty)
      }
    tx += 1

    tu += tdu
    tv += tdv
  }
  tx1 += dx1
  tx2 += dx2
}

if(drawn == 0){
  y2 = y3
  u2=u3
  v2=v3
  dx2 = dx3
  du2=du3
  dv2=dv3
  drawn = 1
  goto DrawingLoop
}

If you need help with this, just ask.
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: GLIB a graphics axe 3d librairy
« Reply #14 on: November 13, 2012, 04:15:30 pm »
Lol, that looks familiar, ben_g

TheMachine, is it possible to increase the amount of precision when moving? It seems that the camera 'jumps' a lot :(