i'm creating Minecraft in ursina.i create a chunk through add virtices to a Mesh model.But now I have a problem, I can not delete the vertices in Mesh.An error occurs each time the Mesh. Generate ()
the following is how i try to delete the vertices and error.
from ursina import *from ursina.shaders import basic_lighting_shader, lit_with_shadows_shaderfrom ursina.prefabs.first_person_controller import FirstPersonControllerapp = Ursina()bte = Entity(model='block.obj',color=color.rgba(1,1,0,0.4),visible=False)bte.scale=1.1bte.origin_y+=0.05sun = DirectionalLight(rotation=Vec3(45, 45, 45))virtices = [# 底面 [0, 0, 0], #0 [0, 0, 1], #1 [1, 0, 1], #2 [1, 0, 1], #3 [1, 0, 0], #4 [0, 0, 0], #5 # 顶面 [0, 1, 0], #0 [1, 1, 0], #1 [1, 1, 1], #2 [1, 1, 1], #3 [0, 1, 1], #4 [0, 1, 0], #5 # 左面 [0, 0, 0], #0 [0, 1, 0], #1 [0, 1, 1], #2 [0, 1, 1], #3 [0, 0, 1], #4 [0, 0, 0], #5 # 右面 [1, 0, 0], #0 [1, 0, 1], #1 [1, 1, 1], #2 [1, 1, 1], #3 [1, 1, 0], #4 [1, 0, 0], #5 # 前面 [0, 0, 0], #0 [1, 0, 0], #1 [1, 1, 0], #2 [1, 1, 0], #3 [0, 1, 0], #4 [0, 0, 0], #5 # 后面 [0, 0, 1], #0 [0, 1, 1], #1 [1, 1, 1], #2 [1, 1, 1], #3 [1, 0, 1], #4 [0, 0, 1], #5 ]normals = [[-1 if number == 0 else number for number in sublist] for sublist in virtices]amesh = Mesh()amesh.normals.extend(normals)amesh.uvs.extend([[0,0], [0,1], [1,1], [1,1], [1,0], [0,0], # 底面 [0,0], [1,0], [1,1], [1,1], [0,1], [0,0], # 顶面 [0,0], [0,1], [1,1], [1,1], [1,0], [0,0], # 左面 [0,0], [1,0], [1,1], [1,1], [0,1], [0,0], # 右面 [0,0], [1,0], [1,1], [1,1], [0,1], [0,0], # 前面 [0,0], [0,1], [1,1], [1,1], [1,0], [0,0], # 后面 ])amesh.vertices.extend(virtices)amesh.vertices.remove([0, 0, 0])amesh.generate()
error:
:prc(warning): Invalid integer value for ConfigVariable win-size:864.0 :prc(warning): Invalid integer value for ConfigVariable win-size: 1536.0 Known pipe types: wglGraphicsPipe (3 aux displaymodules not yet loaded.) set window position: Vec2(192, 108):prc(warning): changing default value for ConfigVariablepaste-emit-keystrokes from '1' to '0'. :pnmimage:png(warning): iCCP:known incorrect sRGB profile package_folder:D:\MiniConda\Lib\site-packages\ursina asset_folder:d:\Downloads\myCode\Python\小游戏\Minecraft-Ursina-2.0 read obj at:d:\Downloads\myCode\Python\小游戏\Minecraft-Ursina-2.0\assets\block.objsaved .bam to: d:\Downloads\myCode\Python\小游戏\Minecraft-Ursina-2.0\models_compressed\block.bam Assertion failed:(num_vertices + num_unused_vertices_per_primitive) %(num_vertices_per_primitive + num_unused_vertices_per_primitive) == 0at line 388 ofc:\buildslave\sdk-windows-amd64\build\panda\src\gobj\geomPrimitive.cxxTraceback (most recent call last): File"d:\Downloads\myCode\Python\小游戏\Minecraft-Ursina-2.0\test.py", line75, in amesh.generate() File "D:\MiniConda\Lib\site-packages\ursina\mesh.py", line 139, in generateprim.close_primitive() AssertionError: (num_vertices + num_unused_vertices_per_primitive) % (num_vertices_per_primitive +num_unused_vertices_per_primitive) == 0 at line 388 ofc:\buildslave\sdk-windows-amd64\build\panda\src\gobj\geomPrimitive.cxx
hoping someone can help me,thanks!!