Пример #1
0
        /// 三角形描画
        public void DrawTriangle(GraphicsContext graphics, GeometryTriangle trgTri, Camera cam, Rgba color)
        {
            if (debShader == null)
            {
                return;
            }

            /// バーテクスの更新
            ///------------------------------------------------------------
            for (int i = 0; i < 3; i++)
            {
                debMesh.Positions[i * 3 + 0] = trgTri.GetPos(i).X;
                debMesh.Positions[i * 3 + 1] = trgTri.GetPos(i).Y;
                debMesh.Positions[i * 3 + 2] = trgTri.GetPos(i).Z;

                debMesh.Normals[i * 3 + 0] = trgTri.Plane.Nor.X;
                debMesh.Normals[i * 3 + 1] = trgTri.Plane.Nor.Y;
                debMesh.Normals[i * 3 + 2] = trgTri.Plane.Nor.Z;
            }

            debVb.SetVertices(0, debMesh.Positions);
            debVb.SetIndices(debMesh.Indices);

            drawMesh(graphics, cam, color);
        }
Пример #2
0
        /// 点と三角形の3辺との最近接点を算出
        static private float getClosestPtPosTriangle(Vector3 trgPos, GeometryTriangle trgTri, ref Vector3 cPos)
        {
            float   isDis, bestDis;
            Vector3 crosePos = new Vector3(0, 0, 0);

            bestDis = 0.0f;
            for (int i = 0; i < 3; i++)
            {
                isDis = getClosestPtPosLine(trgPos, trgTri.GetPos(i), trgTri.GetPos((i + 1) % 3), ref crosePos);

                /// 最近接点を更新
                if (i == 0 || isDis < bestDis)
                {
                    bestDis = isDis;
                    cPos    = crosePos;
                }
            }
            return(bestDis);
        }
Пример #3
0
        /// 点と三角形の3辺との最近接点を算出
        private static float getClosestPtPosTriangle( Vector3 trgPos, GeometryTriangle trgTri, ref Vector3 cPos )
        {
            float isDis, bestDis;
            Vector3 crosePos = new Vector3(0,0,0);

            bestDis = 0.0f;
            for( int i=0; i<3; i++ ){
            isDis = getClosestPtPosLine( trgPos, trgTri.GetPos(i), trgTri.GetPos((i+1)%3), ref crosePos );

            /// 最近接点を更新
            if( i == 0 || isDis < bestDis ){
                bestDis = isDis;
                cPos = crosePos;
            }
            }
            return bestDis;
        }
Пример #4
0
        /// 三角形描画
        public void DrawTriangle( GraphicsContext graphics, GeometryTriangle trgTri, Camera cam, Rgba color )
        {
            if( debShader == null ){
            return ;
            }

            /// バーテクスの更新
            ///------------------------------------------------------------
            for( int i=0; i<3; i++ ){
            debMesh.Positions[ i*3+0 ] = trgTri.GetPos(i).X;
            debMesh.Positions[ i*3+1 ] = trgTri.GetPos(i).Y;
            debMesh.Positions[ i*3+2 ] = trgTri.GetPos(i).Z;

            debMesh.Normals[ i*3+0 ] = trgTri.Plane.Nor.X;
            debMesh.Normals[ i*3+1 ] = trgTri.Plane.Nor.Y;
            debMesh.Normals[ i*3+2 ] = trgTri.Plane.Nor.Z;
            }

            debVb.SetVertices( 0, debMesh.Positions );
            debVb.SetIndices( debMesh.Indices );

            drawMesh( graphics, cam, color );
        }