Exemplo n.º 1
0
        /// <summary>
        /// インデックスバッファの格納
        /// </summary>
        /// <param name="device">GraphicsDevice</param>
        private void InitIndexBuffer(Dx11.Device device)
        {
            int counter = 0;

            foreach (int[] meshes in Cnv.meshSection.meshList.mesh)
            {
                Console.WriteLine("index:" + counter);
                if (meshes.Length == VTXNUM_SQUARE)
                {
                    Console.WriteLine("SQUARE:1 " + meshes[0] + ", " + meshes[1] + ", " + meshes[3]);
                    Console.WriteLine("SQUARE:2 " + meshes[1] + ", " + meshes[2] + ", " + meshes[3]);

                    //四角形を2つに分割してインデックスバッファに格納
                    indices.Add((uint)meshes[0]);
                    indices.Add((uint)meshes[1]);
                    indices.Add((uint)meshes[3]);

                    indices.Add((uint)meshes[1]);
                    indices.Add((uint)meshes[2]);
                    indices.Add((uint)meshes[3]);
                }
                else
                {
                    Console.WriteLine("TRIANGLE:1 " + meshes[0] + ", " + meshes[1] + ", " + meshes[2]);
                    //三角形なのでそのままインデックスバッファに格納
                    indices.Add((uint)meshes[0]);
                    indices.Add((uint)meshes[1]);
                    indices.Add((uint)meshes[2]);
                }
                counter++;
            }
            indexBuffer = MyDirectXHelper.CreateIndexBuffer(device, indices.ToArray());
        }
Exemplo n.º 2
0
        /// <summary>
        /// 初期化
        /// </summary>
        protected virtual void InitDevice()
        {
            InitializeComponent();
            MyDirectXHelper.CreateDeviceAndSwapChain(this, ViewPanel, out GraphicsDevice, out SwapChain);

            InitRasterizerState();
            InitRenderTarget();
            InitDepthStencil();
            GraphicsDevice.ImmediateContext.OutputMerger.SetTargets(DepthStencil, RenderTarget);
            InitViewport();
            InitInputDevice();

            LoadContent();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 頂点バッファの格納
        /// </summary>
        /// <param name="device">GraphicsDevice</param>
        private void InitVertexBuffer(Dx11.Device device)
        {
            for (int i = 0; i < Cnv.meshSection.vtxList.VertexCount; i++)
            {
                Vector3 vtxPos = Cnv.meshSection.vtxList.vertex[i];
                Vector2 uvPos  = Cnv.meshSection.uvList.uvs[i];

                vtxPos += Position;

                Console.WriteLine("Model:" + OldPath + " -> InitVertexBuffer");
                Console.WriteLine("AddVertex [" + i + "] : x:" + vtxPos.X + ",y:" + vtxPos.Y + ",z:" + vtxPos.Z);
                Console.WriteLine("AddUv [" + i + "] : x:" + uvPos.X + ",y:" + uvPos.Y);

                vtxList.Add(MyDirectXHelper.CreateVertexPositionTexture(vtxPos, uvPos));
            }

            vertexBuffer = MyDirectXHelper.CreateVertexBuffer(device, vtxList.ToArray());
        }