kurhlaa Posted December 22, 2017 Share Posted December 22, 2017 Hi, I'm exploring picking options of babylon.js. Doc's example shows how to place the image (first plane) of shot on the second plane. However, if I shoot near the edge of the mesh - texture of the gun shot partly is on the air. Simple example (with white color instead of shot texture): https://www.babylonjs-playground.com/#YHGBXI#2 This looks like air is damaged, what is impossible. So I am thinking about replacing additional plane with additional texture, which will be on the existing one. I've found a way to get picked face ID, coordinates of globally picked point, coordinates of picked point on the specific face/texture - lines 26-28. But I can't find a way to place a non-repeatable (and with image's original size) secondary texture at that point. By "non-repeatable" I mean to draw it only once on a mesh, in the specific place, not 100 times all around it. Is that possible? This way if I shoot near the edge of an object - I'll see only part of the damage image, what is correct. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted December 22, 2017 Share Posted December 22, 2017 Hi K! This surely started as "decal hell". I'll float/wait, as deltakosh is in the thread with me (HI DK). Decals along sharp edges/corners... has always been a rough area of town. But that's not the topic. I might reply more... soon. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 22, 2017 Share Posted December 22, 2017 I think decals could be one alternative: http://www.babylonjs.com/demos/decals/ Quote Link to comment Share on other sites More sharing options...
Wingnut Posted December 22, 2017 Share Posted December 22, 2017 Oh, yeah, I was thinking that our picking demo http://playground.babylonjs.com/?11 was already using decals, and that kurhlaa removed them. Duh. Sorry. Wingnut dummy. Also, border-of-boxes (picture frame) might hide shot textures that are "hanging in air". But yeah, decals might work! Good idea. Also, there is a complicated solve.... using dynamicTexture's context2d... https://www.w3.org/TR/2dcontext/#drawing-images-to-the-canvas context.drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) All that dx, dy, dw, dh is for destination. i.e. Where to place SOME image... onto another image's canvas. Then you use dynamicTexture.update(). I think this image-atop-image stuff was once called 'compositing', but that term might mean something different, these days. I don't have any PG's that show this, but, some adventuresome forumer might try it. A PG search for 'drawImage' might produce results, too. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 22, 2017 Share Posted December 22, 2017 HEHE! I was thinking about this as well but you were faster Wingnut 1 Quote Link to comment Share on other sites More sharing options...
kurhlaa Posted December 22, 2017 Author Share Posted December 22, 2017 Great, seems it's very easy to use decals! I hope it's something lightweight? Wingnut 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 26, 2017 Share Posted December 26, 2017 Kind of Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.