Alternatively, join us on Discord.

CKH4's 3D plane program

Started by CKH4, April 21, 2015, 09:35:36 pm

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

CKH4

April 21, 2015, 09:35:36 pm Last Edit: April 21, 2015, 09:52:53 pm by CKH4
Even though this is not pixel art I don't think that it deserves a new topic so here's the code for the 3d faked plane.
0->A
While 1
A-pi(K=26)+pi(K=24->A
6cos(.05A->B
sin(.05A->C
If K
ClrDraw
Line(~B,6-C,B,6+C
Line(~B,C-6,B,~6-C
Line(B,6+C,B,~C-6
Line(~B,6-C,~B,C-6
"Leave this out for untextured
For(D,0,6,.65
Line(B/6D-B/2,3+D/5C,B/6D-B/2,~3-D/5C
End
"
getKey->K
End

and here's the image:
Without texture

With texture


DJ Omnimaga

April 21, 2015, 09:48:41 pm #1 Last Edit: April 21, 2015, 10:07:19 pm by DJ Omnimaga
I like how fast this is despite being BASIC. :) I should try making an HP Prime version when I get a chance.

CKH4

Yeah, feel free to use any of this code if you need it. For basic I think it is pretty well optimized but I haven't tried to hard.


DJ Omnimaga

April 21, 2015, 10:09:15 pm #3 Last Edit: April 21, 2015, 10:19:44 pm by DJ Omnimaga
Is it possible to modify that engine to use the screen pixel coordinates rather than graph window?

EDIT: This is what I got after modifying the code a bit by the way. Textures seem glitchy though:
EXPORT plane3D()
BEGIN
DIMGROB_P(G1,320,240,#9EAB88);
0▶A;
WHILE 1 DO
A-π*(ISKEYDOWN(8))+π*(ISKEYDOWN(7))▶A;
6*COS(.05*A)▶B;
SIN(.05*A)▶C;
RECT(G1,#9EAB88);
LINE(G1,−B,6-C,B,6+C,#1A1C16);
LINE(G1,−B,C-6,B,−6-C,#1A1C16);
LINE(G1,B,6+C,B,−C-6,#1A1C16);
LINE(G1,−B,6-C,−B,C-6,#1A1C16);
FOR D FROM 0 TO 6 STEP .65 DO
LINE(G1,−B/2+B/6*D,3+D/5*C,−B/2+B/6*D,−3-D/5*C,#1A1C16);
END;
BLIT_P(G0,G1);
WAIT(.1);
END;
END;



I also tried with GETKEY but it only registers 10 keypresses per second.

alexgt

April 21, 2015, 10:21:41 pm #4 Last Edit: April 21, 2015, 10:23:31 pm by alexgt
I want to learn the basics of 3D programming like that is there any good how to's out there (I want MinePrime to be 3D in the future!)

DJ I like the fake lcd color like the Z80 ;P

DJ Omnimaga

Most likely 3D tutorials on Google. IIRC there is a nice raycasting tutorial somewhere too and Critor made a 3D engine in HP PPL. The HP Prime also got FILLPOLY and TRIANGLE commands that can be handy. But yeah i bet that online tutorials can be re-used for calc stuff too.

They can probably be handy for TI-84+ too but much slower of course.

Also with BLIT instead of LINE one could replace the lines with an actual texture if the gaps were removed.

alexgt

PrimeCaster? Also FILLPOLY had a memory issue even when I used the example in the help menu. Thanks for the help :) !

CKH4

Yeah the I had to hack the texture together do to lack of brain power. Anyways that looks really good. I have no idea how to make a less hacky texture. If you find any way to fix it that would be great. Also is there an hp prime boot free equivalent?


DJ Omnimaga

Quote from: alexgt on April 21, 2015, 10:27:50 pm
PrimeCaster? Also FILLPOLY had a memory issue even when I used the example in the help menu. Thanks for the help :) !
Oh it's because the example in the help menu is wrong. The syntax isn't even the right one. I forgot exactly what it is but I think you need to change brackets to parentheses or something else.

Also I think bitmap texture for CKH4 program would not work on the HP Prime because BLIT and DIMGROB don't appear to work at all (most likely the same issue that plagued the HP 39gII), while BLIT_P and DIMGROB_P works fine. So CKH4 engine would not be able to use real textures unless it was ported to pixel-based coordinates instead of window-based ones.
Quote from: CKH4 on April 21, 2015, 10:43:06 pm
Yeah the I had to hack the texture together do to lack of brain power. Anyways that looks really good. I have no idea how to make a less hacky texture. If you find any way to fix it that would be great. Also is there an hp prime boot free equivalent?
The official emulator by HP is free.

CKH4

I think that if you add 30 to each line argument you can use pixel based lines.


DJ Omnimaga

April 21, 2015, 11:05:50 pm #10 Last Edit: April 21, 2015, 11:08:18 pm by DJ Omnimaga
Do you mean incrementing or multiplying? I tried adding 160 to X and 120 to Y and could get a Walrii centered, but I had to scale it up to 24 times its size. Of course it still has the glitch shown in my screenshot earlier but this is how it looks like and run on-calc:



Each column of the sprite are scaled up horizontally to fill 6 pixels in width, which is why it looks weird.

I wonder if with textures that are 8 pixels in width, raycasting would run fast enough...

CKH4

April 21, 2015, 11:15:56 pm #11 Last Edit: April 21, 2015, 11:19:45 pm by CKH4
Cool effect but not to useful long term. I meant for each line to look like this instead:
Line(B+30,6+C+30,B+30,~C-6+30


also where do programs hide on hp prime? nvm I found it.


DJ Omnimaga

Quote from: CKH4 on April 21, 2015, 11:15:56 pm
Cool effect but not to useful long term. I meant for each line to look like this instead:
Line(B+30,6+C+30,B+30,~C-6+30


also where do programs hide on hp prime? nvm I found it.
By not useful do you mean graphical textures are useless?? O.O

Snektron

Legends say if you spam more than DJ Omnimaga, you will become a walrus...


CKH4

DJ that's not quite what I meant. That scaling method isn't helpful although it does look pretty cool. If I could see the code for it I might be able to fix it.


Powered by EzPortal