There seems to be a problem parenting an entity to another that has negative scale. Before posting this in bug reports, I thought I'd post it here in case anyone can shed some light.
In the example below, I expect the cone to retain it's global position/rotation/scale when parented, but this is clearly not happening:
(P.S. I know I'm randomly scaling the balls with potentially negative values, but this is a completely legitimate thing to do. It should still work! :))
In the example below, I expect the cone to retain it's global position/rotation/scale when parented, but this is clearly not happening:
(P.S. I know I'm randomly scaling the balls with potentially negative values, but this is a completely legitimate thing to do. It should still work! :))
Graphics3D 800,600,32,2 SetBuffer BackBuffer() cam = CreateCamera() PositionEntity cam,0,0,-15 light = CreateLight() ; Create some balls, parented together in a chain. ball = CreateSphere() For n = 1 To 5 ball = CreateSphere(8, ball) ScaleEntity(ball,Rnd(-5,.5), Rnd(-5,.5), Rnd(-5,.5), True) PositionEntity(ball, Rnd(-10,10), Rnd(-10,10), 0, True) TurnEntity(ball, 0,0,Rnd(360), True) Next ; Create cone. cone = CreateCone() PositionEntity cone,3,3,0 ScaleEntity cone,.5,2,.5 ; Parent cone to last ball, but keep cone's global position/rotation/scale ??? ; (comment this line out to see how things should look!) EntityParent cone,ball,True While Not KeyHit(1) RenderWorld Text 10,10," Cone global pos: x:" + EntityX(cone,True) + " y:" + EntityX(cone,True) + " z:" + EntityZ(cone,True) Text 10,30,"Cone global scale: x:" + EntityScaleX(cone,True) + " y:" + EntityScaleY(cone,True)+ " z:" + EntityScaleZ(cone,True) Text 10,50," Cone local scale: x:" + EntityScaleX(cone,False) + " y:" + EntityScaleY(cone,False)+ " z:" + EntityScaleZ(cone,False) Flip True Wend End Function EntityScaleX#(entity, globl=False) If globl Then TFormVector 1,0,0,entity,0 Else TFormVector 1,0,0,entity,GetParent(entity) Return Sqr(TFormedX()*TFormedX()+TFormedY()*TFormedY()+TFormedZ()*TFormedZ()) End Function Function EntityScaleY#(entity, globl=False) If globl Then TFormVector 0,1,0,entity,0 Else TFormVector 0,1,0,entity,GetParent(entity) Return Sqr(TFormedX()*TFormedX()+TFormedY()*TFormedY()+TFormedZ()*TFormedZ()) End Function Function EntityScaleZ#(entity, globl=False) If globl Then TFormVector 0,0,1,entity,0 Else TFormVector 0,0,1,entity,GetParent(entity) Return Sqr(TFormedX()*TFormedX()+TFormedY()*TFormedY()+TFormedZ()*TFormedZ()) End Function