none-9999 Posted November 25, 2017 Share Posted November 25, 2017 Hi for all, i have this situation, do not know why my code for that material: function Nave(name, textureMat){ this.name = name; //after by constructor add the mes from .obj file. this.mesh ={}; this.material= new BABYLON.StandardMaterial(this.name+"_material", scene); this.material.diffuseColor = new BABYLON.Color3(0.8, 0.8, 0.8); this.material.specularColor = new BABYLON.Color3(0.05, 0.05, 0.05); this.material.invertU = -1; if(textureMat != null){ this.material.diffuseTexture = new BABYLON.Texture("texturas/"+textureMat, scene); } //...... } //in load of .obj file BABYLON.SceneLoader.ImportMesh("","", "naveTierraSolo.obj", scene, function (meshes) { naves[0].mesh=meshes[0]; carga.cargados +=1; naves[0].mesh.material = naves[0].material; //... }); naves[0] = new Nave("shipPlayer", "naveTierraSolo.png"); JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
SinhNQ Posted November 25, 2017 Share Posted November 25, 2017 You can try: if(textureMat != null){ this.material.diffuseTexture = new BABYLON.Texture("texturas/"+textureMat, scene, false, false); } Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 25, 2017 Share Posted November 25, 2017 Is the invertU in your code intented ? This is not available on material and should be placed on the texture u scale. Quote Link to comment Share on other sites More sharing options...
none-9999 Posted November 26, 2017 Author Share Posted November 26, 2017 i tried : this.material.diffuseTexture = new BABYLON.Texture("texturas/"+textureMat, scene, false, false); and and tried with false,false; false,true; true,false; true,true; and nothing Quote Link to comment Share on other sites More sharing options...
none-9999 Posted November 26, 2017 Author Share Posted November 26, 2017 settings at the moment export obj from blender Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 27, 2017 Share Posted November 27, 2017 Can you try material.diffuseTexture.uScale = -1; // Mirror Horizontally material.diffuseTexture.vScale = -1; // Mirror Vertically Quote Link to comment Share on other sites More sharing options...
none-9999 Posted November 28, 2017 Author Share Posted November 28, 2017 Hi, this happened : //this.material.invertU = -1; if(textureMat != null){ //this.material.diffuseTexture = new BABYLON.Texture("texturas/"+textureMat, scene); this.material.diffuseTexture = new BABYLON.Texture("texturas/"+textureMat, scene,true,true); this.material.diffuseTexture.uScale = -1; // Mirror Horizontally this.material.diffuseTexture.vScale = 1; // Mirror Vertically } the import coordinates of blender .. maybe? //load obj BABYLON.SceneLoader.ImportMesh("","", "naveTierraSolo.obj", scene, function (meshes) { //console.log(meshes); naves[0].mesh=meshes[0]; carga.cargados +=1; naves[0].mesh.material = naves[0].material; naves[0].mesh.rotation=new BABYLON.Vector3(0, Math.PI/4, 0);//to look at 0 degrees... naves[0].flash.parent=naves[0].mesh; camera = new BABYLON.UniversalCamera("UniversalCamera", new BABYLON.Vector3(-10, 50, -10), scene); camera.position.x = naves[0].mesh.position.x; camera.position.y = naves[0].mesh.position.y+vHol; camera.position.z = naves[0].mesh.position.z; camera.rotation=new BABYLON.Vector3(0, 0, 0); camera.attachControl(canvas, true); camera.setTarget(naves[0].mesh.position); naves[0].turbina = new BABYLON.ParticleSystem("particles", 200, scene); naves[0].turbina.particleTexture = new BABYLON.Texture("sprites/Flare.png", scene); naves[0].turbina.textureMask = new BABYLON.Color4(0.1, 0.8, 0.8, 1.0); naves[0].turbina.emitter = naves[0].mesh; naves[0].turbina.minEmitBox = new BABYLON.Vector3(-4, 0.3, 0); // Starting all from naves[0].turbina.maxEmitBox = new BABYLON.Vector3(-4, 0.3, 0); // To... naves[0].turbina.color1 = new BABYLON.Color4(0.7, 0.8, 1.0, 1.0); naves[0].turbina.color2 = new BABYLON.Color4(0.2, 0.5, 1.0, 1.0); naves[0].turbina.colorDead = new BABYLON.Color4(0, 0, 0.0, 0.0); naves[0].turbina.minSize = 2; naves[0].turbina.maxSize = 5; naves[0].turbina.targetStopDuration = 0.15; naves[0].turbina.minLifeTime = 0.1; naves[0].turbina.maxLifeTime = 0.4; naves[0].turbina.emitRate = 50; naves[0].turbina.blendMode = BABYLON.ParticleSystem.BLENDMODE_STANDARD; }); code to follow mouse var mouseControl={mx:0, my:0, segx:0, segy:0, easing : 0.05} var yo_mov={x:1, y:10, z:0, v:0.0, on:false, gra:0, rad:0.0, cuadr:0, nCuadr:0, radF:0}//my movement //in init, features display (size and medium) dPantalla.w = window.innerWidth; dPantalla.h = window.innerHeight; dPantalla.rx = ~~(dPantalla.w/2); dPantalla.ry = ~~(dPantalla.h/2); //event mousemove canvas.addEventListener("mousemove", function (evt) { mouseControl.mx = evt.pageX; mouseControl.my = evt.pageY; }); //in update //follow mouse mouseControl.segx += (mouseControl.mx - mouseControl.segx) * mouseControl.easing; mouseControl.segy += (mouseControl.my - mouseControl.segy) * mouseControl.easing; //get angle from betwen center and dot that follow at cursor yo_mov.rad = Math.atan2(mouseControl.segy - dPantalla.ry, mouseControl.segx - dPantalla.rx); if(yo_mov.rad < 0)yo_mov.rad+=(Math.PI*2); naves[0].mesh.rotation = new BABYLON.Vector3(0, yo_mov.rad+(Math.PI/4), 0); Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 28, 2017 Share Posted November 28, 2017 Could you please create a new issue for the sprite, and try to repro in a playground ? This can also come from the fact you are apply -1 for all the textures of your obj not the flipped one only. Quote Link to comment Share on other sites More sharing options...
none-9999 Posted November 28, 2017 Author Share Posted November 28, 2017 you can try in this url : https://turret.000webhostapp.com/ Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted November 28, 2017 Share Posted November 28, 2017 If the sprite is inheriting the meshes rotation then it sounds like it is a child of the mesh (which if its a bullet it should not be). Did you figure out the UV problem? Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 28, 2017 Share Posted November 28, 2017 @diyo-games debugging your full scene is not the friendliest way and won t help other forum readers. Could you please create a babylon playground dedicated to your sprite issue and start a new thread as the texture rotation has been addressed ? this helps other user when they are looking for a similar issue. Quote Link to comment Share on other sites More sharing options...
none-9999 Posted November 28, 2017 Author Share Posted November 28, 2017 the problem is not the sprite, it is spinning well (or was spinning well), it is more a sign that something is wrong with the mesh of the ship, but the weird is like the mesh turns, but not the texture .. . Quote Link to comment Share on other sites More sharing options...
none-9999 Posted November 28, 2017 Author Share Posted November 28, 2017 25 minutes ago, Pryme8 said: Si el sprite está heredando la rotación de mallas, parece que es un elemento secundario de la malla (que si no es una bala no debería ser). ¿Descubriste el problema UV? I Did not understand Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 28, 2017 Share Posted November 28, 2017 I can not see any issue. could you highlight with a picture maybe ? Quote Link to comment Share on other sites More sharing options...
none-9999 Posted November 28, 2017 Author Share Posted November 28, 2017 ok, I will go back to the beginning .. Quote Link to comment Share on other sites More sharing options...
none-9999 Posted November 28, 2017 Author Share Posted November 28, 2017 ok, now the ship "class" function Nave(name, textureMat, isMine){ this.name = name; //after by constructor add the mes from .obj file. this.isMine = isMine; this.mesh ={}; this.material= new BABYLON.StandardMaterial(this.name+"_material", scene); this.material.diffuseColor = new BABYLON.Color3(0.8, 0.8, 0.8); this.material.specularColor = new BABYLON.Color3(0.05, 0.05, 0.05); //this.material.invertU = -1; if(textureMat != null){ //this.material.diffuseTexture = new BABYLON.Texture("texturas/"+textureMat, scene); this.material.diffuseTexture = new BABYLON.Texture("texturas/"+textureMat, scene); //this.material.diffuseTexture.uScale = -1; // Mirror Horizontally //this.material.diffuseTexture.vScale = 1; // Mirror Vertically } //.... } load .obj BABYLON.SceneLoader.ImportMesh("","", "naveTierraSolo.obj", scene, function (meshes) { //console.log(meshes); naves[0].mesh=meshes[0]; carga.cargados +=1; naves[0].mesh.material = naves[0].material; naves[0].mesh.rotation=new BABYLON.Vector3(0, Math.PI/4, 0); naves[0].flash.parent=naves[0].mesh; camera = new BABYLON.UniversalCamera("UniversalCamera", new BABYLON.Vector3(-10, 50, -10), scene); camera.position.x = naves[0].mesh.position.x; camera.position.y = naves[0].mesh.position.y+vHol; camera.position.z = naves[0].mesh.position.z; camera.rotation=new BABYLON.Vector3(0, 0, 0); camera.attachControl(canvas, true); camera.setTarget(naves[0].mesh.position); naves[0].turbina = new BABYLON.ParticleSystem("particles", 200, scene); naves[0].turbina.particleTexture = new BABYLON.Texture("sprites/Flare.png", scene); naves[0].turbina.textureMask = new BABYLON.Color4(0.1, 0.8, 0.8, 1.0); naves[0].turbina.emitter = naves[0].mesh; naves[0].turbina.minEmitBox = new BABYLON.Vector3(-4, 0.3, 0); // Starting all from naves[0].turbina.maxEmitBox = new BABYLON.Vector3(-4, 0.3, 0); // To... naves[0].turbina.color1 = new BABYLON.Color4(0.7, 0.8, 1.0, 1.0); naves[0].turbina.color2 = new BABYLON.Color4(0.2, 0.5, 1.0, 1.0); naves[0].turbina.colorDead = new BABYLON.Color4(0, 0, 0.0, 0.0); naves[0].turbina.minSize = 2; naves[0].turbina.maxSize = 5; naves[0].turbina.targetStopDuration = 0.15; naves[0].turbina.minLifeTime = 0.1; naves[0].turbina.maxLifeTime = 0.4; naves[0].turbina.emitRate = 50; naves[0].turbina.blendMode = BABYLON.ParticleSystem.BLENDMODE_STANDARD; }); rotation the ship in loop canvas.addEventListener("mousemove", function (evt) { // Watch for browser/canvas resize events mouseControl.mx = evt.pageX; mouseControl.my = evt.pageY; }); mouseControl.segx += (mouseControl.mx - mouseControl.segx) * mouseControl.easing; mouseControl.segy += (mouseControl.my - mouseControl.segy) * mouseControl.easing; yo_mov.rad = Math.atan2(mouseControl.segy - dPantalla.ry, mouseControl.segx - dPantalla.rx); if(yo_mov.rad < 0)yo_mov.rad+=(Math.PI*2); naves[0].mesh.rotation = new BABYLON.Vector3(0, yo_mov.rad+(Math.PI/4), 0); } but the probles is before to apply any rotation.. the logos should be on the right wing Quote Link to comment Share on other sites More sharing options...
none-9999 Posted November 28, 2017 Author Share Posted November 28, 2017 the .obj file shipEarthOnly.zip Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted November 28, 2017 Share Posted November 28, 2017 19 minutes ago, diyo-games said: I Did not understand " 45 minutes ago, Pryme8 said: Si el sprite está heredando la rotación de mallas, parece que es un elemento secundario de la malla (que si no es una bala no debería ser). ¿Descubriste el problema UV?" Whoa, I never said that!!! lol no habla espanol Quote Link to comment Share on other sites More sharing options...
none-9999 Posted November 28, 2017 Author Share Posted November 28, 2017 1 minute ago, Pryme8 said: " 45 minutes ago, Pryme8 said: Si el sprite está heredando la rotación de mallas, parece que es un elemento secundario de la malla (que si no es una bala no debería ser). ¿Descubriste el problema UV?" Whoa, I never said that!!! lol no habla espanol sorry, traslate... Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted November 28, 2017 Share Posted November 28, 2017 7 minutes ago, diyo-games said: ok, now BABYLON.SceneLoader.ImportMesh("","", "naveTierraSolo.obj", scene, function (meshes) {naves[0].turbina.emitter = naves[0].mesh; Make a blank mesh that is the parentented to the ship, position it where you want on the ship and set the emitter to that blank mesh instead of the ship. give that a shot. Quote Link to comment Share on other sites More sharing options...
none-9999 Posted November 28, 2017 Author Share Posted November 28, 2017 2 minutes ago, Pryme8 said: Make a blank mesh that is the parentented to the ship, position it where you want on the ship and set the emitter to that blank mesh instead of the ship. give that a shot. thereby ? Quote Link to comment Share on other sites More sharing options...
none-9999 Posted November 28, 2017 Author Share Posted November 28, 2017 I had a turbine that was a mesh, the idea was to make it semi transparent, but it did not work well, that's why I implemented the particle system as a gas jet. even this problem was already (so far I am reviewing) Quote Link to comment Share on other sites More sharing options...
none-9999 Posted November 28, 2017 Author Share Posted November 28, 2017 Well, I want to think that this is solved by placing all the objects in a scene, then use the babylon exporter and in the code go through the meshes and create the instances. For now I will continue with other parts of the development, many thanks Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted November 28, 2017 Share Posted November 28, 2017 https://pryme8.github.io/LSBAG/ A-D for left and right, space to fire. This shows how to set up a ship with particles like you want.https://github.com/Pryme8/LSBAG/blob/gh-pages/js/game.js Quote Link to comment Share on other sites More sharing options...
none-9999 Posted November 28, 2017 Author Share Posted November 28, 2017 great... and it not move ..? 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.