aninja Posted February 22, 2016 Share Posted February 22, 2016 can anyone check this http://www.babylonjs-playground.com/#1EIE9G#0 steps to reproduce : 1st rotate around X then rotate aroung Y if you notice the color or another Box is changed cay anyone tell me why please help me I'm new hear Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 22, 2016 Share Posted February 22, 2016 Hello and welcome! this is what we call specular and you can turn it off on your material : material.specularColor = new BABYLON.Color3(0, 0, 0); Quote Link to comment Share on other sites More sharing options...
adam Posted February 22, 2016 Share Posted February 22, 2016 I don't think the color is changing. I think the box is just getting rotated in a manner that you are not expecting (due to parenting). Quote Link to comment Share on other sites More sharing options...
adam Posted February 22, 2016 Share Posted February 22, 2016 Try this: http://www.babylonjs-playground.com/#1EIE9G#3 Quote Link to comment Share on other sites More sharing options...
aninja Posted February 22, 2016 Author Share Posted February 22, 2016 it is still persist try pressing X + Y + Y Quote Link to comment Share on other sites More sharing options...
adam Posted February 22, 2016 Share Posted February 22, 2016 I just updated the link to version 3. If you change the parent, you need to account for the change in rotation. Quote Link to comment Share on other sites More sharing options...
aninja Posted February 22, 2016 Author Share Posted February 22, 2016 i really don't know whats the concept behind this,I'm just trying to make a rubix cube Quote Link to comment Share on other sites More sharing options...
adam Posted February 22, 2016 Share Posted February 22, 2016 This might help: http://doc.babylonjs.com/tutorials/Position,_Rotate,_Translate_and_Spaces Quote Link to comment Share on other sites More sharing options...
aninja Posted February 22, 2016 Author Share Posted February 22, 2016 @adam thankyou sir for your quick reply thanku very much Quote Link to comment Share on other sites More sharing options...
adam Posted February 22, 2016 Share Posted February 22, 2016 Creating a rubix cube is no easy task. Rather than parenting cubes to each other, I would create invisible meshes to use as a parent for each cube. I'd then place each cube in the correct position in each of the cube's parents. Then I would only do the rotations with the parent meshes. All of the parent meshes should have the same position. And then so that you can move the rubix cube around, I'd parent all those parent meshes to one invisible mesh. Quote Link to comment Share on other sites More sharing options...
aninja Posted February 22, 2016 Author Share Posted February 22, 2016 means suppose for 3X3 i have to make 27 cubes as well as 27 cubes as their parents and moving them relatively right ? or I'M GETTING WRONG Quote Link to comment Share on other sites More sharing options...
adam Posted February 22, 2016 Share Posted February 22, 2016 This is how I would do it: http://www.babylonjs-playground.com/#1JLWKC Then when you want to rotate a side, figure out all the boxes that are on that side and rotate all their parents. Quote Link to comment Share on other sites More sharing options...
adam Posted February 22, 2016 Share Posted February 22, 2016 http://www.babylonjs-playground.com/#1JLWKC#3 Quote Link to comment Share on other sites More sharing options...
aninja Posted February 23, 2016 Author Share Posted February 23, 2016 @adam can you tell me why it shifted slightly after rotation ? http://www.babylonjs-playground.com/#1JLWKC#4 how can i resolve it ? Quote Link to comment Share on other sites More sharing options...
adam Posted February 23, 2016 Share Posted February 23, 2016 I had to shift the initial positions by the space between the boxes: http://www.babylonjs-playground.com/#1JLWKC#7 Quote Link to comment Share on other sites More sharing options...
aninja Posted February 23, 2016 Author Share Posted February 23, 2016 why it's not rotating otherthan Y aixs ? Quote Link to comment Share on other sites More sharing options...
aninja Posted February 23, 2016 Author Share Posted February 23, 2016 Ohh sorry it was my logic fault It's working GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
aninja Posted February 24, 2016 Author Share Posted February 24, 2016 Hi @adam can you please look this issue http://www.babylonjs-playground.com/#MRRQN#0 hear i try to animate the rubix 1 animation at a time is working fine but when i put multiple animation like if user rotate clockwise upper piece cube then rotate clockwise middle piece cube then it misbehaves just uncomment the line 86-97 and 103,104 please help and guide me Quote Link to comment Share on other sites More sharing options...
aninja Posted February 25, 2016 Author Share Posted February 25, 2016 21 hours ago, aninja said: Hi @adam can you please look this issue http://www.babylonjs-playground.com/#MRRQN#0 hear i try to animate the rubix 1 animation at a time is working fine but when i put multiple animation like if user rotate clockwise upper piece cube then rotate clockwise middle piece cube then it misbehaves just uncomment the line 86-97 and 103,104 please help and guide me Quote Link to comment Share on other sites More sharing options...
JohnK Posted February 25, 2016 Share Posted February 25, 2016 The array cubesToRotate2 does not have any entries hence the error message - Compilation error Cannot set property 'parent' of undefined× Also note that rotation is like position and sets a particular rotation. This means that rotation A followed by rotation B results in rotation B only NOT A followed by B. To do cumulative rotations other methods are needed. Perhaps this tutorial might help http://doc.babylonjs.com/tutorials/Position,_Rotate,_Translate_and_Spaces Quote Link to comment Share on other sites More sharing options...
aninja Posted February 25, 2016 Author Share Posted February 25, 2016 Oh that compilation error is just because my code is not saved is't gives me "Code Too Long " error, and I'm not able to find any Clue about cumulative rotations the link describes the basic of rotation not the cumulative rotations please guide me I am trying to make a rubix cube Quote Link to comment Share on other sites More sharing options...
jerome Posted February 25, 2016 Share Posted February 25, 2016 I guess the way to cumulate successive rotations would be : to set rotation 1 to compute and to store the related WorldMatrix to set rotation 2 idem etc then to multiply all the intermediate stored rotation matrices and to aplly the result to the mesh Just an idea (don't ask me how to do this ) Quote Link to comment Share on other sites More sharing options...
aninja Posted February 25, 2016 Author Share Posted February 25, 2016 Hi Please look at this http://www.babylonjs-playground.com/#NDSST#0 there are 2 buttons for rotation both rotation works well independently but when i rotate one after another it got mixed A rotation1 B rotation2 if i press A or B N times it will rotate fine but if i rotate A->B or B->A then it will inherit previous rotation please check it and help me Quote Link to comment Share on other sites More sharing options...
JohnK Posted February 25, 2016 Share Posted February 25, 2016 Cumulative rotations. In tutorial http://doc.babylonjs.com/tutorials/Position,_Rotate,_Translate_and_Spaces scroll down to where you see Figs 6a, 6b, 6c under the Rotate section. This shows rotations take place around the world-local-axes and are accumulative. This can be seen in Demo 7. The mesh 'pilot' is rotated using the following code on lines 107 to 109. The difference between world-local-axes BABYLON.Space.WORLD and local-axes BABYLON.Space.LOCAL are explained in the tutorial. The cumulative nature of rotate can be seen by first commenting out lines 108 and 109, then only line 109 and then none of them. pilot.rotate(BABYLON.Axis.Y, Math.PI / 2, BABYLON.Space.WORLD); pilot.rotate(BABYLON.Axis.Y, Math.PI / 2, BABYLON.Space.WORLD); pilot.rotate(BABYLON.Axis.X, Math.PI / 2, BABYLON.Space.WORLD); Whether or not this is the way to go I am not clear on as you have complications of cubes switching faces when they are rotated. Personally I think I would tackle the rubix cube by giving each of the 27 cubes its own individual parent then having decided on a face to rotate determine the 9 current cubes in that face and rotate their 9 parents as required using the rotate method above but then I often do not do things the best way possible. Quote Link to comment Share on other sites More sharing options...
aninja Posted February 25, 2016 Author Share Posted February 25, 2016 Hi @JohnK thanks for reply I have followed exact the same strategy as you told but it clashes when i start another animation look at this http://www.babylonjs-playground.com/#1MNLNN#0 there are two buttona M Clokwise and U Clockwise same, both works fine independantly but try M->U or U->M please help me to figure out 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.