Exemplo n.º 1
0
        public void SetHeightFromScale(ROLModelDefinition def, GameObject root, float dScale, float vScale, ModelOrientation orientation)
        {
            float desiredHeight     = def.height * vScale;
            float staticHeight      = GetStaticHeight() * dScale;
            float neededScaleHeight = desiredHeight - staticHeight;

            //iterate through scaleable transforms, calculate total height of scaleable transforms; use this height to determine 'percent share' of needed scale height for each transform
            float totalScaleableHeight = 0f;

            foreach (CompoundModelTransformData data in compoundTransformData)
            {
                totalScaleableHeight += data.canScaleHeight ? data.height : 0;
            }

            float pos = 0f;                                                //pos starts at origin, is incremented according to transform height along 'dir'
            float dir = orientation == ModelOrientation.BOTTOM ? -1f : 1f; //set from model orientation, either +1 or -1 depending on if origin is at botom or top of model (ModelOrientation.TOP vs ModelOrientation.BOTTOM)
            float percent, scale, height;

            foreach (CompoundModelTransformData data in compoundTransformData)
            {
                percent = data.canScaleHeight ? data.height / totalScaleableHeight : 0f;
                height  = percent * neededScaleHeight;
                scale   = height / data.height;

                foreach (Transform tr in root.transform.ROLFindChildren(data.name))
                {
                    tr.localPosition = data.vScaleAxis * (pos + data.offset * dScale);
                    float localVerticalScale = data.canScaleHeight ? scale : dScale;
                    pos          += dir * (data.canScaleHeight ? height : dScale * data.height);
                    tr.localScale = GetScaleVector(dScale, localVerticalScale, data.vScaleAxis);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Find a single model definition by name.  Returns null if not found.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static ROLModelDefinition getModelDefinition(String name)
        {
            if (!defsLoaded)
            {
                loadDefs();
            }
            ROLModelDefinition data = null;

            baseModelData.TryGetValue(name, out data);
            return(data);
        }
Exemplo n.º 3
0
 public ModelDefinitionLayoutOptions(ROLModelDefinition def, ModelLayoutData[] layouts)
 {
     this.definition = def;
     if (definition == null)
     {
         ROLLog.error("Model definition was null when creating model layout options!");
     }
     this.layouts = layouts;
     if (this.layouts == null || this.layouts.Length < 1)
     {
         throw new InvalidOperationException("ERROR: No valid layout data specified.");
     }
 }
Exemplo n.º 4
0
 public ModelDefinitionLayoutOptions(ROLModelDefinition def)
 {
     definition = def;
     if (definition == null)
     {
         ROLLog.error("Model definition was null when creating model layout options!");
     }
     layouts = ROLModelLayout.findLayouts(new string[] { "default" });
     if (this.layouts == null || this.layouts.Length < 1)
     {
         throw new InvalidOperationException("ERROR: No valid layout data specified.");
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Create a group of model definition layout options by model definition name, with default (single position) layouts.
        /// </summary>
        /// <param name="names"></param>
        /// <returns></returns>
        public static ModelDefinitionLayoutOptions[] getModelDefinitionLayouts(string[] names)
        {
            List <ModelDefinitionLayoutOptions> defs = new List <ModelDefinitionLayoutOptions>();
            int len = names.Length;

            for (int i = 0; i < len; i++)
            {
                ROLModelDefinition def = getModelDefinition(names[i]);
                if (def != null)
                {
                    defs.Add(new ModelDefinitionLayoutOptions(def));
                }
                else
                {
                    ROLLog.error("Could not locate model defintion for name: " + names[i]);
                }
            }
            return(defs.ToArray());
        }
Exemplo n.º 6
0
        private static void loadDefs()
        {
            if (defsLoaded)
            {
                return;
            }
            defsLoaded = true;
            ConfigNode[]       modelDatas = GameDatabase.Instance.GetConfigNodes("ROL_MODEL");
            ROLModelDefinition data;

            foreach (ConfigNode node in modelDatas)
            {
                data = new ROLModelDefinition(node);
                ROLLog.log("Loading model definition data for name: " + data.name + " with model URL: " + data.modelName);
                if (baseModelData.ContainsKey(data.name))
                {
                    ROLLog.error("Model defs already contains def for name: " + data.name + ".  Please check your configs as this is an error.  The duplicate entry was found in the config node of:\n" + node);
                    continue;
                }
                baseModelData.Add(data.name, data);
            }
        }
Exemplo n.º 7
0
        public void SetHeightExplicit(ROLModelDefinition def, GameObject root, float dScale, float height, ModelOrientation orientation)
        {
            float vScale = height / def.height;

            SetHeightFromScale(def, root, dScale, vScale, orientation);
        }