Bricktheworld

Members
  • Content count

    22
  • Joined

  • Last visited

  1. Sending Rotation of Player with Node and Socket.io

    Thank you Jaskar, I have tried to do this but whenever I try to send the rotation, it is always 0. Is this because I am sending it as rotation.x, rotation.y, and rotation.z? Thanks!
  2. Hello! I am trying to make a multiplayer third-person shooter using node.js, express, and socket.io. I was wondering what is the best way to send the rotation of a player from the client to the server and to the other clients. Thanks!
  3. Create Box in Function

    Yes. Thanks!
  4. Create Box in Function

    Hello! I am trying to create a multiplayer node game and I need to create a box in a function. How can I do this? Thanks!
  5. Shooting

    I am trying but I can't seem to get it to work even though it works when I run a local sever on my computer
  6. Shooting

    Hello there! I am trying to make a 3rd person plane shooter using two models. What is the best way to make the Lazer model shoot out of the X-Wing model? Here is the code: var mouseX = 0; var mouseY = 0; var windowHalfX = window.innerWidth / 2; var windowHalfY = window.innerHeight / 2; var XWing; var XWings = []; var Tie; var Ties = []; var Lazerorig; var Lazers = []; var fire = false; window.addEventListener('DOMContentLoaded', function() { var canvas = document.getElementById('canvas'); var engine = new BABYLON.Engine(canvas, true); engine.enableOfflineSupport = false; var domeRadius = 4000; var randomNumber = function(min, max) { if (min === max) { return (min); } var random = Math.random(); return ((random * (max - min)) + min); }; // Wingy's default positions var myStartPositionFunction = function(worldMatrix, positionToUpdate) { var v3 = getCart(domeRadius); BABYLON.Vector3.TransformCoordinatesFromFloatsToRef(v3.x, v3.y, v3.z, worldMatrix, positionToUpdate); }; // ------------------------------------------------------------------------------------------------- var myUpdateFunction = function(particles) { for (var index = 0; index < particles.length; index++) { var particle = particles[index]; particle.age += this._scaledUpdateSpeed; if (particle.age >= particle.lifeTime) { this.recycleParticle(particle); index--; continue; } else { particle.color = new BABYLON.Color3.White(); particle.size = randomNumber(this.minSize, this.maxSize); if (particle.color.a < 0) particle.color.a = 0; } } }; // ----------------------------------------------------------------------- // a gruesome stolen func - thx to... // https://rbrundritt.wordpress.com/2008/10/14/conversion-between-spherical-and-cartesian-coordinates-systems/ function getCart(radius) { // var lat = DegtoRad (latlong.Latitude); // var lon = DegtoRad (latlong.Longitude); var xy = plot1(); // just below var lat = xy[0]; var lon = xy[1]; var x = radius * Math.cos(lat) * Math.cos(lon); var y = radius * Math.cos(lat) * Math.sin(lon); var z = radius * Math.sin(lat); return new BABYLON.Vector3(x, y, z); } // ----------------------------------------------------------------------- // a stolen formula - claims to eliminate polar bias (clustering near poles) // in use - thx to http://rectangleworld.com/blog/archives/298 var plot1 = function() { var theta = Math.random() * 2 * Math.PI; var phi = Math.acos(Math.random() * 2 - 1); return [theta, phi]; }; // ----------------------------------------------------------------------- var doubleColor4 = function(min, max) { return new BABYLON.Color4(Math.random() * 2, Math.random() * 2, Math.random() * 2, Math.random()); } // ----------------------------------------------------------------------- var createScene = function() { var scene = new BABYLON.Scene(engine); scene.clearColor = new BABYLON.Color3.Black(); var light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 0, 0), scene); var box1 = BABYLON.Mesh.CreateBox("box1", 25, scene); var box2 = BABYLON.Mesh.CreateBox("box2", 25, scene); //var cylinder = BABYLON.Mesh.CreateCylinder("cylinder", ) box1.material = new BABYLON.StandardMaterial("b1mat", scene); box1.material.emissiveColor = BABYLON.Color3.White(); box2.material = new BABYLON.StandardMaterial("b2mat", scene); box2.material.emissiveColor = BABYLON.Color3.White(); box1.position.z = -100 box2.parent = box1; box2.setPivotMatrix(BABYLON.Matrix.Translation(0, 10, -25)); box1.visibility = 0; var box3 = BABYLON.Mesh.CreateBox("Box3", 25, scene); var material = new BABYLON.StandardMaterial("material1", scene); material.wireframe = true; box3.material = material; // BABYLON.SceneLoader.ImportMesh("", "Models/", "Tie.babylon", // scene, // function(newMeshes) { // Tie = newMeshes[0]; // Tie.parent = box1; // // }); BABYLON.SceneLoader.ImportMesh("XWing", "Models/", "XWing.babylon", scene, function(newMeshes) { XWing = newMeshes[0]; XWing.parent = box1; }); BABYLON.SceneLoader.ImportMesh("Lazers", "Models/", "XWingLazers.babylon", scene, function(newMeshes) { Lazerorig = newMeshes[0]; //Lazerorig.parent = box1; Lazerorig.visibility = 0; }); var camera = new BABYLON.FreeCamera("camera", new BABYLON.Vector3(0, 0, -55), scene); scene.camera = camera; document.addEventListener('mousemove', onDocumentMouseMove, false); document.addEventListener('mousedown', function(){ }, false); document.addEventListener('mouseup', onDocumentMouseUp, false); //camera.parent = box2; camera.target = box1; box2.visibility = 0; var ps = new BABYLON.ParticleSystem("particles", 1300, scene); ps.startPositionFunction = myStartPositionFunction; ps.updateFunction = myUpdateFunction; // Texture of each particle - set far below ps.particleTexture = new BABYLON.Texture("Models/star.png", scene); //ps.particleTexture = new BABYLON.Texture("https://cdn.rawgit.com/wingnutt/misc/master/star.jpg", scene); // Where the particles come from ps.emitter = new BABYLON.Vector3(0, 15, 0); ps.minEmitBox = new BABYLON.Vector3(0, 0, 0); // Starting all from ps.maxEmitBox = new BABYLON.Vector3(0, 0, 0); // To... // the sizing. ps.minSize = 20; ps.maxSize = 30; // Life time of each particle (random between... ps.minLifeTime = 40000.0; ps.maxLifeTime = 50000.0; // Emission rate ps.emitRate = 5000; // Blend mode : BLENDMODE_ONEONE, or BLENDMODE_STANDARD ps.blendMode = BABYLON.ParticleSystem.BLENDMODE_ONEONE; // Angular speed, in radians ps.minAngularSpeed = 0; // ps.maxAngularSpeed = Math.PI*2; ps.maxAngularSpeed = 0; // Speed ps.minEmitPower = 0; ps.maxEmitPower = 0; ps.updateSpeed = 0.005; // Start the particle system ps.start(); return scene; } function onDocumentMouseMove(event) { mouseX = (event.clientX - windowHalfX); mouseY = (event.clientY - windowHalfY); } function onDocumentMouseDown() { } function onDocumentMouseUp(event) { fire = false; } var scene = createScene(); engine.runRenderLoop(function() { scene.getMeshByName("box1").rotate(BABYLON.Axis.Y, mouseX * 0.00007, BABYLON.Space.LOCAL); scene.getMeshByName("box1").rotate(BABYLON.Axis.X, mouseY * 0.0001, BABYLON.Space.LOCAL); scene.getMeshByName("box1").translate(BABYLON.Axis.Z, 6, BABYLON.Space.LOCAL); scene.render(); }); });
  7. Blender to Babylon File

    Thank you!
  8. Blender to Babylon File

    Thank you guys!
  9. Blender to Babylon File

    Hello! I am trying to convert this 3d blender file to a babylon file using the exporter. The problem is that I would like to rotate the X-Wing 180 degrees and whenever I try to export it, the model is changed for whatever reason. If anyone could do this for me or tell me what I am doing wrong, that would be awsome! Thanks! XWing.blend
  10. Spherical coordinates to Cartesian coordinates

    Thank you! I am now realizing why everyone is starting to tag you in their questions! Just one more question is there any way I can control the "box'" rotations using mouse controls? Thanks again!
  11. Spherical coordinates to Cartesian coordinates

    @WingnutHi! I've been playing around with this and I am wondering if you know of a way to replace box2 with a camera without using an arcrotatecamera? Thanks!
  12. Spherical coordinates to Cartesian coordinates

    Thank you! I think this is what I need
  13. Spherical coordinates to Cartesian coordinates

    Thank you!
  14. Spherical coordinates to Cartesian coordinates

    Thank you! I guess I should have said in the post that I also want to rotate the box in the center and for the orbiting box to follow. How would this work with the rotating?