#Need help in creating rubix cube

102 messages ยท Page 1 of 1 (latest)

gritty sandal
#

Please help 0-0

dull wigeonBOT
#

โŒ› This post has been reserved for your question.

Hey @gritty sandal! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

gritty sandal
#

@vital halo Sorry bud for ping but can we talk ?

vital halo
#

just join a VC

gritty sandal
#

:'[

vital halo
#

oh ok

gritty sandal
#

So as you know i am creating 54 cubes

And while doing rotation i will move them

So when i apply rotation 2 thing will happen cubes will get rotated on its own axis also from center, as you can see in video

So main problem i am getting is rotation on cubes own center

#

And i need to solve that

#

All cube changing their location rightly i just need to do something about center rotation

gritty sandal
# vital halo oh ok

I had one idea keeping track of all cubes location and its home location
(Here location means which side they belong either red,green,white etc)

And rotating it on its center according to this but i think its lengthy

#

You think there can be easy approch

vital halo
#

Did you try using 0 0 0 as the pivot coordinates?

#

what happens when doing that?

gritty sandal
#

goes to right cordinates but center rotation messed up

#

I need to deal with center rotation

I thought resizing a cube when it enter to another side would be good but i think that will also not work

vital halo
#

and the problem also occurs on the first rotation?

gritty sandal
#

First rotation no problem

#

For any side

vital halo
#

How are you displaying the cube?

#

maybe try concatentating rotations?

gritty sandal
vital halo
#

Can you show your cubeGroup?

gritty sandal
#

And adding this class inside the scene

#

This one

#

I am just adding all cubes inside it

vital halo
#

so you are transforming groups and not individual cubes?

gritty sandal
#

And here it is added to scene

gritty sandal
vital halo
gritty sandal
#

For rotation i am applying it to individual cubies

#

each of cube will rotate and transform

vital halo
gritty sandal
vital halo
#

and when rotating it, first create the rotate object

#

and then call yourCube.applyTransform(yourRotate)

#

and do the same thing for all other transforms on individual cubes

gritty sandal
#

ok let me do it

#

I got it 50-60% but will give it try

vital halo
#

not sure whether that makes a difference

vital halo
vital halo
#

Did xou try the thing with concatenations?

gritty sandal
#

I just made class with it and try to apply that to individual cube

#

public class x{
private Transform t=new Rotate();
public void applyTransform(Transform toApply, Cube c){
t = t.createConcatenation(toApply);
c.m_B.getTransforms().clear();
c.m_B.getTransforms().add(t);
}
}

#

public void rotateFront(Cube[][][] c, String direction,x X) {//YELLOW
float a = .55f;
for(int i=0; i<6; i++) {
for(int j=0; j<3; j++) {
for(int k=0; k<3; k++) {
if(c[i][j][k].m_B.getTranslateZ() <= -150 || c[i][j][k].m_B.getTranslateZ() <= -100) {
Rotate rotate = new Rotate();
rotate.setAxis(rotate.Z_AXIS);
if (direction.equals("clockwise")) {
rotate.setAngle(a);
//r.setAngle(0.5);
} else if (direction.equals("counterclockwise")) {
rotate.setAngle(-a);
//r.setAngle(-90);
}
X.applyTransform(rotate, c[i][j][k]);
rotate.setAngle(5);
// Move the cube to its new position
double angle = Math.toRadians(rotate.getAngle());
double newX = c[i][j][k].m_B.getTranslateX() * Math.cos(angle) - c[i][j][k].m_B.getTranslateY() * Math.sin(angle);
double newY = c[i][j][k].m_B.getTranslateX() * Math.sin(angle) + c[i][j][k].m_B.getTranslateY() * Math.cos(angle); c[i][j][k].m_B.setTranslateX(newX);
c[i][j][k].m_B.setTranslateX(newX);
c[i][j][k].m_B.setTranslateY(newY);
}
}
}
}

    }
vital halo
#

No, I meant this as an instance method of your cube class

gritty sandal
vital halo
#

and why do you change the translate manually?

#

shouldn't the rotate do that?

gritty sandal
#

double angle = Math.toRadians(rotate.getAngle());
double newX = c[i][j][k].m_B.getTranslateX() * Math.cos(angle) - c[i][j][k].m_B.getTranslateY() * Math.sin(angle);
double newY = c[i][j][k].m_B.getTranslateX() * Math.sin(angle) + c[i][j][k].m_B.getTranslateY() * Math.cos(angle); c[i][j][k].m_B.setTranslateX(newX);
c[i][j][k].m_B.setTranslateX(newX);
c[i][j][k].m_B.setTranslateY(newY);

THis?

gritty sandal
#

i need to move them in the forward to create rotation

vital halo
#

oh I thought Rotate is doing both of these things

#

can you use a Translate object instead of doing the translation manually maybe?

gritty sandal
#

Nothing will be changed

vital halo
#

Is it? Or would old rotations be applied to the new positions?

gritty sandal
#

-_-

#

or i am applying it wrong way

#

I am so frustrated man

vital halo
#

what ate you doing?

gritty sandal
#

public void rotateFront(Cube[][][] c, String direction) {//YELLOW
float a = 90f;
for(int i=0; i<6; i++) {
for(int j=0; j<3; j++) {
for(int k=0; k<3; k++) {
if(c[i][j][k].m_B.getTranslateZ() <= -150 || c[i][j][k].m_B.getTranslateZ() <= -100) {
Rotate rotate = new Rotate();
rotate.setAxis(rotate.Z_AXIS);
if (direction.equals("clockwise")) {
rotate.setAngle(a);
//r.setAngle(0.5);
} else if (direction.equals("counterclockwise")) {
rotate.setAngle(-a);
//r.setAngle(-90);
}
c[i][j][k].applyTransform(rotate);

// Move the cube to its new position
double angle = Math.toRadians(rotate.getAngle());
double newX = c[i][j][k].m_B.getTranslateX() * Math.cos(angle) - c[i][j][k].m_B.getTranslateY() * Math.sin(angle);
double newY = c[i][j][k].m_B.getTranslateX() * Math.sin(angle) + c[i][j][k].m_B.getTranslateY() * Math.cos(angle); c[i][j][k].m_B.setTranslateX(newX);
c[i][j][k].m_B.setTranslateX(newX);
c[i][j][k].m_B.setTranslateY(newY);
}
}
}
}

    }
#

Btw how to send code in that window

vital halo
#

I thibk manually applying the translations with setTranslateX instead of using a Translate object could be the cause of the issue

#

but I am not experienced with JavaFX 3D stuff

#

or any 3D stuff

gritty sandal
#

All other server are dead

#

-_-

vital halo
#

Can you try creating a Translate object?

#

for the translations

vital halo
gritty sandal
# vital halo not really

Me closing this post

I will apply that approch keeping track of all side and add rotation according to it

#

Have a great day

#

And take care because i need more help in future ๐Ÿ˜›

vital halo
#

btw you don't need to lose the post before you solve your problem

gritty sandal
#

So i close whenever i go offline

vital halo
#

it gets dormanted

#

after 300 minutes, it will be marked as dormant

#

but you cab reopen it by sending a message in that post

gritty sandal
#

I see then I will keep it as it is

#

Byw