Hello all,
for my new project I need a procedure cut hole in the wall, for example changing the different positions of the window in the wall.
I think the best solution for this is the stencil mask.
I wanted to start from this example https://playcanvas.com/editor/scene/448915
But with the new version of Playcanvas this example not working.
Do you have any ideas for repair this example?
Thanks for any advice.
I think it’d be far more efficient (and probably easier) to simply procedurally slice up the polygons of a wall as the opening moves around.
Hello Will,
I progress with creating ‘procedural’ holes in the wall. Everything works fine except one thing:
When I look through window, every meshes with blending materials are not visible ( glass, another wall ). At least I think that is due to blending materials.
Do you have any idea/solution how improve this ?
Here is my project:
https://playcanvas.com/editor/scene/681120
for MASK I use (plane mesh used as marks for window)
// code here
var meshInstance = this.entity.model.model.meshInstances[0];
var mat = meshInstance.material;
mat.stencilFront = mat.stencilBack = new pc.StencilParameters({
ref: this.maskId,
});
mat.redWrite = mat.greenWrite = mat.blueWrite = mat.alphaWrite = false; // don't write to color, only to stencil
mat.update();
and for MASKED ( wall )
var meshInstance = this.entity.model.model.meshInstances[0];
var mat = meshInstance.material.clone();
meshInstance.layer = pc.LAYER_WORLD - 1; // draw after all stencil masks are drawn
//
mat.update();
this.entity.model.model.meshInstances[0].material = mat;
Hey @AGP I am trying to cut hole in a mesh at run time but I am not able to do so, can you please make a test public project showing how the windows are cut ?
I would be very grateful, Thanks.