예제 #1
0
        private void ReadSubstances(EndianBinaryReader reader, int substance_offset, int substance_count)
        {
            reader.BaseStream.Seek(0, SeekOrigin.Begin);
            m_SubstanceData = new SubstanceData(reader);

            reader.BaseStream.Seek(substance_offset, SeekOrigin.Begin);
            for (int i = 0; i < substance_count; i++)
            {
                reader.BaseStream.Seek(36, SeekOrigin.Current);
                SubstanceType sub_type = (SubstanceType)reader.ReadInt32();
                reader.BaseStream.Seek(-40, SeekOrigin.Current);

                switch (sub_type)
                {
                case SubstanceType.Float:
                    Substance <ObservableCollection <PrimitiveBinding <float> > > float_sub = new Substance <ObservableCollection <PrimitiveBinding <float> > >(reader, m_SubstanceData.GetFloatData);
                    m_Substances.Add(float_sub);
                    break;

                case SubstanceType.Int:
                    Substance <ObservableCollection <PrimitiveBinding <int> > > int_sub = new Substance <ObservableCollection <PrimitiveBinding <int> > >(reader, m_SubstanceData.GetIntData);
                    m_Substances.Add(int_sub);
                    break;

                case SubstanceType.String:
                    Substance <PrimitiveBinding <string> > string_sub = new Substance <PrimitiveBinding <string> >(reader, m_SubstanceData.GetStringData);
                    m_Substances.Add(string_sub);
                    break;

                case SubstanceType.Vec3:
                    Substance <ObservableCollection <BindingVector3> > vec3_sub = new Substance <ObservableCollection <BindingVector3> >(reader, m_SubstanceData.GetVec3Data);
                    m_Substances.Add(vec3_sub);
                    break;
                }
            }

            foreach (Substance s in m_Substances)
            {
                s.AssignNextSubstance(m_Substances);
            }
        }
예제 #2
0
        private void AddProperty(Substance Sub, System.Windows.Point Position)
        {
            SubstanceNodeViewModel sub_view = new SubstanceNodeViewModel(Sub);

            sub_view.Position = Position;

            NodeInputViewModel new_prop_input = new NodeInputViewModel();

            new_prop_input.Connections.Connect()
            .Subscribe(change => {
                OnPropertyInputChanged(change);
            });

            Parent.Nodes.Edit(x => x.Add(sub_view));

            Inputs.Edit(x => x.Add(new_prop_input));

            ConnectionViewModel new_prop_connection = new ConnectionViewModel(
                Parent,
                new_prop_input,
                sub_view.Outputs.Items.First());

            Parent.Connections.Edit(x => x.Add(new_prop_connection));
        }
