Author Topic: Asymmetrical Scaling  (Read 2113 times)

Offline AGP

  • quad
  • ******
  • Posts: 1616
    • View Profile
Re: Asymmetrical Scaling
« Reply #15 on: June 27, 2018, 04:25:34 am »
Have a look at this. The further ahead I move Luke, the further up the glow goes. I've tried, unsuccessfully, rotating getTransformedCenter() of the blade, but it's still wrong.

https://www.dropbox.com/s/ouy2edwxaaxuyfr/TheFurtherAheadTheFurtherUp.webm?dl=0

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11970
    • View Profile
    • http://www.jpct.net
Re: Asymmetrical Scaling
« Reply #16 on: June 27, 2018, 12:55:37 pm »
Maybe the location of the glow in object space is off? What are the bouding box values for the glow and the blade?

Offline AGP

  • quad
  • ******
  • Posts: 1616
    • View Profile
Re: Asymmetrical Scaling
« Reply #17 on: June 27, 2018, 07:04:58 pm »
It would've been crazy if they weren't in the same place.

Quote
******Blade Bounds:
0.18368883, 0.22368883
-1.0867921, -0.08679211
0.9159291, 0.95592904
******

******Glow Bounds:
0.18368883, 0.22368883
-1.0867921, -0.08679211
0.9159291, 0.95592904
******

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11970
    • View Profile
    • http://www.jpct.net
Re: Asymmetrical Scaling
« Reply #18 on: June 28, 2018, 09:10:12 am »
Soo...the bounding boxes are in the same location, the transformed center is...yet the visual outcome doesn't match!? I'm not sure what's wrong here. Have you tried to replace these objects by some primitives just to see if it's really not something with the objects themselves?

Offline AGP

  • quad
  • ******
  • Posts: 1616
    • View Profile
Re: Asymmetrical Scaling
« Reply #19 on: June 28, 2018, 10:05:23 am »
The original object, blade (obj in the Glow class) is an ExtendedPrimitive. Glow itself is a copy of blade (new Object3D(obj, false)).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11970
    • View Profile
    • http://www.jpct.net
Re: Asymmetrical Scaling
« Reply #20 on: June 28, 2018, 01:06:26 pm »
I really don't know then. In this screen shot, which object is the child of which?

Offline AGP

  • quad
  • ******
  • Posts: 1616
    • View Profile
Re: Asymmetrical Scaling
« Reply #21 on: June 28, 2018, 06:38:11 pm »
The glow object is the child of blade (obj in Glow class).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11970
    • View Profile
    • http://www.jpct.net
Re: Asymmetrical Scaling
« Reply #22 on: June 28, 2018, 11:25:45 pm »
What happens if you call clearRotation() and clearTranslation() on the glow object?

Offline AGP

  • quad
  • ******
  • Posts: 1616
    • View Profile
Re: Asymmetrical Scaling
« Reply #23 on: June 29, 2018, 07:49:09 am »
ClearRotation() doesn't do anything (and it shouldn't, since I interpolate the matrices of the lightsaber and the skeletal structure's hand in the loop). ClearTranslation fixed its initial position, thanks very much.

Now, I'm having a hard time keeping glow in the same place. I've tried every permutation of the following method of which I could think:

Code: [Select]
     public void thicken(final float deltaTime) {
SimpleVector[] vertices = this.getSourceMesh();
SimpleVector[] destination = this.getDestinationMesh();
final SimpleVector c = new SimpleVector(obj.getTransformedCenter());
float minX = Float.MAX_VALUE, minZ = Float.MAX_VALUE, maxX = Float.MIN_VALUE, maxZ = Float.MIN_VALUE;
for (int i = 0; i < vertices.length; i++) {
     SimpleVector v = new SimpleVector(vertices[i]);
     v.x *= (1f+deltaTime);
//      v.x -= deltaTime*.5f;
     v.z *= (1f+deltaTime);
//      v.z -= deltaTime*.5f;
     destination[i] = v;
     if (minX > v.x)
minX = v.x;
     if (maxX < v.x)
maxX = v.x;
     if (minZ > v.z)
minZ = v.z;
     if (maxZ < v.z)
maxZ = v.z;
}
this.updateMesh();
SimpleVector d = new SimpleVector((minX-maxX), 0f, (minZ-maxZ));
obj.translate(d);
// obj.clearTranslation();
// obj.calcCenter();
// Glow.moveTo(obj, c);
// Glow.moveTo(obj, d.calcSub(c));
     }

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11970
    • View Profile
    • http://www.jpct.net
Re: Asymmetrical Scaling
« Reply #24 on: June 30, 2018, 04:38:59 pm »
I'm not sure, if I understand...if the glow is a child of the saber...then why doesn't it follow it properly?

Offline AGP

  • quad
  • ******
  • Posts: 1616
    • View Profile
Re: Asymmetrical Scaling
« Reply #25 on: July 01, 2018, 01:41:03 am »
Because I'm altering its vertices with the VertexController.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11970
    • View Profile
    • http://www.jpct.net
Re: Asymmetrical Scaling
« Reply #26 on: July 02, 2018, 07:44:16 pm »
Ok...so it works without that vertex manipulation but with it (to make the glower larger), it doesn't in some way. Is that the problem? I somehow lost track here...

Offline AGP

  • quad
  • ******
  • Posts: 1616
    • View Profile
Re: Asymmetrical Scaling
« Reply #27 on: July 03, 2018, 01:50:16 am »
It works both ways, but it's getting displaced as it gets wider. Read that last version of thicken() and you'll see my many attempts to keep the center in the same place.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11970
    • View Profile
    • http://www.jpct.net
Re: Asymmetrical Scaling
« Reply #28 on: July 03, 2018, 06:25:03 pm »
Maybe because your calculations assume that the center is at the origin? I would try this: Take the vertex, translate it by the negated center, scale it and translate it back by the center.

Offline AGP

  • quad
  • ******
  • Posts: 1616
    • View Profile
Re: Asymmetrical Scaling
« Reply #29 on: July 04, 2018, 02:56:55 am »
This still displaces it, but in a different direction:

Code: [Select]
     public void thicken(final float deltaTime) {
SimpleVector[] vertices = this.getSourceMesh();
SimpleVector[] destination = this.getDestinationMesh();
final SimpleVector c = new SimpleVector(obj.getTransformedCenter());
for (int i = 0; i < vertices.length; i++) {
     SimpleVector v = new SimpleVector(vertices[i]);
     v.x -= c.x;
     v.y -= c.y;
     v.z -= c.z;
     v.x *= (1f+deltaTime);
     v.z *= (1f+deltaTime);
     v.x += c.x;
     v.y += c.y;
     v.z += c.z;
     destination[i] = v;
}
this.updateMesh();
     }
« Last Edit: July 04, 2018, 03:03:22 am by AGP »