Jump to content

Doubt about inverted texture


none-9999
 Share

Recommended Posts

Hi for all, i have this situation, do not know why

dudaBaby.thumb.png.fece05a48a52d17211a09699bc4d118d.png

 

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");

 

 

 

 

 

Link to comment
Share on other sites

Hi, this happened :

 

babyDouct4.thumb.png.7ffa5a01e9ea677efc3203becf0d1d4e.png

 

//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);

 

Link to comment
Share on other sites

ok, now

 

baby7.thumb.png.fd685e7d5312f2186fa955f8f96069b5.png

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..

 

baby8.thumb.png.37b2bf3937d7c6718e79829818b6a9e3.png

the logos should be on the right wing

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

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... :D

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...