JimmyBuchman Posted January 23, 2017 Share Posted January 23, 2017 How can I dynamically do spheres be created and according to a numbering that I enter make the spheres position themselves in this way as the example shows Can someone show an example? Thanks The example is below Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 23, 2017 Share Posted January 23, 2017 Sequence of numbers a(0), a(1), a(2). Let gap be 2 * sphere diameter + a bit. For a(i) having s spheres set the x position of a sphere to be i * gap and the y position of the sphere be k * gap for 0 ≤ k < s Use this idea to produce a playground any more questions easier to refer to playground. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
davrous Posted January 23, 2017 Share Posted January 23, 2017 I've got this weird feeling that you're trying to make us your homework. Please tell me I'm wrong! David JCPalmer 1 Quote Link to comment Share on other sites More sharing options...
JimmyBuchman Posted January 23, 2017 Author Share Posted January 23, 2017 2 hours ago, davrous said: I've got this weird feeling that you're trying to make us your homework. Please tell me I'm wrong! David You're wrong i don't 'study i just wanna do this for a game idea Quote Link to comment Share on other sites More sharing options...
JimmyBuchman Posted January 24, 2017 Author Share Posted January 24, 2017 5 hours ago, JohnK said: Sequence of numbers a(0), a(1), a(2). Let gap be 2 * sphere diameter + a bit. For a(i) having s spheres set the x position of a sphere to be i * gap and the y position of the sphere be k * gap for 0 ≤ k < s Use this idea to produce a playground any more questions easier to refer to playground. JohnK, you think i'm in the right way ? if I change de values everything goes wrong var createScene = function () { // This creates a basic Babylon Scene object (non-mesh) var scene = new BABYLON.Scene(engine); // This creates and positions a free camera (non-mesh) var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -149), scene); camera.attachControl(canvas, true); // This targets the camera to scene origin camera.setTarget(BABYLON.Vector3.Zero()); var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); // Default intensity is 1. Let's dim the light a small amount light.intensity = 0.7; // Spheres var spheresCount = 5; var p=[1,3,1]; var alpha = 0; var alfay=0; var atual = 0; var x=[]; var y=[]; var boo = true; for (var index = 0; index < 3; index++) { if(p[index]==1){ console.log('if'); var sphere = BABYLON.Mesh.CreateSphere("Sphere" + index, 32, 4, scene); sphere.position.x = 10 * Math.tan(alpha+5); }else{ console.log('else'); console.log(p[index]); for(j=0;j<p[index];j++){ var sphere = BABYLON.Mesh.CreateSphere("Sphere" + index, 32, 4, scene); sphere.position.y = 10 * Math.tan(alfay+5); sphere.position.x = 10 * Math.tan(auxx); alfay += (2 * Math.PI) / spheresCount; } } alpha += (2 * Math.PI) / spheresCount; } return scene; }; Quote Link to comment Share on other sites More sharing options...
JimmyBuchman Posted January 24, 2017 Author Share Posted January 24, 2017 6 hours ago, JohnK said: Sequence of numbers a(0), a(1), a(2). Let gap be 2 * sphere diameter + a bit. For a(i) having s spheres set the x position of a sphere to be i * gap and the y position of the sphere be k * gap for 0 ≤ k < s Use this idea to produce a playground any more questions easier to refer to playground. if i use an array = [1,3,1] its go fine but if i put an array [1,3,1,2] when i get on the number 2, the position.x goes wronghttp://www.babylonjs-playground.com/#XALW2#0 what can i do ? JohnK 1 Quote Link to comment Share on other sites More sharing options...
iiceman Posted January 24, 2017 Share Posted January 24, 2017 Good job with the playground! I tired to simplify it a bit, not sure if i succeeded: http://www.babylonjs-playground.com/#XALW2#1 The positions might not be exactly right, but maybe you can play around and make it better. Does that help? JohnK 1 Quote Link to comment Share on other sites More sharing options...
JimmyBuchman Posted January 24, 2017 Author Share Posted January 24, 2017 6 hours ago, iiceman said: Good job with the playground! I tired to simplify it a bit, not sure if i succeeded: http://www.babylonjs-playground.com/#XALW2#1 The positions might not be exactly right, but maybe you can play around and make it better. Does that help? thanks iiceman, i will study the code now Quote Link to comment Share on other sites More sharing options...
Nabroski Posted January 24, 2017 Share Posted January 24, 2017 Quote Link to comment Share on other sites More sharing options...
iiceman Posted January 24, 2017 Share Posted January 24, 2017 What a good movie... I should watch that again soon... I made a fishy: http://www.babylonjs-playground.com/#XALW2#4 Edit: and his big friend: http://www.babylonjs-playground.com/#XALW2#5 jerome and JohnK 2 Quote Link to comment Share on other sites More sharing options...
Nabroski Posted January 24, 2017 Share Posted January 24, 2017 I would say, lets make them swim edit:mother with little fishy children, so the mother try to teach how to http://www.babylonjs-playground.com/#XALW2#9 iiceman 1 Quote Link to comment Share on other sites More sharing options...
JimmyBuchman Posted January 25, 2017 Author Share Posted January 25, 2017 20 hours ago, iiceman said: What a good movie... I should watch that again soon... I made a fishy: http://www.babylonjs-playground.com/#XALW2#4 Edit: and his big friend: http://www.babylonjs-playground.com/#XALW2#5 haw can i do for the camera rotate in x,y and z 360º with the buttons x,y,z ? Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 25, 2017 Share Posted January 25, 2017 You can use an arc rotate camera http://www.babylonjs-playground.com/#XALW2#10 Quote Link to comment Share on other sites More sharing options...
JimmyBuchman Posted January 25, 2017 Author Share Posted January 25, 2017 3 hours ago, JohnK said: You can use an arc rotate camera http://www.babylonjs-playground.com/#XALW2#10 but in that way only spin 180 Quote Link to comment Share on other sites More sharing options...
iiceman Posted January 25, 2017 Share Posted January 25, 2017 set the limits to null like that: http://www.babylonjs-playground.com/#XALW2#11 Nabroski 1 Quote Link to comment Share on other sites More sharing options...
Nabroski Posted January 25, 2017 Share Posted January 25, 2017 @iTekVR Visam 1 Quote Link to comment Share on other sites More sharing options...
Visam Posted January 25, 2017 Share Posted January 25, 2017 21 minutes ago, Nabroski said: @iTekVR @Nabroski Thank you. I found the nice advice to set the limits to null! It is useful for me! Quote Link to comment Share on other sites More sharing options...
Nabroski Posted January 26, 2017 Share Posted January 26, 2017 @iTekVR the funny thing is i was looking around for a good implementation. i found a math formula, and i said, okay, okay no need to hurry, maybe in 2-3 weeks or something ... Visam 1 Quote Link to comment Share on other sites More sharing options...
Nabroski Posted January 26, 2017 Share Posted January 26, 2017 @iiceman IS A GANGSTA CODER!!! Quote Link to comment Share on other sites More sharing options...
iiceman Posted January 26, 2017 Share Posted January 26, 2017 actually... I just google things, forgot to give the source, here it is: ...credit goes to Deltakosh... as always Nabroski 1 Quote Link to comment Share on other sites More sharing options...
JimmyBuchman Posted January 30, 2017 Author Share Posted January 30, 2017 On 24/01/2017 at 5:01 PM, iiceman said: What a good movie... I should watch that again soon... I made a fishy: http://www.babylonjs-playground.com/#XALW2#4 Edit: and his big friend: http://www.babylonjs-playground.com/#XALW2#5 how can I do that "conection" only layer by layer ? Quote Link to comment Share on other sites More sharing options...
iiceman Posted January 30, 2017 Share Posted January 30, 2017 @JimmyBuchman I am not sure what you mean by layer by layer... like that: http://www.babylonjs-playground.com/#XALW2#13 -> click spheres (has a bug, sometimes if you click them in the wrong order it draws a wrong connection) Nabroski 1 Quote Link to comment Share on other sites More sharing options...
JimmyBuchman Posted January 30, 2017 Author Share Posted January 30, 2017 29 minutes ago, iiceman said: @JimmyBuchman I am not sure what you mean by layer by layer... like that: http://www.babylonjs-playground.com/#XALW2#13 -> click spheres (has a bug, sometimes if you click them in the wrong order it draws a wrong connection) Something like this, but this has to do automatically, loke the image below. I can already make this connection, but have some problem that is not following the matrix of weights correctly. thi is the code i'm using, unfortunately it wont work in the playground, but there it is > http://www.babylonjs-playground.com/#2AV3DG#0 Quote Link to comment Share on other sites More sharing options...
dbawel Posted February 1, 2017 Share Posted February 1, 2017 @JimmyBuchman - Perhaps everyone is overthinking this - if I understand the original question correctly. It appears you only want to translate the objects, sprites, or whatever in X and Y - so if you will be maintaining their Z as a constant (in relation to the camera and world space), then in using a pick == true function, simply test using the following function to read your canvas cursor position and print to the console (or echo to the canvas) to use to build a function to calculate the math required to translate your objects in your final translation function. The function below will only print your canvas X,Y cursor values to the JS console: onmousemove = function(e){console.log("mouse location:", e.clientX, e.clientY)} Again, the above is simply a function to write to the JS console to calculate the cursor values needed for your actual function to move your objects in X and Y; so begin simply by placing this function into a script and print your canvas cursor positions to the JS console to calculate the pick and delta (X.Y move) positions. To ultimately use this in your scene as I believe you initially described, convert the X,Y cursor positions to apply as a delta on each picked object in X and Y in your BJS scene. DB 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.