Artem Posted February 22, 2014 Share Posted February 22, 2014 Hello, I'm pretty new to Babylon.js (almost a week for now), it was okay until I started to ask more and more of it. I searched for answers a lot, in Google and here, on forums, but no success. So, here's some questions of mine that I can't deal with: [1] How can I set up 32x32 pixels image to stay sharp on some pretty big cube mesh? I found 'noMipmap' parameter for 'BABYLON.Texture', but I don't understand how to use it, what's 'type' thing? I need something like nearest neighbour thing. Any thoughts?[EDIT]: So, 'noMipmap' and 'invertY' both use 'true' or 'false', right? I found Babylon.js documentation here and it says 'type', not 'boolean', I'm confused (maybe I just don't know some simple things). 'noMipmap' works if things getting smaller, but not bigger or it works both ways, but uses exactly 'smooth' thing?[EDIT2]: I've set texture to 512x512 and I feel fine about it for now. "I'm a blurryful!".[-^o ^ - . .], [2] How to apply texture to chosen side (polygon) of mesh (box) only? As far as I know I can use Blender for that, but is there a thing that I can use while using code only?[EDIT]: I found out that I can use that one (not tried yet though):materialName.reflectionTexture = new BABYLON.CubeTexture("folder/filename", scene);materialName.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;// filename_nx.png, filename_ny.png, filename_nz.png, filename_px.png, filename_py.png, filename_pz.png[3] How to get 'lookAt' method be instant instead of slowly rotate meshes to target?[EDIT]: I stopped pulling my hair off and just placed piggy sprite inside of mesh (just copied its position), also applied 1x1 alpha texture to the mesh, at least I've got almost the same result I wanted (mesh has physics).[EDIT2]: Just found .isVisible and set it to false instead of adding materials and set transparent texture for them. Removed '.setPhysicsState' for mesh and calculate stuff like some simple platformer now. Sprite checks its position through '.runRenderLoop' function. "Dusk is getting closer, oink!" [4] Is there any function or method I can use to calculate shadow using texture instead of mesh itself (shadow of sprite)? [5] How can I get rid of white outline around texture which has 'hasAlpha' set to 'true'? [6] Sometimes it takes too long to load textures (about 15s or more), any idea why? [7] How to send physics to sleep when its not used and if it stays calm and touches nothing except floor where it lays for a few? [8] How to tell mesh that has '.setPhysicsState' to check collision with mesh that doesn't has it (not .intersectsMesh though, but to react if first mesh has '.setPhysicsState' as well, while it doesn't)? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 24, 2014 Share Posted February 24, 2014 Hi Artem! Welcome to the forum. Have you ever considered using a 3D model of a pig, such as these... http://tinyurl.com/l8jrwyx instead of using sprites? Maybe find one that has a low polygon/face count, and you could still have many pigs in the scene and not slow too much. You can use the free Blender modeling software to export a pig model using the BabylonJS export for Blender. This COULD cause some problem for the imposter shape used in setPhysicsState. #4 - Using a model would fix your shadows, too, but keep in mind that shadows use much CPU power... especially true if you have many many pigs. #6 - I have never had this problem, but this COULD BE that your disk drive is going into 'sleep mode' and needs time to wake up before loading a texture. Maybe try setting your disk drive to NOT SLEEP, especially if it is an external drive. I am guessing here, but maybe. #7 - Cannon.js physics engine... and many others... have that jiggle-when-idle problem for some reason. It is being studied by many, but few solutions have been found. MAYBE one way is to somehow check for pig movement, and if 'stopped', then again pig.setPhysicsState with mass: 0, friction: 0, restitution: 0 . Then check for .intersectsMesh in render loop, and if true, quickly setPhysicsState AGAIN with mass, friction, restitution > 0. This is an idea to test. No promises. Maybe others will have more ideas. Maybe another idea is to keep your pig's feet... a small distance above the ground when they are stopped. *shrug* #8 - This is related to #7. Maybe by loop checking .intersectsMesh, you can setPhysicsState only when needed. Again, I do not know if this will work. But... first set all pigs and other physics objects... to a 'idle' physics state... maybe like this... pig.checkCollisions = true;pig.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: 0, friction: 0, restitution: 0 }) then constantly check all pigs for .intersectsMesh inside the render loop... for (pig in pen) { if (pen[pig].intersectsMesh(fence)) { // try to quickly cause a physics reaction pen[pig].setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: .5, friction: .5, restitution: 2 }) }} It would be good if there was... mesh.isColliding -> boolean ... but I could not find one. If there WAS one... you could use... if (pen[pig].isColliding())... then pen[pig].setPhysicsState(options) . Maybe It will be added someday soon. I like using URL ... http://doc.babylonjs.com ... to look and learn things. I am not a very good programmer, so maybe these things will not work... but they are some ideas. Again, welcome. Good questions! Maybe smarter people than I will respond soon. Be well, keep experimenting. Your project is very interesting! Quote Link to comment Share on other sites More sharing options...
Artem Posted February 26, 2014 Author Share Posted February 26, 2014 Hi Artem! Welcome to the forum. Have you ever considered using a 3D model of a pig, such as these... http://tinyurl.com/l8jrwyx instead of using sprites? Maybe find one that has a low polygon/face count, and you could still have many pigs in the scene and not slow too much. You can use the free Blender modeling software to export a pig model using the BabylonJS export for Blender. This COULD cause some problem for the imposter shape used in setPhysicsState. #4 - Using a model would fix your shadows, too, but keep in mind that shadows use much CPU power... especially true if you have many many pigs. #6 - I have never had this problem, but this COULD BE that your disk drive is going into 'sleep mode' and needs time to wake up before loading a texture. Maybe try setting your disk drive to NOT SLEEP, especially if it is an external drive. I am guessing here, but maybe. #7 - Cannon.js physics engine... and many others... have that jiggle-when-idle problem for some reason. It is being studied by many, but few solutions have been found. MAYBE one way is to somehow check for pig movement, and if 'stopped', then again pig.setPhysicsState with mass: 0, friction: 0, restitution: 0 . Then check for .intersectsMesh in render loop, and if true, quickly setPhysicsState AGAIN with mass, friction, restitution > 0. This is an idea to test. No promises. Maybe others will have more ideas. Maybe another idea is to keep your pig's feet... a small distance above the ground when they are stopped. *shrug* #8 - This is related to #7. Maybe by loop checking .intersectsMesh, you can setPhysicsState only when needed. Again, I do not know if this will work. But... first set all pigs and other physics objects... to a 'idle' physics state... maybe like this... pig.checkCollisions = true;pig.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: 0, friction: 0, restitution: 0 }) then constantly check all pigs for .intersectsMesh inside the render loop... for (pig in pen) { if (pen[pig].intersectsMesh(fence)) { // try to quickly cause a physics reaction pen[pig].setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: .5, friction: .5, restitution: 2 }) }} It would be good if there was... mesh.isColliding -> boolean ... but I could not find one. If there WAS one... you could use... if (pen[pig].isColliding())... then pen[pig].setPhysicsState(options) . Maybe It will be added someday soon. I like using URL ...http://doc.babylonjs.com ... to look and learn things. I am not a very good programmer, so maybe these things will not work... but they are some ideas. Again, welcome. Good questions! Maybe smarter people than I will respond soon. Be well, keep experimenting. Your project is very interesting! Hello! Thank you I'd love to use 3D models but it really isn't how I see my game, it should be pixelated for a reason. I tried to find a way to extrude sprites, but no luck, it looks like I need to forget about it for a while, until I'll figure out how to write my own script for it. Yeah, I thought about it and it looks like I'll be using circle shadows below sprites, which is kind of a sad way. I'd love to use voxel meshes instead of sprites, though, which would help me a lot with different issues (shadows, for example) I have at moment, but I doubt it'll be better for performance (need to test different ways first). Also it would be much harder to make animations too. I never thought about hard drive, thanks a lot for the tip! I'll try it out! I never had that problem with physi.js, but I still prefer cannon.js. Yeah, I think I'll just calculate speed of meshes (sprites are in meshes) and will throw a timer, which disables physics properties if speed of meshes is lower than some integer, then I'll wake them up using 'intersectsMesh'. That should work, I hope. Thanks. Yeah, thank you, I thought about it as well (a bit), but I keep worrying about few things. For example, pig throws a ball to another pig (ball is a mesh, that doesn't use 'setPhysicsState'), ball has some speed and some vector to move to, but wouldn't it stop if I just give him 'setPhysicsState'? I want ball still has it's movement speed and etc. Not sure if it'll work, but I need to try it, definitely! Hehe, yeah, I use this documentation a lot, playing with random things all the time Actually I think some of these may work (I really hope some will). You helped me to sort some things out for sure, Wingnut. Thank you once again for your time and for all of your tips, that help won't be forgotten Wingnut 1 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.