コード例 #1
0
        public static GameObject CreateModel(ComplexCuboidModel model)
        {
            GameObject root = new GameObject("ComplexCuboid");

            for (int i = 0; i < model.Size(); i++)
            {
                Vector3     pos    = model.GetPositionAt(i);
                CuboidModel cuboid = model.GetCuboidAt(i);
                GameObject  cub    = CreateCuboid(cuboid);
                cub.transform.parent   = root.transform;
                cub.transform.position = pos;
            }

            root.AddComponent <ModelContainer>().Model = model;
            return(root);
        }
コード例 #2
0
        public static GameObject CreateCuboid(CuboidModel cuboid)
        {
            GameObject   cub          = CreateCuboid(cuboid.Width, cuboid.Height, cuboid.Depth);
            MeshRenderer meshRenderer = cub.GetComponent <MeshRenderer>();

            if (cuboid.Material != null)
            {
                meshRenderer.material.CopyPropertiesFromMaterial(cuboid.Material);
            }
            else
            {
                meshRenderer.material       = new Material(Shader.Find("Standard"));
                meshRenderer.material.name  = "Default";
                meshRenderer.material.color = Color.white;
            }
            cub.AddComponent <ModelContainer>().Model = cuboid;
            return(cub);
        }
コード例 #3
0
        public override GeometryModel CreateSourceGeometryModel()
        {
            CuboidModel cuboid = new CuboidModel();

            float width  = this.width.ChangeUnit(Parent.Parent.Environment.DefaultLengthUnit);
            float height = this.height.ChangeUnit(Parent.Parent.Environment.DefaultLengthUnit);
            float depth  = this.depth.ChangeUnit(Parent.Parent.Environment.DefaultLengthUnit);

            cuboid.Width  = Math.Abs(width);
            cuboid.Depth  = Math.Abs(depth);
            cuboid.Height = Math.Abs(height);

            //Compute the center vector3
            cuboid.CenterVector3 = this.RefPoint.GetDirectXVector(Parent.Parent.Environment.DefaultLengthUnit);
            cuboid.CenterVector3 = Vector3.Add(cuboid.CenterVector3, new Vector3(width / 2.0f, depth / 2.0f, height / 2.0f));

            //Set the matrix
            cuboid.WorldMatrix = Matrix.Translation(cuboid.CenterVector3);

            return(cuboid);
        }
コード例 #4
0
        /// <summary>
        /// Create the primitives to be drawed
        /// X ---- Width
        /// Y ---- Depth
        /// Z ---- Height
        /// </summary>
        public override void Initialize( )
        {
            if (cuboidMesh != null)
            {
                cuboidMesh.Dispose();
            }

            model = source as CuboidModel;

            //Create the mesh
            cuboidMesh = new AutoMesh(d3d, Mesh.Box(d3d.Dx, model.Width, model.Depth, model.Height));

            //Get the bounding box
            cuboidMesh.BoundingBox(out minVector3, out maxVector3);

            minVector3.TransformCoordinate(model.WorldMatrix);
            maxVector3.TransformCoordinate(model.WorldMatrix);

            model.MinVector3 = minVector3;
            model.MaxVector3 = maxVector3;
        }
コード例 #5
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 protected override void PerformDispose( )
 {
     cuboidMesh.Dispose( );
     model = null;
 }