/// <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); }
private void UpdateModulePositions() { lengthWidth = coreModule.definition.lengthWidth; float height = lengthWidth ? panelLength : coreModule.moduleHeight; if (lengthWidth) { coreModule.setScaleForHeightAndDiameter(panelLength, panelWidth, lengthWidth); } else { coreModule.setScaleForHeightAndDiameter(panelScale, panelScale, lengthWidth); } coreModule.setPosition(height / 2); coreModule.updateModelMeshes(lengthWidth); /* * if (fullScale) * { * ROLLog.debug("UpdateModulePositions() fullScale"); * float currentDiameter = coreModule.definition.diameter * panelScale; * coreModule.setScaleForDiameter(currentDiameter, 1); * height = coreModule.moduleHeight; * pos = height * 0.5f; * coreModule.setPosition(pos); * coreModule.updateModelMeshes(); * } * else * { * ROLLog.debug("UpdateModulePositions()"); * lengthWidth = coreModule.definition.lengthWidth; * ROLLog.debug($"lengthWidth: {lengthWidth}"); * if (lengthWidth) * { * coreModule.setScaleForHeightAndDiameter(panelLength, panelWidth, lengthWidth); * height = coreModule.modulePanelLength; * } * else * { * coreModule.setScaleForHeightAndDiameter(panelScale, panelScale, lengthWidth); * height = coreModule.moduleHeight; * } * pos = height * 0.5f; * coreModule.setPosition(pos); * coreModule.updateModelMeshes(lengthWidth); * } */ animationName = coreModule.definition.animationName; FindAnimations(); // Allow StartFSM() to configure the animation state (time/speed/weight) // Change handler will need to re-call StartFSM() to properly reset a model. if (pivotName.Equals("sunPivot")) { hasPivot = false; } pivotName = coreModule.GetPivotName(); panelRotationTransform = part.FindModelTransform(pivotName); originalRotation = currentRotation = panelRotationTransform.localRotation; secondaryTransformName = raycastTransformName = coreModule.GetSecondaryTransform(); }