altium: use correct position and rotation when importing step models
This commit is contained in:
parent
1065bb65c8
commit
7d67be5b5f
|
@ -624,6 +624,8 @@ ACOMPONENTBODY6::ACOMPONENTBODY6( ALTIUM_PARSER& aReader )
|
||||||
|
|
||||||
rotation = ALTIUM_PARSER::PropertiesReadDouble( properties, "MODEL.2D.ROTATION", 0. );
|
rotation = ALTIUM_PARSER::PropertiesReadDouble( properties, "MODEL.2D.ROTATION", 0. );
|
||||||
|
|
||||||
|
bodyOpacity = ALTIUM_PARSER::PropertiesReadDouble( properties, "BODYOPACITY3D", 1. );
|
||||||
|
|
||||||
aReader.SkipSubrecord();
|
aReader.SkipSubrecord();
|
||||||
|
|
||||||
if( aReader.HasParsingError() )
|
if( aReader.HasParsingError() )
|
||||||
|
|
|
@ -509,6 +509,7 @@ struct ACOMPONENTBODY6
|
||||||
MODULE_3D_SETTINGS::VECTOR3D modelPosition;
|
MODULE_3D_SETTINGS::VECTOR3D modelPosition;
|
||||||
MODULE_3D_SETTINGS::VECTOR3D modelRotation;
|
MODULE_3D_SETTINGS::VECTOR3D modelRotation;
|
||||||
double rotation;
|
double rotation;
|
||||||
|
double bodyOpacity;
|
||||||
|
|
||||||
explicit ACOMPONENTBODY6( ALTIUM_PARSER& aReader );
|
explicit ACOMPONENTBODY6( ALTIUM_PARSER& aReader );
|
||||||
};
|
};
|
||||||
|
|
|
@ -846,20 +846,22 @@ void ALTIUM_PCB::ParseComponentsBodies6Data(
|
||||||
modelSettings.m_Offset.y = -Iu2Millimeter( (int) elem.modelPosition.y - modulePosition.y );
|
modelSettings.m_Offset.y = -Iu2Millimeter( (int) elem.modelPosition.y - modulePosition.y );
|
||||||
modelSettings.m_Offset.z = Iu2Millimeter( (int) elem.modelPosition.z );
|
modelSettings.m_Offset.z = Iu2Millimeter( (int) elem.modelPosition.z );
|
||||||
|
|
||||||
double correctedRotation =
|
double orientation = module->GetOrientation();
|
||||||
module->IsFlipped() ? -module->GetOrientation() : module->GetOrientation();
|
|
||||||
|
|
||||||
RotatePoint( &modelSettings.m_Offset.x, &modelSettings.m_Offset.y, correctedRotation );
|
|
||||||
|
|
||||||
if( module->IsFlipped() )
|
if( module->IsFlipped() )
|
||||||
{
|
{
|
||||||
// TODO: in case of a flipped module, the offset is sometimes wrong. HowTo correct?
|
modelSettings.m_Offset.y = -modelSettings.m_Offset.y;
|
||||||
|
orientation = -orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RotatePoint( &modelSettings.m_Offset.x, &modelSettings.m_Offset.y, orientation );
|
||||||
|
|
||||||
modelSettings.m_Rotation.x = NormalizeAngleDegrees( -elem.modelRotation.x, -180, 180 );
|
modelSettings.m_Rotation.x = NormalizeAngleDegrees( -elem.modelRotation.x, -180, 180 );
|
||||||
modelSettings.m_Rotation.y = NormalizeAngleDegrees( elem.modelRotation.y, -180, 180 );
|
modelSettings.m_Rotation.y = NormalizeAngleDegrees( -elem.modelRotation.y, -180, 180 );
|
||||||
modelSettings.m_Rotation.z =
|
modelSettings.m_Rotation.z = NormalizeAngleDegrees(
|
||||||
NormalizeAngleDegrees( -elem.modelRotation.z + correctedRotation / 10, -180, 180 );
|
-elem.modelRotation.z + elem.rotation + orientation / 10, -180, 180 );
|
||||||
|
|
||||||
|
modelSettings.m_Opacity = elem.bodyOpacity;
|
||||||
|
|
||||||
module->Models().push_back( modelSettings );
|
module->Models().push_back( modelSettings );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue