/// <summary> /// Update the scale and position values for all currently configured models. Does no validation, only updates positions.<para/> /// After calling this method, all models will be scaled and positioned according to their internal position/scale values and the orientations/offsets defined in the models. /// </summary> public void UpdateModulePositions() { //scales for modules depend on the module above/below them //first set the scale for the core module -- this depends directly on the UI specified 'diameter' value. if (lengthWidth) { coreModule.setScaleForHeightAndDiameter(currentLength, currentDiameter); } else { coreModule.setScaleForDiameter(currentDiameter, currentVScale); } //next, set nose scale values noseModule.setDiameterFromBelow(coreModule.moduleUpperDiameter, currentVScale); //finally, set mount scale values mountModule.setDiameterFromAbove(coreModule.moduleLowerDiameter, currentVScale); //total height of the part is determined by the sum of the heights of the modules at their current scale float totalHeight = noseModule.moduleHeight; totalHeight += coreModule.moduleHeight; totalHeight += mountModule.moduleHeight; //position of each module is set such that the vertical center of the models is at part origin/COM float pos = totalHeight * 0.5f; //abs top of model pos -= noseModule.moduleHeight; //bottom of nose model noseModule.setPosition(pos); pos -= coreModule.moduleHeight * 0.5f; //center of 'core' model coreModule.setPosition(pos); pos -= coreModule.moduleHeight * 0.5f; //bottom of 'core' model mountModule.setPosition(pos); }