SSTUTools.SolarData.updateModelPosition C# (CSharp) Method

updateModelPosition() public method

public updateModelPosition ( float yOffset ) : void
yOffset float
return void
        public void updateModelPosition(float yOffset)
        {
            int len = rootTransforms.Length;
            float yPos = 0;
            Vector3 pos;
            for (int i = 0; i < len; i++)
            {
                yPos = yOffset + positions[i].position.y;
                pos = rootTransforms[i].localPosition;
                pos.y = yPos;
                rootTransforms[i].localPosition = pos;
            }
        }

Usage Example

        private void updateModulePositions()
        {
            //update for model scale
            topDockModule.updateScale(1);
            topModule.updateScaleForDiameter(topDiameter);
            coreModule.updateScaleForDiameter(coreDiameter);
            bottomModule.updateScaleForDiameter(bottomDiameter);
            bottomDockModule.updateScale(1);

            //calc positions
            float yPos     = topModule.currentHeight + (coreModule.currentHeight * 0.5f);
            float topDockY = yPos;

            yPos -= topModule.currentHeight;
            float topY = yPos;

            yPos -= coreModule.currentHeight;
            float coreY   = yPos;
            float bottomY = coreY;

            yPos -= bottomModule.currentHeight;
            float bottomDockY = yPos;

            //update internal ref of position
            topDockModule.setPosition(topDockY);
            topModule.setPosition(topY);
            coreModule.setPosition(coreY);
            bottomModule.setPosition(bottomY, ModelOrientation.BOTTOM);
            bottomDockModule.setPosition(bottomDockY, ModelOrientation.BOTTOM);

            //update actual model positions and scales
            topDockModule.updateModel();
            topModule.updateModel();
            coreModule.updateModel();
            bottomModule.updateModel();
            bottomDockModule.updateModel();

            solarModule.updateModelPosition(coreModule.currentVerticalPosition);

            Vector3 pos = new Vector3(0, topDockY + topDockModule.currentHeight, 0);

            topDockTransform.localPosition    = pos;
            topControlTransform.localPosition = pos;

            pos = new Vector3(0, bottomDockY - bottomDockModule.currentHeight, 0);
            bottomDockTransform.localPosition    = pos;
            bottomControlTransform.localPosition = pos;
        }