Where are my triangles stored?

I use triangles for my terrain. Triangles are created with vertexes and not with a hightmap.
Now I want the player to dig a hole in the ground and have to alter some of my triangles. I can do the rigidbody and collisons but i can’t access the mesh:

        this.mesh = pc.createMesh(this.app.graphicsDevice, this.positions, options);

        this.node.name = line+row.toString()+'-'+collum.toString();
        this.setGroundParameter(); // reset before randomnize
        var instance = new pc.MeshInstance(this.node, this.mesh, this.chooseGroundSkin());
        this.model = new pc.Model();
        this.model.graph = this.node;
        this.model.meshInstances = [ instance ];

        this.node.tag  = 'GroundAttributes';
        CurrentTerrain = this.entity.children;
        CurrentNumber = CurrentTerrain.length -1; 
        this.model.tag = 'Triangle';
        this.model.receiveShadows = true;

I’ve tryed to add the model somwhere else, but it wont be visible than. Or use findByTag but only got an empty array.

Any hint as always very welcome,

the game is quite confusing, but’s from the ‘farmland’ scene; ‘HomeBase’ entity and the ‘buildTerrain’ script, but i would’t try look this up :crazy_face:

thanx Gurki

This is probably a good example to inspect

It loads the statue mesh, which contains multiple MeshInstances. It finds them all, and each frame modifies their positions.

Also this could give you further ideas:


Thanx :smiling_face_with_three_hearts:
yes I think I can experiment with some lines of this


1 Like