首先 感谢您的回复
//=================================================================
根据您的建议,我将定义改为如下:
pp = ti.Vector.field(3,ti.f32)
pixels = ti.root.pointer(ti.ij, (n*2, n)).place(pp)
并配合清屏以及赋值部分改为
pixels[i, j] =ti.Vector([0,0,0]) #clear screen
其在清屏代码部分出现问题如下
On line 31 of file "Z:\_PROJECT_\Python\taichi_course\example\chaos\logistics.py":
pixels[i, j] =ti.Vector([0,0,0]) #clear screen 清屏
^^^^^^^^^^^^
Traceback (most recent call last):
File "D:\_PRO\_DEVELOPER\Miniconda3\envs\taichienv\lib\site-packages\taichi\lang\ast\ast_transformer_utils.py", line 24, in __call__
return method(ctx, node)
File "D:\_PRO\_DEVELOPER\Miniconda3\envs\taichienv\lib\site-packages\taichi\lang\ast\ast_transformer.py", line 169, in build_Subscript
node.ptr = impl.subscript(node.value.ptr, *node.slice.ptr)
File "D:\_PRO\_DEVELOPER\Miniconda3\envs\taichienv\lib\site-packages\taichi\lang\util.py", line 214, in
wrapped
return func(*args, **kwargs)
File "D:\_PRO\_DEVELOPER\Miniconda3\envs\taichienv\lib\site-packages\taichi\lang\impl.py", line 211, in
subscript
raise IndexError(
IndexError: Field with dim 0 accessed with indices of dim 2
此类报错就非常让我头痛了 Field 的 dim如何会是0的
但请注意!!!
可以确证该清屏赋值方式适用于原代码pixels = ti.Vector.field(3, ti.f32, shape=(n * 3, n))
的;
//=================================================================
那么好像问题依旧存在
随后我试了试如下赋值
pixels[i, j] =pp(0,0,0) # clear screen
而报错如下:
taichi.lang.exception.TaichiCompilationError:
On line 32 of file "Z:\_PROJECT_\Python\taichi_course\example\chaos\logistics.py":
pixels[i, j] =pp(0,0,0) #clear screen 清屏
^^^^^^^^^
Traceback (most recent call last):
File "D:\_PRO\_DEVELOPER\Miniconda3\envs\taichienv\lib\site-packages\taichi\lang\ast\ast_transformer_utils.py", line 24, in __call__
return method(ctx, node)
File "D:\_PRO\_DEVELOPER\Miniconda3\envs\taichienv\lib\site-packages\taichi\lang\ast\ast_transformer.py", line 384, in build_Call
node.ptr = func(*args, **keywords)
TypeError: 'MatrixField' object is not callable
//=================================================================
emmmmmm 我现在依旧怀疑是否要从定义上下手 …