Hi,
We are trying to build a Rubik's Cube in Croquet. We just started working with Croquet, so still trying to find our feet in the environment. We can't seem to figure out how to make one part of the cube rotate. Are there any existing classes that do this that we can take a look at? Thanks, Balaji 
I would switch to the Virtual World Framework (this is really Croquet 2.0). You can code it in Javascript and it is much easier to deploy  totally webcentric. And I designed that one too. Regards, David On Fri, Apr 19, 2013 at 7:00 PM, balajim <[hidden email]> wrote: Hi, David A. Smith

Thank You for replying, David.
But we are actually constrained by the language. We have just learnt Smalltalk so we are trying to figure out how to implement it in Smalltalk. Balaji 
No problem. I wrote Croquet, so might be able to help there too. David On Fri, Apr 19, 2013 at 7:22 PM, balajim <[hidden email]> wrote: Thank You for replying, David. David A. Smith

I'm working with Balaji to get the Rubik's cube implemented in Croquet Smalltalk. I'm posting a few questions and hoping to get them answered. I'm still new to the framework and therefore would appreciate some detailed responses to my questions.
This is the way we are imagining to get this done. Step 1 : figure out a way to rotate a cube around a point in the world, which is not the center of the cube itself. (This would be like planets rotating around the sun) I understand that, to do this, we first need to translate the object to the point, rotate it there, and translate it back, which gives the effect of rotation around a point. I'm having trouble to figure out what existing classes should I leverage that might already do this. Step 2 : After step 1  we need a way to select all the cubes in a plane so that rotating one, causes rotation of all the cubes in the plane. Step 3 : we need a way to combine 1 and 2 to actually get the rotation for all cubes. 
Step 1 is basically right. Once you formulate the actual equation, you can combine it all into a single matrix if you do it a lot. Easier to do the following: Step 2  create a TFrame at the center of where you want to rotate around. You can place this TFrame anywhere you like in the world. Add the elements of the cube into the TFrame.
Step 3  more difficult if you want to have each cube move somewhat independently the way a Rubik's cube does. I wrote a method that computes the transform matrix from one object to another. This allows you to perform a rotation around the other object or TFrame. I don't remember the actual method name though.
David On Fri, Apr 19, 2013 at 8:26 PM, sachuraju <[hidden email]> wrote: I'm working with Balaji to get the Rubik's cube implemented in Croquet David A. Smith

Thank you for the reply, David. I'll go ahead and try it. I would also appreciate your inputs on the following.
It seems to me that we may be thinking at a lower level of abstraction than we ought to. The rotation around a point is not necessarily a property of a single cube, but all the cubes in the plane in which I want the rotations to happen. So, 1) Would it be easier to define a container class, (such as a subclass of TGroup), that can contain cubes and have rotation as a property of the container class itself? This way, we don't have to worry about singlecube rotations. 2) If we do implement such a container class, we'll need to make such a container class dynamic since after a rotation, the cubes shift their positions. So if I do a rotation around yaxis, then the cubes would change their planes in the xaxis and zaxis. Would it be any easier, given the classes in croquet, than my previous approach? 
Probably not. Rubik's cubes are necessarily complex in their transformations. I think you really just want to treat each subcube as an independent entity when you do its transform. The nice thing is that all the cubes in that plane should undergo the same transform (newMatrix = transform*oldMatrix or something like that for all 9 cubes in that plane...)
David On Sun, Apr 21, 2013 at 12:46 PM, sachuraju <[hidden email]> wrote: Thank you for the reply, David. I'll go ahead and try it. I would also David A. Smith

Ok..
I'm now trying to arrive at the transformation matrix that will give me the required rotation, and this is what I've come up with. It isn't working as I expect it to. rotateBy: anAngle aroundX: xValue y: yValue z: zValue "xyz is the point around which I want to rotate the object. I'll call it the origin" prevTrans := localTransform translation. "store the current position of the object" diffTrans := (Vector3 x: xValue y:yValue z:zValue)  prevTrans. "Get the difference between origin and current position" transformMatrix := Matrix4x4 identity. "To build the transformation matrix, start with the identity" transformMatrix addTranslation: diffTrans. "add transformation to translate the object to the origin" transformMatrix := transformMatrix rotation: anAngle aroundX:xValue y:yValue z:zValue. "add transformation to rotate the object by some angle at the origin" transformMatrix addTranslation: (diffTrans negated). "add transformation to translate the object to its new position" localTransform := transformMatrix * localTransform. "using the generate transformation matrix to apply the transformation to the object's localTransform". With this, I was really expecting to get the desired result but am not getting it. What am I missing here? 
Free forum by Nabble  Resume Templates  Edit this page 