--- a +++ b/Tools/ModelUtilities/SolidModeling/SolidModeling.any @@ -0,0 +1,260 @@ +#class_template CreateBox( InputName, InputPlacement, InputLengthX, InputLengthY, InputLengthZ, InputDensity ) +{ + #var AnyVec3 Pos0 = {0,0,0 }; + #var AnyVec3 RotAnglesInDegree0 = {0,0,0 } ; + #var AnyVec3 Color = {0,0,0 }; + #var AnyVar Opacity = 1.0; + #var AnyVar OpacityForLocalFrame = 1.0; + #var AnyVar OpacityForLocalRefNodes = 1.0; + //#var AnyVar ScaleFactorForLocalFrame = 0.5* sqrt(pow(InputLengthX,2)+pow(InputLengthY,2)+pow(InputLengthZ, 2)); + #var AnyVar ScaleFactorForLocalFrame = 2 * min({InputLengthX,InputLengthY,InputLengthZ}); + #var AnyVar ScaleFactorForLocalRefNodes = ScaleFactorForLocalFrame * 0.5; + + AnyVar GetVolume = InputLengthX * InputLengthY * InputLengthZ ; + AnyVar GetMass = InputDensity * GetVolume; + AnyVar GetIxx = GetMass * ( pow(InputLengthY,2) * pow(InputLengthZ, 2)) / 12; + AnyVar GetIyy = GetMass * ( pow(InputLengthZ,2) * pow(InputLengthX, 2)) / 12; + AnyVar GetIzz = GetMass * ( pow(InputLengthX,2) * pow(InputLengthY, 2)) / 12; + AnyFolder& WhereToPut = InputPlacement; + + + WhereToPut = + { + AnySeg InputName = + { + Mass = ..GetMass; + Jii = {..GetIxx, ..GetIyy, ..GetIzz }; + r0 = ..Pos0; + Axes0 = RotMat(..RotAnglesInDegree0[0]*pi/180, x) * + RotMat(..RotAnglesInDegree0[1]*pi/180, y) * + RotMat(..RotAnglesInDegree0[2]*pi/180, z) ; + JaboutCoMOnOff = On; + AnyDrawSurf drw = + { + FileName = "box"; + ScaleXYZ = {InputLengthX/2, InputLengthY/2, InputLengthZ/2} / 0.15; + RGB = ...Color ; + Opacity = ...Opacity; + Face = -1; + }; + //AnyDrawRefFrame drw_frame = + //{ + // RGB = {0,0,0}; + // ScaleXYZ = ...ScaleFactorForLocalFrame * {1, 1, 1}; + // Opacity = ...OpacityForLocalFrame; + //}; + AnyRefNode Node_Point0 = + { + sRel = {InputLengthX/2, InputLengthY/2, InputLengthZ/2}; + //AnyDrawRefFrame drw_frame = + //{ + // RGB = {1,1,0}; + // ScaleXYZ = ....ScaleFactorForLocalRefNodes * {1, 1, 1}; + // Opacity = ....OpacityForLocalRefNodes; + //}; + }; + AnyRefNode Node_Point1 = + { + sRel = {InputLengthX/2, InputLengthY/2, -InputLengthZ/2}; + //AnyDrawRefFrame drw_frame = + //{ + // RGB = {1,1,0}; + // ScaleXYZ = ....ScaleFactorForLocalRefNodes * {1, 1, 1}; + // Opacity = ....OpacityForLocalRefNodes; + //}; + }; + AnyRefNode Node_Point2 = + { + sRel = {InputLengthX/2, -InputLengthY/2, InputLengthZ/2}; + //AnyDrawRefFrame drw_frame = + //{ + // RGB = {1,1,0}; + // ScaleXYZ = ....ScaleFactorForLocalRefNodes * {1, 1, 1}; + // Opacity = ....OpacityForLocalRefNodes; + //}; + }; + AnyRefNode Node_Point3 = + { + sRel = {InputLengthX/2, -InputLengthY/2, -InputLengthZ/2}; + //AnyDrawRefFrame drw_frame = + //{ + // RGB = {1,1,0}; + // ScaleXYZ = ....ScaleFactorForLocalRefNodes * {1, 1, 1}; + // Opacity = ....OpacityForLocalRefNodes; + //}; + }; + AnyRefNode Node_Point4 = + { + sRel = {-InputLengthX/2, InputLengthY/2, InputLengthZ/2}; + //AnyDrawRefFrame drw_frame = + //{ + // RGB = {1,1,0}; + // ScaleXYZ = ....ScaleFactorForLocalRefNodes * {1, 1, 1}; + // Opacity = ....OpacityForLocalRefNodes; + //}; + }; + AnyRefNode Node_Point5 = + { + sRel = {-InputLengthX/2, InputLengthY/2, -InputLengthZ/2}; + //AnyDrawRefFrame drw_frame = + //{ + // RGB = {1,1,0}; + // ScaleXYZ = ....ScaleFactorForLocalRefNodes * {1, 1, 1}; + // Opacity = ....OpacityForLocalRefNodes; + //}; + }; + AnyRefNode Node_Point6 = + { + sRel = {-InputLengthX/2, -InputLengthY/2, InputLengthZ/2}; + //AnyDrawRefFrame drw_frame = + //{ + // RGB = {1,1,0}; + // ScaleXYZ = ....ScaleFactorForLocalRefNodes * {1, 1, 1}; + // Opacity = ....OpacityForLocalRefNodes; + //}; + }; + AnyRefNode Node_Point7 = + { + sRel = {-InputLengthX/2, -InputLengthY/2, -InputLengthZ/2}; + //AnyDrawRefFrame drw_frame = + //{ + // RGB = {1,1,0}; + // ScaleXYZ = ....ScaleFactorForLocalRefNodes * {1, 1, 1}; + // Opacity = ....OpacityForLocalRefNodes; + //}; + }; + }; + }; +}; + +#class_template CreateSphere( InputName, InputPlacement, InputRadius, InputDensity) +{ + #var AnyVec3 Pos0 = {0,0,0 }; + #var AnyVec3 RotAnglesInDegree0 = {0,0,0 } ; + #var AnyVec3 Color = {0,0,0 }; + #var AnyVar Opacity = 1.0; + #var AnyVar OpacityForLocalFrame = 1.0; + #var AnyVar OpacityForLocalRefNodes = 1.0; + #var AnyVar ScaleFactorForLocalFrame = 2* InputRadius ; + #var AnyVar ScaleFactorForLocalRefNodes = ScaleFactorForLocalFrame * 0.5; + + AnyVar GetVolume = 4 * pi * pow(InputRadius, 3) / 3; + AnyVar GetMass = InputDensity * GetVolume ; + AnyVar GetIxx = 2 * GetMass * pow(InputRadius, 2) / 5 ; + AnyVar GetIyy = 2 * GetMass * pow(InputRadius, 2) / 5 ; + AnyVar GetIzz = 2 * GetMass * pow(InputRadius, 2) / 5 ; + AnyFolder& WhereToPut = InputPlacement ; + + WhereToPut = + { + AnySeg InputName = + { + Mass = ..GetMass; + Jii = {..GetIxx, ..GetIyy, ..GetIzz }; + r0 = ..Pos0; + Axes0 = RotMat(..RotAnglesInDegree0[0]*pi/180, x) * + RotMat(..RotAnglesInDegree0[1]*pi/180, y) * + RotMat(..RotAnglesInDegree0[2]*pi/180, z) ; + JaboutCoMOnOff = On; + AnyDrawSphere drw = + { + ScaleXYZ = InputRadius * {1,1,1}; + RGB = ...Color ; + Opacity = ...Opacity; + AnyStyleDrawMaterial1 style = + { + EnableCreasing = On; + CreasingAngle = 0.524; + SpecularRGB = 0.05*{1,1,1}; + }; + }; + //AnyDrawRefFrame drw_frame = + //{ + // RGB = {0,0,0}; + // ScaleXYZ = ...ScaleFactorForLocalFrame * {1, 1, 1}; + // Opacity = ...OpacityForLocalFrame; + //}; + }; + }; +}; + +#class_template CreateCylinder( InputName, InputPlacement, InputRadius, InputLength, InputDensity) +{ + #var AnyVec3 Pos0 = {0,0,0 }; + #var AnyVec3 RotAnglesInDegree0 = {0,0,0 } ; + #var AnyVec3 Color = {0,0,0 }; + #var AnyVar Opacity = 1.0; + #var AnyVar CapRatio = 0; + #var AnyVar OpacityForLocalFrame = 1.0; + #var AnyVar OpacityForLocalRefNodes = 1.0; + #var AnyVar ScaleFactorForLocalFrame = 2* InputRadius ; + #var AnyVar ScaleFactorForLocalRefNodes = ScaleFactorForLocalFrame * 0.5; + + AnyVar GetVolume = pi * pow(InputRadius, 2) * InputLength ; + AnyVar GetMass = InputDensity * GetVolume ; + AnyVar GetIxx = GetMass * (3 * pow(InputRadius, 2) + pow(InputLength, 2) ) / 12 ; + AnyVar GetIyy = GetMass * (3 * pow(InputRadius, 2) + pow(InputLength, 2) ) / 12 ; + AnyVar GetIzz = GetMass * pow(InputRadius, 2) / 2 ; + AnyFolder& WhereToPut = InputPlacement ; + + WhereToPut = + { + AnySeg InputName = + { + Mass = ..GetMass; + Jii = {..GetIxx, ..GetIyy, ..GetIzz }; + r0 = ..Pos0; + Axes0 = RotMat(..RotAnglesInDegree0[0]*pi/180, x) * + RotMat(..RotAnglesInDegree0[1]*pi/180, y) * + RotMat(..RotAnglesInDegree0[2]*pi/180, z) ; + JaboutCoMOnOff = On; + //AnyDrawRefFrame drw_frame = + //{ + // RGB = {0,0,0}; + // ScaleXYZ = ...ScaleFactorForLocalFrame * {1, 1, 1}; + // Opacity = ...OpacityForLocalFrame; + //}; + AnyRefNode drw_node = + { + sRel = { 0,0, -InputLength/2 }; + AnySurfCylinder drw = + { + Radius = InputRadius ; + Length = InputLength; + CapRatio = ....CapRatio ; + AnyDrawParamSurf drw = + { + RGB = .....Color; + Opacity = .....Opacity; + AnyStyleDrawMaterial1 style = + { + EnableCreasing = On; + CreasingAngle = 0.524; + SpecularRGB = 0.05*{1,1,1}; + }; + }; + }; + }; + AnyRefNode Node_Bottom = + { + sRel = {0, 0, -InputLength/2}; + //AnyDrawRefFrame drw_frame = + //{ + // RGB = {1,1,0}; + // ScaleXYZ = ....ScaleFactorForLocalRefNodes * {1, 1, 1}; + // Opacity = ....OpacityForLocalRefNodes; + //}; + }; + AnyRefNode Node_Top = + { + sRel = {0, 0, InputLength/2}; + //AnyDrawRefFrame drw_frame = + //{ + // RGB = {1,1,0}; + // ScaleXYZ = ....ScaleFactorForLocalRefNodes * {1, 1, 1}; + // Opacity = ....OpacityForLocalRefNodes; + //}; + }; + }; + }; +}; \ No newline at end of file