public void Init(Core coordinator)
        {
            ProjectorConfig config = new ProjectorConfig();
            mDrawLabels = config.DrawGlobalLabels;
            mDrawRoom = config.DrawRoom;

            string roomFile = config.RoomFile;
            if (roomFile != null && File.Exists(roomFile)) {
                XmlDocument doc = new XmlDocument();
                doc.Load(roomFile);

                foreach (XmlElement cornerNode in doc.GetElementsByTagName("Room")[0].ChildNodes.OfType<XmlElement>()) {
                    XmlAttribute xAttr = cornerNode.Attributes["X"];
                    XmlAttribute yAttr = cornerNode.Attributes["Y"];
                    XmlAttribute zAttr = cornerNode.Attributes["Z"];

                    float x, y, z;
                    x = y = z = 0f;

                    if (xAttr != null)
                        float.TryParse(xAttr.Value, out x);
                    if (yAttr != null)
                        float.TryParse(yAttr.Value, out y);
                    if (yAttr != null)
                        float.TryParse(zAttr.Value, out z);

                    sCorners.Add(new Vector3(x, y, z));

                    if (mBig.X < x) mBig.X = x;
                    if (mBig.Y < y) mBig.Y = y;
                    if (mBig.Z < z) mBig.Z = z;

                    if (mSmall.X > x) mSmall.X = x;
                    if (mSmall.Y > y) mSmall.Y = y;
                    if (mSmall.Z > z) mSmall.Z = z;
                }

                mAnchor = config.RoomAnchor;
            } else if (roomFile != null)
                Logger.Warn("Unable to initialise room. File '" + roomFile + "' does not exist.");

            coordinator.FrameAdded += new Action<Frame, EventArgs>(coordinator_FrameAdded);
            foreach (var window in coordinator.Frames)
                coordinator_FrameAdded(window, null);
        }
Example #2
0
        public Projector(Frame frame, ProjectorPlugin projectorPlugin)
        {
            mProjectorPlugin = projectorPlugin;
            mFrame = frame;
            mTargetH = frame.Height;

            ProjectorConfig cfg = new ProjectorConfig(frame.Name);
            mOrientation = new Rotation(cfg.ProjectorPitch, cfg.ProjectorYaw);

            //Constants
            mThrowRatio = cfg.ThrowRatio;
            mUpsideDown = cfg.UpsideDown;
            mVOffset = cfg.VOffset;
            mNativeAspectRatio = cfg.NativeAspectRatio;
            SetAspectRatio(cfg.AspectRatio);
            CalculateAngles();

            mLock = cfg.Lock;

            if (mLock == LockedVariable.Position/* || mLock == LockedVariable.Nothing*/) {
                mPosition = cfg.ProjectorPosition;
                mD = cfg.WallDistance;
                mFrame.Orientation.Yaw = mOrientation.Yaw;
            } else {
                mD = mLock == LockedVariable.Width ? CalculateDFromW() :CalculateDFromH();
                mPosition = CalculatePositionFromH();
                mOrientation.Yaw = mFrame.Orientation.Yaw;
            }

            mOldW = mFrame.Width;
            mOldH = mFrame.Height;

            mDraw = cfg.Draw;
            mDrawLabels = cfg.DrawLabels;

            mProjectorPlugin.RoomChanged += new Action(mProjectorPlugin_RoomChanged);
            mOrientation.Changed += new EventHandler(mOrientation_Changed);
            frame.Changed += new Action<Frame,EventArgs>(frame_Changed);
        }