Exemplo n.º 1
0
        public override void MouseUp(object sender, MouseButtonEventArgs e)
        {
            MouseDownFlag = false;
            var temppoing = e.GetPosition(sender as System.Windows.Controls.Image);

            //增加模型
            if (MouseDownPt.X == temppoing.X && MouseDownPt.Y == temppoing.Y)
            {
                //得到创建实体的名称,根据当前时间得到,不会有重复
                string name = Guid.NewGuid().ToString("N");
                //创建模型实体
                Entity ent = ogreimage.SceneManager.CreateEntity(name, ms.ModelName);

                SceneNode node = esmanager.MainNode.CreateChildSceneNode();

                //旋转模型,饶X轴转90度,因为创建模型和下载的模型视角不同,即初始到当前场景时会躺下,
                float      xx = 90 * (float)(System.Math.PI / 180);
                Quaternion x  = new Quaternion(new Radian(xx), Vector3.UNIT_X);
                node.Orientation *= x;
                node.Scale(ms.Scale, ms.Scale, ms.Scale);
                //将模型实体加入到场景节点中
                node.AttachObject(ent);
                node.Position = esmanager.AddmodelNode.Position;

                //向模型状态链表中增加模型信息,以便更新状态和保存场景信息

                ModelEntryStruct mm  = esmanager.ModelDataManage.AddRemoveState(node, 1);
                AddModelForm     dlg = new AddModelForm();

                if ((bool)dlg.ShowDialog())
                {
                    mm.称    = dlg.name_textBox.Text;
                    mm.备注属性 = dlg.remark_textBox.Text;
                    if (dlg.picture_textBox.Text != "")
                    {
                        mm.图片名称 = dlg.picture_textBox.Text;
                        FileStream   file   = File.OpenRead(dlg.picturename);
                        BinaryReader reader = new BinaryReader(file);
                        mm.图片 = reader.ReadBytes((int)file.Length);
                        reader.Close();
                        file.Close();
                    }
                    if (dlg.vido_textBox.Text != "")
                    {
                        mm.视频名称 = dlg.vido_textBox.Text;
                        FileStream   file   = File.OpenRead(dlg.vidoname);
                        BinaryReader reader = new BinaryReader(file);
                        mm.视频 = reader.ReadBytes((int)file.Length);
                        reader.Close();
                        file.Close();
                    }
                }
                //更新模型的旋转角度,因为旋转是用四元素做。通过节点得不到饶某个轴旋转的角度。所以在这单独记下,
                esmanager.ModelDataManage.UpdateModelState(node, 'x', xx);
                //设置当前工具为漫游
                ToolManage.Singleton.ToolType = typeof(SelectModelTool);
            }
        }
Exemplo n.º 2
0
        private void Image_MouseDown_3(object sender, MouseButtonEventArgs e)
        {
            if (EsdSceneManager.Singleton.CurrentOperateNode != null)
            {
                ModelEntryStruct mm = EsdSceneManager.Singleton.ModelDataManage.modelEntry.GetModelEntry(EsdSceneManager.Singleton.CurrentOperateNode);
                if (mm != null)
                {
                    AddModelForm dlg = new AddModelForm();
                    dlg.name_textBox.Text    = mm.称;
                    dlg.remark_textBox.Text  = mm.备注属性;
                    dlg.picture_textBox.Text = mm.图片名称;
                    dlg.vido_textBox.Text    = mm.视频名称;

                    if ((bool)dlg.ShowDialog())
                    {
                        mm.称    = dlg.name_textBox.Text;
                        mm.备注属性 = dlg.remark_textBox.Text;
                        if (dlg.picture_textBox.Text != "")
                        {
                            if (dlg.picture_textBox.Text != mm.图片名称)
                            {
                                mm.图片名称 = dlg.picture_textBox.Text;
                                FileStream   file   = File.OpenRead(dlg.picturename);
                                BinaryReader reader = new BinaryReader(file);
                                mm.图片 = reader.ReadBytes((int)file.Length);
                                reader.Close();
                                file.Close();
                            }
                        }
                        else
                        {
                            mm.图片   = null;
                            mm.图片名称 = "";
                        }
                        if (dlg.vido_textBox.Text != "")
                        {
                            if (dlg.vido_textBox.Text != mm.视频名称)
                            {
                                mm.视频名称 = dlg.vido_textBox.Text;
                                FileStream   file   = File.OpenRead(dlg.vidoname);
                                BinaryReader reader = new BinaryReader(file);
                                mm.视频 = reader.ReadBytes((int)file.Length);
                                reader.Close();
                                file.Close();
                            }
                        }
                        else
                        {
                            mm.视频名称 = "";
                            mm.视频   = null;
                        }
                    }
                }
            }
        }