Create() public static method

get a bounding box renderer.
public static Create ( vec3 lengths ) : BoundingBoxRenderer
lengths vec3 bounding box's length at x, y, z direction.
return BoundingBoxRenderer
Ejemplo n.º 1
0
        /// <summary>
        /// Gets a <see cref="BoundingBoxRenderer"/> that wraps specified <paramref name="model"/>.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static BoundingBoxRenderer GetBoundingBoxRenderer(this IModelSpace model)
        {
            BoundingBoxRenderer boxRenderer = BoundingBoxRenderer.Create(model.Lengths);

            boxRenderer.SwitchList.Add(new LineWidthSwitch(lineWidth: 1.0f));
            boxRenderer.CopyModelSpaceStateFrom(model);

            return(boxRenderer);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a <see cref="BoundingBoxRenderer"/> that wraps specified <paramref name="model"/>.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static BoundingBoxRenderer GetBoundingBoxRenderer(this IModelSpace model)
        {
            BoundingBoxRenderer boxRenderer = BoundingBoxRenderer.Create(model.ModelSize);

            boxRenderer.StateList.Add(new LineWidthState(lineWidth: 1.0f));
            //boxRenderer.CopyModelSpaceStateFrom(model);
            boxRenderer.ModelSize = model.ModelSize;

            return(boxRenderer);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Render this bounding box.
 /// </summary>
 /// <param name="boundingBox"></param>
 /// <param name="color"></param>
 /// <param name="arg"></param>
 public static void Render(this IBoundingBox boundingBox, Color color, RenderEventArgs arg)
 {
     if (renderer == null)
     {
         var lengths = new vec3(1, 1, 1);
         renderer = BoundingBoxRenderer.Create(lengths);
         renderer.Initialize();
     }
     renderer.WorldPosition    = boundingBox.MaxPosition / 2 + boundingBox.MinPosition / 2;
     renderer.Scale            = boundingBox.MaxPosition - boundingBox.MinPosition;
     renderer.BoundingBoxColor = color;
     renderer.Render(arg);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Render this bounding box.
        /// </summary>
        /// <param name="boundingBox"></param>
        /// <param name="color"></param>
        /// <param name="arg"></param>
        public static void Render(this IBoundingBox boundingBox, Color color, RenderEventArgs arg)
        {
            if (renderer == null)
            {
                var lengths = new vec3(1, 1, 1);
                renderer = BoundingBoxRenderer.Create(lengths);
                renderer.Initialize();
            }
            mat4 model = glm.translate(mat4.identity(), boundingBox.MaxPosition / 2 + boundingBox.MinPosition / 2);

            model = glm.scale(model, boundingBox.MaxPosition - boundingBox.MinPosition);
            renderer.ModelMatrix      = model;
            renderer.BoundingBoxColor = color;
            renderer.Render(arg);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets a <see cref="BoundingBoxRenderer"/> that wraps specified <paramref name="models"/>.
        /// </summary>
        /// <param name="models"></param>
        /// <returns></returns>
        public static BoundingBoxRenderer GetBoundingBoxRenderer(this IModelSpace[] models)
        {
            if (models == null)
            {
                throw new System.ArgumentNullException();
            }

            vec3 max = new vec3();
            vec3 min = new vec3();
            {
                bool initialized = false;
                foreach (var model in models)
                {
                    if (!initialized)
                    {
                        model.GetMaxMinPosition(out max, out min);
                        initialized = true;
                    }
                    else
                    {
                        vec3 tmpMax, tmpMin;
                        model.GetMaxMinPosition(out tmpMax, out tmpMin);
                        tmpMax.UpdateMax(ref max);
                        tmpMin.UpdateMin(ref min);
                    }
                }
            }

            vec3 lengths       = (max - min);
            vec3 worldPosition = max / 2.0f + min / 2.0f;
            BoundingBoxRenderer boxRenderer = BoundingBoxRenderer.Create(lengths);

            boxRenderer.SwitchList.Add(new LineWidthSwitch(lineWidth: 1.0f));
            boxRenderer.WorldPosition = worldPosition;

            return(boxRenderer);
        }