public void init(StreamWriter st) { st.WriteLine("初期化開始"); pictureBox1.MouseWheel += new MouseEventHandler(pictureBox1_MouseWheel); st.WriteLine("デバイス作成の開始"); device = new Device(new Direct3D(), 0, DeviceType.Hardware, this.pictureBox1.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters() { BackBufferWidth = this.pictureBox1.ClientSize.Width, BackBufferHeight = this.pictureBox1.ClientSize.Height, Windowed = true, }); st.WriteLine("デバイス作成の終了"); Capabilities caps = device.Capabilities; st.WriteLine("adapterOrdinal:" + caps.AdapterOrdinal); st.WriteLine("DeviceType:" + caps.DeviceType); if (caps.VertexShaderVersion.Major < 3) { MessageBox.Show("VertexShader3.0 以上がサポートされていません。\n現バージョン:" + caps.VertexShaderVersion); device.Dispose(); Environment.Exit(0); } else if (caps.PixelShaderVersion.Major < 3) { MessageBox.Show("PixelShader3.0 以上がサポートされていません。\n現バージョン:" + caps.VertexShaderVersion); device.Dispose(); Environment.Exit(0); } st.WriteLine("DeviceContextの初期化"); DeviceContext.init(device); st.WriteLine("ZEnableの初期化"); device.SetRenderState(RenderState.ZEnable, true); st.WriteLine("cameraの初期化"); camera = new Camera(device); st.WriteLine("Floorの初期化"); floorMap = new FloorMap(device); // teapot = Mesh.CreateTeapot(device); // device.SetRenderState(RenderState.ShadeMode, ShadeMode.Flat); st.WriteLine("照明の初期化"); device.SetRenderState(RenderState.Lighting, true); device.SetLight(0, new Light() { Type = LightType.Directional, Diffuse = Color.White, Ambient = Color.Gray, Direction = new Vector3(1.0f, 1.0f, 0.0f), }); device.EnableLight(0,true); standardLine = new StandardLine(device); //射影変換 device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH((float)(Math.PI / 4), (float)this.pictureBox1.ClientSize.Width / (float)this.pictureBox1.ClientSize.Height, 0.1f, 1500.0f)); //ビュー device.SetTransform(TransformState.View, camera.getLookAtLh()); device.SetTransform(TransformState.World, Matrix.Identity); st.WriteLine("FloorModelの初期化"); floorModel = new FloorModel(new MqoParser(device).parse(".\\projects\\sample\\model\\floor.mqo", new MqoModel())); st.WriteLine("初期化終了"); }
private void openFileMenuItem_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); String current = Directory.GetCurrentDirectory(); dialog.InitialDirectory = current + @"\projects\" + projectName + @"\data"; if(dialog.ShowDialog() == DialogResult.OK) { floorMap.dispose(); floorMap = new FloorMap(device); EditorConfig editorConfig = new EditorConfig(); Boolean result = editorConfig.fromFile(dialog.FileName); if(!result) { MessageBox.Show("ファイルの読み込みが正常に終了しませんでした。"); } drawFloorModel = editorConfig.drawFloorModel; showAlwaysFloorMap = editorConfig.showAlwaysFloorMap; floorMap.setX(editorConfig.mapXsize); floorMap.setY(editorConfig.mapYsize); mapSizeX.Value = editorConfig.mapXsize; mapSizeY.Value = editorConfig.mapYsize; //コントロールの読み込み showFloorModelcheckBox.Checked = drawFloorModel; showAlwaysFloorModelcheckBox.Checked = showAlwaysFloorMap; mapSizeX.Enabled = !editorConfig.lockMapSize; mapSizeY.Enabled = !editorConfig.lockMapSize; encountRatioUpDown.Value = editorConfig.encounterRatio; //enableの構築 for (int i = 0; i < editorConfig.mapXsize - 1; i++) { List<Boolean> bl = editorConfig.edgeXListEnable.ElementAt(i); List<MapEdge> el = floorMap.MapPosition.EdgeXList.ElementAt(i); for (int j = 0; j < editorConfig.mapYsize; j++) { Boolean b = bl.ElementAt(j); el.ElementAt(j).Enabled = b; } } for (int i = 0; i < editorConfig.mapXsize; i++ ) { List<Boolean> bl = editorConfig.edgeYListEnable.ElementAt(i); List<MapEdge> el = floorMap.MapPosition.EdgeYList.ElementAt(i); for (int j = 0; j < editorConfig.mapYsize - 1; j++) { Boolean b = bl.ElementAt(j); el.ElementAt(j).Enabled = b; } } } }