Hai!
Using the rotating moons tutorial I tried to rotate a object.
Now not only one but multiple…
The problem is that the objects do not rotate at all
All I wanted to do was rotate the "Box"es in selectedObj vector but without rotating the object it self, just
the objects position…
Heres my code which doesnt work:
private void rotateObj() {
Vector3f rotPoint = new Vector3f();
/*Vector3f maxRotPoint = new Vector3f();
Vector3f minRotPoint = new Vector3f();
for (int x = 0;x<MainClass.selectedObj.size();x++){
Box selected = selectedObj.elementAt(x);
if (selected.getLocalTranslation().x > maxRotPoint.x){
maxRotPoint.x = selected.getLocalTranslation().x;
}
if (selected.getLocalTranslation().y > maxRotPoint.y){
maxRotPoint.y = selected.getLocalTranslation().y;
}
if (selected.getLocalTranslation().z > maxRotPoint.z){
maxRotPoint.z = selected.getLocalTranslation().z;
}
if (selected.getLocalTranslation().x < minRotPoint.x){
minRotPoint.x = selected.getLocalTranslation().x;
}
if (selected.getLocalTranslation().y < minRotPoint.y){
minRotPoint.y = selected.getLocalTranslation().y;
}
if (selected.getLocalTranslation().z < minRotPoint.z){
minRotPoint.z = selected.getLocalTranslation().z;
}
}*/
rotPoint.add(MainClass.selectedObj.get(0).getLocalTranslation());
Node pos = new Node();
pos.setLocalTranslation(rotPoint);
for (int x = 0;x<MainClass.selectedObj.size();x++){
Box selected = selectedObj.elementAt(x);
pos.attachChild(selected);
//float[] pos = rotatePos((float) Math.toRadians(90),rotPoint.x,rotPoint.z,selected.getLocalTranslation().x,selected.getLocalTranslation().z);
//selected.setLocalTranslation(pos[0],selected.getLocalTranslation().y,pos[1]);
float xPos = selected.getLocalScale().x;
float zPos = selected.getLocalScale().z;
selected.setLocalScale(new Vector3f(zPos,selected.getLocalScale().y,xPos));
}
Quaternion rot = new Quaternion();
rot.fromAngleAxis(90, Vector3f.UNIT_Y);
pos.setLocalRotation(rot);
pos.setName("POS");
for (int x = 0;x<MainClass.selectedObj.size();x++){
Box selected = selectedObj.elementAt(x);
Vector3f selPos = selected.getWorldTranslation();
System.out.println(selected.getParent());
selected.setLocalTranslation(selPos);
rootnode.attachChild(selected);
}
pos.removeFromParent();
}