hellboyxxx 发表于 2022-10-22 10:34:41

尝试实现fx9860的3D图形绘制,发现居然可行??

本帖最后由 hellboyxxx 于 2022-10-22 10:33 编辑

pAn:
上午看bili学代数
下午磕磕碰碰做了一个甜甜圈的3D渲染
用c.basic实现的,据说是比自带的basic快十倍
虽然最终显示效果超级慢。。。。。
不知道是不是sh3性能问题,麻烦高手指出代码中可以优化的地方
如图

视频放在附件里了,有兴趣可以看看


原理非常简单
就是先做出甜甜圈的截面圆
分别经过yxz轴的变换并投射xy点在屏幕上即可
下面是草稿


以下是c.basic代码,每一部分都加了注释,可以仔细看看
'ProgramMode:RUN

'init
ViewWindow (-)24,128,0,(-)8,64,0
Screen.G
Deg
Local Theta,a,b,c,x,y,m,n,p,q,R1,R2,K1,K2,D1,D2,D3,D4,S1,S2

'donut radient
30->R1
'donut thickness
10->R2
'distance from screen to camera
30->K1
'distance from donut to screen
30->K2

'startangle for xyz axes rotation
(-)90->D1
(-)60->D2
(-)60->D3
(-)30->D4

'step,drawing precision
30->S1
20->S2

{3,3}->Dim Mat A
{3,3}->Dim Mat B
{3,3}->Dim Mat C
{3,1}->Dim Vct E
{3,1}->Dim Vct F

Cls

'start loop
While 1

'rotation on z axes 4th
For D4->c To D4+360 Step S2
'rotation on x axes 3rd
For D3->a To D3+360 Step S2
Cls
'rotation on y axes 2nd
For D2->b To D2+360 Step S2
'rotate donut ring 1st
For D1->Theta To D1+360 Step S1

'donut ring
[]->Vct E
'xyz translation
[]->Mat A
[[(-)sin b,0,cos b]]->Mat B
[]->Mat C

'input all translation at once
Vct E*Mat B*Mat A*Mat C->Vct F

'output real donut location
Vct F->x
Vct F->y

'save last location
m->p
n->q

'output the screen location,frac means divide by
x*K1frac(K1+K2-R2)+64->m
y*K1frac(K1+K2-R2)+32->n

'option to draw dots
'__Pixel _m,n,1

'option to draw lines from last location to current location
_Line p,q,m,n,1

'info print on screen
Text 0,0,"R1:"+ToStr(R1)
Text 7,0,"R2:"+ToStr(R2)
Text 14,0,"K1:"+ToStr(K1)
Text 21,0,"K2:"+ToStr(K2)
Text 28,0,"_Theta_:"+ToStr(Theta)
Text 35,0,"b:"+ToStr(b)
Text 42,0,"a:"+ToStr(a)
Text 49,0,"c:"+ToStr(c)
Text 0,28,"a 3d donut basic render"
Text 7,43,"in super slow motion"
Text 57,75,"pAn signature."

'start drawing
_DispVram

Next
Next
'enjoy the view
TicksWait 128
Next
Next

WhileEnd

3536466 发表于 2022-10-31 21:50:47

有一个可以显著加快绘制速度的方法:用超频软件Ftune。进去之后在check memory界面直接选NO,然后按F5直接超频到230+Mhz
接着就退出享受超高速计算的快乐吧♪(^∀^●)ノ

hellboyxxx 发表于 2022-12-4 19:18:18

3536466 发表于 2022-10-31 21:50
有一个可以显著加快绘制速度的方法:用超频软件Ftune。进去之后在check memory界面直接选NO,然后按F5 ...

好是好,但是老机器寿命短不敢用啊
页: [1]
查看完整版本: 尝试实现fx9860的3D图形绘制,发现居然可行??