cnCalc计算器论坛

 找回密码
 注册
搜索
查看: 717|回复: 1

[fx-9860/9750] 尝试实现fx9860的3D图形绘制,发现居然可行??

[复制链接]
发表于 2022-10-22 10:34:41 | 显示全部楼层 |阅读模式
本帖最后由 hellboyxxx 于 2022-10-22 10:33 编辑

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

1

1

2

2

3

3

4

4

5

5

视频放在附件里了,有兴趣可以看看
7.mp4 (13.23 MB, 下载次数: 6) 8.mp4 (4.68 MB, 下载次数: 3)

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

6

6


以下是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
[[R1+R2cos Theta,R2sin Theta,0]]->Vct E
'xyz translation
[[1,0,0][0,cos a,(-)sin a][0,sin a,cos a]]->Mat A
[[cos b,0,sin b][0,1,0][(-)sin b,0,cos b]]->Mat B
[[cos c,(-)sin c,0][sin c,cos c,0][0,0,1]]->Mat C

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

'output real donut location
Vct F[1,1]->x
Vct F[1,2]->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

发表于 2022-10-31 21:50:47 | 显示全部楼层
有一个可以显著加快绘制速度的方法:用超频软件Ftune。进去之后在check memory界面直接选NO[F6],然后按F5直接超频到230+Mhz
接着就退出享受超高速计算的快乐吧♪(^∀^●)ノ

FTUNE2.G1A

55.68 KB, 下载次数: 1

超频软件

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|cnCalc计算器论坛

GMT+8, 2022-11-29 18:14 , Processed in 0.052207 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表