Author Topic: TI 3D modeller  (Read 5602 times)

0 Members and 1 Guest are viewing this topic.

Offline zero44

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 128
  • Rating: +21/-0
  • <!--//www.ustr.net/infrared/infrared1.shtml-->
    • View Profile
    • zero44
TI 3D modeller
« on: May 31, 2011, 07:17:12 am »
Yesterday and this morning I made a 3D modeller in Axe.
It can zoom (1~15), and make a horizontal rotation from 0 to 359°.
It's not very fast, a complete rotation of a 13-pixel object takes 16 seconds !
(yeah, it's objects pixel per pixel, but I'm working on lines)

Code:
Spoiler For code:
.VIEW3D

[hex code->GDB1
zeros(3*•->GDB0
for(I,0,3*•-1
{GDB1+I}->{GDB1+I}
End
0->X->G->I
1->Z
12->L
Repeat getkey(15)
sub(DRW
DispGraphClrDraw
If getkey(25)
G+1^2->G
Pause 300
End
If getkey(2)
X-1->X
If X>360:359->X
End:End
If getkey(3)
X+1^360->X
End
If Z>1 and getkey(50)
Z-1->Z:End
If Z<15 and getkey(49)
Z+1->Z:End
End
Return

.LBLs

Lbl DRW
X->r4
For(I,0,L
3*I+GDB0->A
3*I+GDB1->B
For(r3,0,2
{B+r3}*Z-(128*Z)+128->{A+r3}
End
sub(XYZ,A,r4
Pxl-On(S+48,T+32
End
Return

Lbl XYZ
r1->r3:r2->r4
{r3}-128->r6
{r3+2}-128->r5
{r3+1}-128->r2

cos(r4*10/14)*r6+(sin(r4*10/14)*r5)/128->r1
r1->S
r2->T
Return

Enjoy !  :hyper:

Hex code: write the XYZ place of a pixel. [808080] is the zero. ( the center of screen is the middle of var: 128)
To have a little tower, write: [808080808180808280] and add [808081] for an eventual hall  :P

• is the number of points, for the moment you have to do equations with it, and write results directly in source code ( this stage is dangerous for Ram, so don't make mistake while adding numbers. But you've got a calc, no ?  ;D

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: TI 3D modeller
« Reply #1 on: May 31, 2011, 09:46:07 am »
Hm, cool. Are you going to add oncalc drawing soon? And please post the source code as an 8xp.
I'm not a nerd but I pretend:

Offline zero44

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 128
  • Rating: +21/-0
  • <!--//www.ustr.net/infrared/infrared1.shtml-->
    • View Profile
    • zero44
Re: TI 3D modeller
« Reply #2 on: May 31, 2011, 11:01:52 am »
I have no usb cable anymore, and I'm trying to do lines; just before vertical rotation.
If someone can say me how to convert xyz point + xy rotation to a xy point ... It'll be great better for the project.
____________

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: TI 3D modeller
« Reply #3 on: May 31, 2011, 02:08:45 pm »
I have no usb cable anymore, and I'm trying to do lines; just before vertical rotation.
If someone can say me how to convert xyz point + xy rotation to a xy point ... It'll be great better for the project.

You can use SourceCoder or TokenIDE to tokenize that code :)

Either way, I'd love a screenshot when you can.

SirCmpwn

  • Guest
Re: TI 3D modeller
« Reply #4 on: May 31, 2011, 02:33:07 pm »
What method of 3D is this?  Full perspective?  It looks like much less source code than I'd expect.

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: TI 3D modeller
« Reply #5 on: May 31, 2011, 02:36:18 pm »
So is this dots or is it polygons. I would recommend using polygons as they are faster to render. And I agree with Sir on that it is much less code than I expected.

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

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: TI 3D modeller
« Reply #6 on: May 31, 2011, 02:45:12 pm »
If someone can say me how to convert xyz point + xy rotation to a xy point ... It'll be great better for the project.

here is some GML code for converting a 3d point to a 2d point onscreen. It's just handling variables, so if you've ever programmed before(in any language), you should understand the code.
It's based on floating points, so it might be a bit difficulty to port.
the code to convert 3d to 2d returns a number between -1 and 1 for the x and y variables.
If you don't understand the 3d therms, just ask me.
I'm also porting this code to asm for my 3d engine

the code (GML version) has been fully tested and no bugs were found
Spoiler For the GML code:
call this to initialise the 'camera'. It handles most of the slow and complicated math so that this should only be calculated once every frame.
Code: [Select]
global.d3dto2d_xfrom = argument0;
global.d3dto2d_yfrom = argument1;
global.d3dto2d_zfrom = argument2;

global.d3dto2d_xto = argument3-global.d3dto2d_xfrom;
global.d3dto2d_yto = argument4-global.d3dto2d_yfrom;
global.d3dto2d_zto = argument5-global.d3dto2d_zfrom;
d = sqrt(global.d3dto2d_xto*global.d3dto2d_xto+global.d3dto2d_yto*global.d3dto2d_yto+global.d3dto2d_zto*global.d3dto2d_zto);
global.d3dto2d_xto /= d;
global.d3dto2d_yto /= d;
global.d3dto2d_zto /= d;

global.d3dto2d_xup = argument6;
global.d3dto2d_yup = argument7;
global.d3dto2d_zup = argument8;
d = global.d3dto2d_xup*global.d3dto2d_xto+global.d3dto2d_yup*global.d3dto2d_yto+global.d3dto2d_zup*global.d3dto2d_zto;
global.d3dto2d_xup -= d*global.d3dto2d_xto;
global.d3dto2d_yup -= d*global.d3dto2d_yto;
global.d3dto2d_zup -= d*global.d3dto2d_zto;
d = tan(degtorad(argument9)/2)*sqrt(global.d3dto2d_xup*global.d3dto2d_xup+global.d3dto2d_yup*global.d3dto2d_yup+global.d3dto2d_zup*global.d3dto2d_zup);
global.d3dto2d_xup /= d;
global.d3dto2d_yup /= d;
global.d3dto2d_zup /= d;

global.d3dto2d_xcross = (global.d3dto2d_yup*global.d3dto2d_zto-global.d3dto2d_zup*global.d3dto2d_yto)/argument10;
global.d3dto2d_ycross = (global.d3dto2d_zup*global.d3dto2d_xto-global.d3dto2d_xup*global.d3dto2d_zto)/argument10;
global.d3dto2d_zcross = (global.d3dto2d_xup*global.d3dto2d_yto-global.d3dto2d_yup*global.d3dto2d_xto)/argument10;

global.d3dto2d_znear = argument11;
global.d3dto2d_zfar = argument12;
call this to convert a 3d point to a 2d point
Code: [Select]
var xx,yy,zz,d;
xx = argument0-global.d3dto2d_xfrom;
yy = argument1-global.d3dto2d_yfrom;
zz = argument2-global.d3dto2d_zfrom;
d= xx*global.d3dto2d_xto+yy*global.d3dto2d_yto+zz*global.d3dto2d_zto;
if (d<global.d3dto2d_znear or d>global.d3dto2d_zfar){ return 0}else{
global.xx = (xx*global.d3dto2d_xcross+yy*global.d3dto2d_ycross+zz*global.d3dto2d_zcross)/d;
global.yy = (xx*global.d3dto2d_xup+yy*global.d3dto2d_yup+zz*global.d3dto2d_zup)/d;
}
return 1;
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 zero44

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 128
  • Rating: +21/-0
  • <!--//www.ustr.net/infrared/infrared1.shtml-->
    • View Profile
    • zero44
Re: TI 3D modeller
« Reply #7 on: May 31, 2011, 03:11:26 pm »
I didn't understood all what you said.

I made a horizontal rotation, and now if there's X points, it's possible to draw X lines.
I tried a cube, it works, but Blender is faster. ^^
____________

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: TI 3D modeller
« Reply #8 on: May 31, 2011, 03:14:26 pm »
Sounds interesting, I would like to see screenshots.

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: TI 3D modeller
« Reply #9 on: May 31, 2011, 03:16:57 pm »
what's the part you don't understand?
The upper script handles the 'camera', and the lower script calculates the 2D coordinates of a 3D point.

Or do you just not know how to port those scripts to axe?
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 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: TI 3D modeller
« Reply #10 on: May 31, 2011, 04:34:41 pm »
I've just tested it on my calc, AND NOW MAH SCREEN DISPLAYS UPSIDE-DOWN (and it also turned the contrast all the way up)
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 Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: TI 3D modeller
« Reply #11 on: May 31, 2011, 05:58:39 pm »
I've just tested it on my calc, AND NOW MAH SCREEN DISPLAYS UPSIDE-DOWN (and it also turned the contrast all the way up)

Woah, really? But outside the program?

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: TI 3D modeller
« Reply #12 on: May 31, 2011, 06:13:08 pm »
I've just tested it on my calc, AND NOW MAH SCREEN DISPLAYS UPSIDE-DOWN (and it also turned the contrast all the way up)
This topic should help you get it back to normal: http://ourl.ca/6348
Good luck. :)

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: TI 3D modeller
« Reply #13 on: June 01, 2011, 12:32:50 pm »
thanks for the link, ztrumpet

It's nothing about the program itself, it was my own dam fault. I executed the compiled version as a basic program :banghead:
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 zero44

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 128
  • Rating: +21/-0
  • <!--//www.ustr.net/infrared/infrared1.shtml-->
    • View Profile
    • zero44
Re: TI 3D modeller
« Reply #14 on: June 01, 2011, 12:40:34 pm »
I forget something : it's a beta version ...  :-\
Sorry ben_g for your screen, I hope you'll can have it normally.
The only bug I had was a Ram Cleared.

I give you the last version :
AxeLib7 is the library (see my sig) needed
Axe3Dbdd is the objects hexa BDD
Axe3D is the program you've to compile
View3D is the compiled program

to change objects :
go into bdd, put out the hex code of the comment :
theres, in a second comment, some numbers : &,$,# and * (for example)
Put them here :
'Zeros(& ...
'For(I,0,$ ...
'#→L
'*→K

and re-compile Axe3D

Enjoy !  :hyper: (but this time, be careful cause it may bug ...  :-\ )


EDIT: forgot the most important : now after xyz, in a point, you've to put another number : it's the numero of another point, and if it's not null, you'll have a line.
And in GDB7, put two point's numeros and you'll have a line too.
« Last Edit: June 01, 2011, 12:43:16 pm by zero44 »
____________