コード例 #1
0
ファイル: SOFactory.cs プロジェクト: ZeroLu/frame3Sharp
        public virtual SceneObject BuildBox(FScene scene, TypedAttribSet attributes)
        {
            BoxSO so = new BoxSO();

            safe_set_property_f(attributes, IOStrings.AWidth, (f) => { so.Width = f; });
            safe_set_property_f(attributes, IOStrings.AHeight, (f) => { so.Height = f; });
            safe_set_property_f(attributes, IOStrings.ADepth, (f) => { so.Depth = f; });
            so.Create(scene.DefaultSOMaterial);
            safe_set_property_s(attributes, IOStrings.ASOName, (s) => { so.Name = s; });
            RestoreTransform(so, attributes);
            RestoreMaterial(so, attributes);
            return(so);
        }
コード例 #2
0
ファイル: BoxSO.cs プロジェクト: ly774508966/frame3Sharp
        override public SceneObject Duplicate()
        {
            BoxSO copy = new BoxSO();

            copy.width  = this.width;
            copy.height = this.height;
            copy.depth  = this.depth;
            copy.Create(this.GetAssignedSOMaterial());
            copy.SetLocalFrame(
                this.GetLocalFrame(CoordSpace.ObjectCoords), CoordSpace.ObjectCoords);
            copy.SetLocalScale(this.GetLocalScale());
            return(copy);
        }
コード例 #3
0
        public PrimitiveSO BuildSO(FScene scene, SOMaterial material)
        {
            Frame3f sceneFrame = scene.ToSceneFrame(shiftedFrame);
            float   scale      = 1.0f / scene.GetSceneScale();

            float w = (float)Math.Abs(Width);
            float h = (float)Math.Abs(Height);
            float d = (float)Math.Abs(Depth);

            if (Type == PrimType.Cylinder)
            {
                CylinderSO cyl = new CylinderSO()
                {
                    Center = this.Center,
                    Radius = w * 0.5f * scale, Height = h * scale
                };
                cyl.Create(material);
                cyl.SetLocalFrame(sceneFrame, CoordSpace.WorldCoords);
                return(cyl);
            }
            else if (Type == PrimType.Box)
            {
                BoxSO box = new BoxSO()
                {
                    Center = this.Center,
                    Width  = w * scale, Height = h * scale, Depth = d * scale
                };
                box.Create(material);
                box.SetLocalFrame(sceneFrame, CoordSpace.WorldCoords);
                return(box);
            }
            else if (Type == PrimType.Sphere)
            {
                SphereSO sphere = new SphereSO()
                {
                    Center = this.Center, Radius = w * 0.5f * scale
                };
                sphere.Create(material);
                sphere.SetLocalFrame(sceneFrame, CoordSpace.WorldCoords);
                return(sphere);
            }
            return(null);
        }