Ursina:如何组合两个立方体

问题描述

嘿,最近我从 here 学习使用 ursina。
但是如果我要添加更多blocks/cubes,游戏就会滞后很多并且
我发现通过组合所有立方体的网格并渲染一个单孔网格,它不会滞后那么多,但问题是

I can't find a way to combine the mesh of cubes into one big mesh

如果你想要这是我的代码

def update():
    global block_pick,player,block_pickOriginal
    try:
        if block_pick != block_pickOriginal:
            a = Text(blockL[block_pick - 1],scale=1.5,position=Vec2(-.0,-0.35))
            block_pickOriginal = block_pick
            destroy(a,delay=.5)
    except:
        pass

    # print(player.world_position[2] // .5 // 2)

    # print(round(player.x) // .5)

    if held_keys['left mouse'] or held_keys['right mouse']:
        hand.active()
    else:
        hand.passive()

    if held_keys['q']:
        quit()
    if held_keys['1']:
        block_pick = 1
        grid.texture = grassS
    if held_keys['2']:
        block_pick = 2
        grid.texture = stones
    if held_keys['3']:
        block_pick = 3
        grid.texture = woodplankS
    if held_keys['4']:
        block_pick = 4
        grid.texture = dirtS

    if held_keys['5']: block_pick = 5
    if held_keys['6']: block_pick = 6
    if held_keys['7']: block_pick = 7
    if held_keys['8']: block_pick = 8
    if held_keys['9']: block_pick = 9

    if player.world_position[1] < -100: player = FirstPersonController()

    # print(player.world_position[1])


class Voxel(Button):
    def __init__(self,position=(0,0),texture=grass_texture):
        super().__init__(
            parent=scene,position=position,model='assets/block',origin_y=0.5,texture=texture,color=color.color(0,random.uniform(0.9,1)),scale=0.5)

    def input(self,key):
        global voxel

        if self.hovered:
            if key == 'left mouse down':
                punch_sound.play()
                if block_pick == 1: voxel = Voxel(position=self.position + mouse.normal,texture=grass_texture)
                if block_pick == 2: voxel = Voxel(position=self.position + mouse.normal,texture=stone_texture)
                if block_pick == 3: voxel = Voxel(position=self.position + mouse.normal,texture=brick_texture)
                if block_pick == 4: voxel = Voxel(position=self.position + mouse.normal,texture=dirt_texture)
                if block_pick == 5: voxel = Voxel(position=self.position + mouse.normal,texture=coal_texture)
                if block_pick == 6: voxel = Voxel(position=self.position + mouse.normal,texture=glass_texture)
                if block_pick == 7: voxel = Voxel(position=self.position + mouse.normal,texture=iron_texture)
                if block_pick == 8: voxel = Voxel(position=self.position + mouse.normal,texture=gold_texture)
                if block_pick == 9: voxel = Voxel(position=self.position + mouse.normal,texture=diamond_texture)

            if key == 'right mouse down':
                punch_sound.play()
                destroy(self)

for z in range(20):
    for x in range(20):
       voxel = Voxel(position=(x,z))
player = FirstPersonController()

在这link 我找不到用立方体做到这一点的方法 我什至可以用立方体做到这一点吗 bcos在游戏中the cubes isn't going to be the same every time

的几何

任何帮助将不胜感激

谢谢!!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)