예제 #3
0
        public void CopySettingsFromCamera(WCamera Camera, bool IsStart)
        {
            string EyeName    = IsStart ? "StartEye" : "Eye";
            string CenterName = IsStart ? "StartCenter" : "Center";
            string FovyName   = IsStart ? "StartFovy" : "Fovy";

            List <NodeInputViewModel> ViewModelList = Inputs.Items.ToList();

            ViewModelList.RemoveAt(0); // First input is always the execution input, so skip it because it doesn't matter for properties.

            NodeInputViewModel     EyeNodeInput = ViewModelList.Find(x => x.Connections.Items.First().Output.Parent.Name.ToLower() == EyeName.ToLower());
            SubstanceNodeViewModel EyeNode      = EyeNodeInput != null?EyeNodeInput.Connections.Items.First().Output.Parent as SubstanceNodeViewModel : null;

            NodeInputViewModel     CenterNodeInput = ViewModelList.Find(x => x.Connections.Items.First().Output.Parent.Name.ToLower() == CenterName.ToLower());
            SubstanceNodeViewModel CenterNode      = CenterNodeInput != null?CenterNodeInput.Connections.Items.First().Output.Parent as SubstanceNodeViewModel : null;

            NodeInputViewModel     FovyNodeInput = ViewModelList.Find(x => x.Connections.Items.First().Output.Parent.Name.ToLower() == FovyName.ToLower());
            SubstanceNodeViewModel FovyNode      = FovyNodeInput != null?FovyNodeInput.Connections.Items.First().Output.Parent as SubstanceNodeViewModel : null;

            System.Windows.Point Offset = new System.Windows.Point(Position.X - 375, Position.Y + 50);

            // EyeNode was already attached to this cut
            if (EyeNode != null)
            {
                Substance <ObservableCollection <BindingVector3> > EyeSub = EyeNode.Substance as Substance <ObservableCollection <BindingVector3> >;
                EyeSub.Data = new ObservableCollection <BindingVector3>()
                {
                    new BindingVector3(Camera.Transform.Position)
                };
            }
            // EyeNode needs to be added
            else
            {
                Substance <ObservableCollection <BindingVector3> > EyeSub = new Substance <ObservableCollection <BindingVector3> >(EyeName, SubstanceType.Vec3);
                EyeSub.Data = new ObservableCollection <BindingVector3>()
                {
                    new BindingVector3(Camera.Transform.Position)
                };

                AddProperty(EyeSub, Offset);
            }

            Offset.Y += 125;

            // CenterNode was already attached to this cut
            if (CenterNode != null)
            {
                Substance <ObservableCollection <BindingVector3> > CenterSub = CenterNode.Substance as Substance <ObservableCollection <BindingVector3> >;
                Vector3 CenterPos = Camera.Transform.Position + (Camera.Transform.Forward * -1000.0f);
                CenterSub.Data = new ObservableCollection <BindingVector3>()
                {
                    new BindingVector3(CenterPos)
                };
            }
            // CenterNode needs to be added
            else
            {
                Substance <ObservableCollection <BindingVector3> > CenterSub = new Substance <ObservableCollection <BindingVector3> >(CenterName, SubstanceType.Vec3);
                Vector3 CenterPos = Camera.Transform.Position + (Camera.Transform.Forward * -1000.0f);
                CenterSub.Data = new ObservableCollection <BindingVector3>()
                {
                    new BindingVector3(CenterPos)
                };

                AddProperty(CenterSub, Offset);
            }

            Offset.Y += 125;

            // FovyNode was already attached to this cut
            if (FovyNode != null)
            {
                Substance <ObservableCollection <PrimitiveBinding <float> > > FovySub = FovyNode.Substance as Substance <ObservableCollection <PrimitiveBinding <float> > >;
                FovySub.Data = new ObservableCollection <PrimitiveBinding <float> >()
                {
                    new PrimitiveBinding <float>(Camera.FieldOfView)
                };
            }
            // FovyNode needs to be added
            else
            {
                Substance <ObservableCollection <PrimitiveBinding <float> > > FovySub = new Substance <ObservableCollection <PrimitiveBinding <float> > >(FovyName, SubstanceType.Float);
                FovySub.Data = new ObservableCollection <PrimitiveBinding <float> >()
                {
                    new PrimitiveBinding <float>(Camera.FieldOfView)
                };

                AddProperty(FovySub, Offset);
            }
        }
예제 #4
0
        private void OnRequestCreatePropertyNode(Tuple <string, string, SubstanceType> args)
        {
            Substance new_sub = null;

            switch (args.Item3)
            {
            case SubstanceType.Float:
                float FloatDefault = 0.0f;
                float.TryParse(args.Item2, out FloatDefault);

                new_sub = new Substance <ObservableCollection <PrimitiveBinding <float> > >(args.Item1, args.Item3)
                {
                    Data = new ObservableCollection <PrimitiveBinding <float> >()
                    {
                        new PrimitiveBinding <float>(FloatDefault)
                    }
                };
                break;

            case SubstanceType.Int:
                int IntDefault = 0;
                int.TryParse(args.Item2, out IntDefault);

                new_sub = new Substance <ObservableCollection <PrimitiveBinding <int> > >(args.Item1, args.Item3)
                {
                    Data = new ObservableCollection <PrimitiveBinding <int> >()
                    {
                        new PrimitiveBinding <int>(IntDefault)
                    }
                };
                break;

            case SubstanceType.String:
                new_sub = new Substance <PrimitiveBinding <string> >(args.Item1, args.Item3)
                {
                    Data = new PrimitiveBinding <string>(args.Item2)
                };
                break;

            case SubstanceType.Vec3:
                new_sub = new Substance <ObservableCollection <BindingVector3> >(args.Item1, args.Item3)
                {
                    Data = new ObservableCollection <BindingVector3>()
                    {
                        new BindingVector3(new OpenTK.Vector3(0, 0, 0))
                    }
                };
                break;
            }

            SubstanceNodeViewModel temp_node = new SubstanceNodeViewModel(new_sub);

            temp_node.Position = Position;

            Parent.Nodes.Edit(x => x.Add(temp_node));

            NodeInputViewModel new_prop_input = new NodeInputViewModel();

            new_prop_input.Connections.Connect()
            .Subscribe(change => {
                OnPropertyInputChanged(change);
            });

            Inputs.Edit(x => x.Add(new_prop_input));

            ConnectionViewModel new_prop_connection = new ConnectionViewModel(
                Parent,
                new_prop_input,
                temp_node.Outputs.Items.First());

            Parent.Connections.Edit(x => x.Add(new_prop_connection));
        }