示例#1
0
        public virtual SceneObject BuildCylinder(FScene scene, TypedAttribSet attributes)
        {
            CylinderSO so = new CylinderSO();

            safe_set_property_f(attributes, IOStrings.ARadius, (f) => { so.Radius = f; });
            safe_set_property_f(attributes, IOStrings.AHeight, (f) => { so.Height = 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
        override public SceneObject Duplicate()
        {
            CylinderSO copy = new CylinderSO();

            copy.radius = this.radius;
            copy.height = this.height;
            copy.Create(this.GetAssignedSOMaterial());
            copy.SetLocalFrame(
                this.GetLocalFrame(CoordSpace.ObjectCoords), CoordSpace.ObjectCoords);
            copy.SetLocalScale(this.GetLocalScale());
            return(copy);
        }
        public static void EmitCylinderSO(SceneSerializer s, IOutputStream o, CylinderSO so)
        {
            o.AddAttribute(IOStrings.ASOName, so.Name);
            o.AddAttribute(IOStrings.ASOUuid, so.UUID);
            s.EmitTransform(o, so);
            o.AddAttribute(IOStrings.ARadius, so.Radius);
            o.AddAttribute(IOStrings.AHeight, so.Height);
            Frame3f f = so.GetLocalFrame(CoordSpace.ObjectCoords);

            o.AddAttribute(IOStrings.AStartPoint, (f.Origin - 0.5f * so.ScaledHeight * f.Y));
            o.AddAttribute(IOStrings.AEndPoint, (f.Origin + 0.5f * so.ScaledHeight * f.Y));
            s.EmitMaterial(o, so.GetAssignedSOMaterial());
        }
        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);
        }
 public static void Emit(this SceneSerializer s, IOutputStream o, CylinderSO so)
 {
     o.AddAttribute(IOStrings.ASOType, IOStrings.TypeCylinder);
     EmitCylinderSO(s, o, so);
 }