当前位置: 首页>>代码示例>>C#>>正文


C# ObjectArray.GetRawArray方法代码示例

本文整理汇总了C#中ObjectArray.GetRawArray方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectArray.GetRawArray方法的具体用法?C# ObjectArray.GetRawArray怎么用?C# ObjectArray.GetRawArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObjectArray的用法示例。


在下文中一共展示了ObjectArray.GetRawArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MergePoints

        //! classify points that are closer
        public void MergePoints(ref Vector4 plane, float margin, ObjectArray<IndexedVector3> points, int point_count)
        {
            m_point_count = 0;
            m_penetration_depth = -1000.0f;

            int[] point_indices = new int[MAX_TRI_CLIPPING];

            int _k;

            for (_k = 0; _k < point_count; _k++)
            {
                float _dist = -ClipPolygon.DistancePointPlane(ref plane, ref points.GetRawArray()[_k]) + margin;

                if (_dist >= 0.0f)
                {
                    if (_dist > m_penetration_depth)
                    {
                        m_penetration_depth = _dist;
                        point_indices[0] = _k;
                        m_point_count = 1;
                    }
                    else if ((_dist + MathUtil.SIMD_EPSILON) >= m_penetration_depth)
                    {
                        point_indices[m_point_count] = _k;
                        m_point_count++;
                    }
                }
            }

            for (_k = 0; _k < m_point_count; _k++)
            {
                m_points[_k] = points[point_indices[_k]];
            }
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:35,代码来源:TriangleShapeEx.cs

示例2: ProcessTriangle

		public virtual void ProcessTriangle(ObjectArray<Vector3> triangle,int partId, int triangleIndex)
		{
			Vector3[] rawData = triangle.GetRawArray();
			for (int i=0;i<3;i++)
			{
				float dot;
				Vector3.Dot(ref m_supportVecLocal,ref rawData[i],out dot);
				if (dot > m_maxDot)
				{
					m_maxDot = dot;
					m_supportVertexLocal = triangle[i];
				}
			}
		}
开发者ID:HaKDMoDz,项目名称:InVision,代码行数:14,代码来源:SupportVertexCallback.cs

示例3: PlaneClipPolygon

        //! Clips a polygon by a plane
        /*!
        *\return The count of the clipped counts
        */
        public static int PlaneClipPolygon(
                               ref Vector4 plane,
                               ObjectArray<IndexedVector3> polygon_points,
                               int polygon_point_count,
                               ObjectArray<IndexedVector3> clipped)
        {
            int clipped_count = 0;

            IndexedVector3[] rawPoints = polygon_points.GetRawArray();

            //clip first point
            float firstdist = DistancePointPlane(ref plane, ref rawPoints[0]); ;
            if (!(firstdist > MathUtil.SIMD_EPSILON))
            {
                clipped[clipped_count] = polygon_points[0];
                clipped_count++;
            }

            float olddist = firstdist;
            for (int i = 1; i < polygon_point_count; i++)
            {
                float dist = DistancePointPlane(ref plane, ref rawPoints[i]);

                PlaneClipPolygonCollect(
                                ref rawPoints[i - 1], ref rawPoints[i],
                                olddist,
                                dist,
                                clipped,
                                ref clipped_count);


                olddist = dist;
            }

            //RETURN TO FIRST  point

            PlaneClipPolygonCollect(
                            ref rawPoints[polygon_point_count - 1], ref rawPoints[0],
                            olddist,
                            firstdist,
                            clipped,
                            ref clipped_count);

            return clipped_count;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:49,代码来源:ClipPolygon.cs

示例4: PlaneClipPolygonCollect

 //! This function calcs the distance from a 3D plane
 public static void PlaneClipPolygonCollect(
                        ref IndexedVector3 point0,
                        ref IndexedVector3 point1,
                        float dist0,
                        float dist1,
                        ObjectArray<IndexedVector3> clipped,
                        ref int clipped_count)
 {
     bool _prevclassif = (dist0 > MathUtil.SIMD_EPSILON);
     bool _classif = (dist1 > MathUtil.SIMD_EPSILON);
     if (_classif != _prevclassif)
     {
         float blendfactor = -dist0 / (dist1 - dist0);
         VecBlend(ref clipped.GetRawArray()[clipped_count], ref point0, ref point1, blendfactor);
         clipped_count++;
     }
     if (!_classif)
     {
         clipped[clipped_count] = point1;
         clipped_count++;
     }
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:23,代码来源:ClipPolygon.cs

示例5: InitializeDemo

        public override void InitializeDemo()
        {
            SetCameraDistance(50);
            int totalTriangles = 2 * (NUM_VERTS_X - 1) * (NUM_VERTS_Y - 1);

            int vertStride = 1;
            int indexStride = 3;

            BulletGlobals.gContactAddedCallback = new CustomMaterialCombinerCallback();


            gVertices = new ObjectArray<IndexedVector3>(totalVerts);
            gIndices = new ObjectArray<int>(totalTriangles * 3);

            SetVertexPositions(waveheight, 0.0f);
            
            gVertices.GetRawArray()[1].Y = 0.1f;


	int index=0;
    int i, j;
	for (i=0;i<NUM_VERTS_X-1;i++)
	{
		for (j=0;j<NUM_VERTS_Y-1;j++)
		{

#if SWAP_WINDING
#if SHIFT_INDICES
			gIndices[index++] = j*NUM_VERTS_X+i;
			gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;
			gIndices[index++] = j*NUM_VERTS_X+i+1;
			
			gIndices[index++] = j*NUM_VERTS_X+i;
			gIndices[index++] = (j+1)*NUM_VERTS_X+i;
			gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;
			
#else
			gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;
			gIndices[index++] = j*NUM_VERTS_X+i+1;
			gIndices[index++] = j*NUM_VERTS_X+i;

			gIndices[index++] = (j+1)*NUM_VERTS_X+i;
			gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;
			gIndices[index++] = j*NUM_VERTS_X+i;
#endif //SHIFT_INDICES
#else //SWAP_WINDING

#if SHIFT_INDICES
			gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;
			gIndices[index++] = j*NUM_VERTS_X+i;
			gIndices[index++] = j*NUM_VERTS_X+i+1;

#if TEST_INCONSISTENT_WINDING
			gIndices[index++] = j*NUM_VERTS_X+i;
			gIndices[index++] = (j+1)*NUM_VERTS_X+i;
			gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;

#else //TEST_INCONSISTENT_WINDING
			gIndices[index++] = (j+1)*NUM_VERTS_X+i;
			gIndices[index++] = j*NUM_VERTS_X+i;
			gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;
#endif //TEST_INCONSISTENT_WINDING
			
			
			
#else //SHIFT_INDICES
			gIndices[index++] = j*NUM_VERTS_X+i;
			gIndices[index++] = j*NUM_VERTS_X+i+1;
			gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;

			gIndices[index++] = j*NUM_VERTS_X+i;
			gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;
			gIndices[index++] = (j+1)*NUM_VERTS_X+i;
#endif //SHIFT_INDICES

#endif //SWAP_WINDING
        }
    }

            m_indexVertexArrays = new TriangleIndexVertexArray(totalTriangles,
                gIndices,
                indexStride,
                totalVerts, gVertices, vertStride);

            bool useQuantizedAabbCompression = true;

             IndexedVector3  aabbMin = new IndexedVector3 (-1000,-1000,-1000);
             IndexedVector3 aabbMax = new IndexedVector3(1000, 1000, 1000);
	
            trimeshShape  = new BvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression,ref aabbMin,ref aabbMax,true);

            CollisionShape groundShape = trimeshShape;

            TriangleInfoMap triangleInfoMap = new TriangleInfoMap();

            InternalEdgeUtility.GenerateInternalEdgeInfo(trimeshShape, triangleInfoMap);


            m_collisionConfiguration = new DefaultCollisionConfiguration();

//.........这里部分代码省略.........
开发者ID:JohnLouderback,项目名称:illuminati-engine-xna,代码行数:101,代码来源:InternalEdgeDemo.cs

示例6: ProcessTriangle

        public virtual void ProcessTriangle(ObjectArray<Vector3> triangle, int partId, int triangleIndex)
        {
            Vector3[] raw = triangle.GetRawArray();

            Vector3 v10;
            Vector3 v20;
            
            Vector3.Subtract(ref raw[1],ref raw[0],out v10);
            Vector3.Subtract(ref raw[2],ref raw[0],out v20);

            Vector3 triangleNormal;
            Vector3.Cross(ref v10,ref v20,out triangleNormal);

            float dist;
            Vector3.Dot(ref raw[0],ref triangleNormal,out dist);
            float dist_a;
            Vector3.Dot(ref triangleNormal,ref m_from,out dist_a);
            dist_a -= dist;
            float dist_b;
            Vector3.Dot(ref triangleNormal,ref m_to,out dist_b);
            dist_b -= dist;

            if (dist_a * dist_b >= 0f)
            {
                return; // same sign
            }
            //@BP Mod - Backface filtering
            if (((m_flags & EFlags.kF_FilterBackfaces) != 0) && (dist_a > 0f))
            {
                // Backface, skip check
                return;
            }

            float proj_length = dist_a - dist_b;
            float distance = (dist_a) / (proj_length);
            // Now we have the intersection point on the plane, we'll see if it's inside the triangle
            // Add an epsilon as a tolerance for the raycast,
            // in case the ray hits exacly on the edge of the triangle.
            // It must be scaled for the triangle size.

            if (distance < m_hitFraction)
            {
                float edge_tolerance = triangleNormal.LengthSquared();
                edge_tolerance *= -0.0001f;
                Vector3 point; 
                point = MathUtil.Interpolate3(ref m_from, ref m_to, distance);
                {
                    Vector3 v0p;
                    Vector3.Subtract(ref raw[0],ref point,out v0p);
                    Vector3 v1p;
                    Vector3.Subtract(ref raw[1],ref point,out v1p);

                    Vector3 cp0;
                    Vector3.Cross(ref v0p,ref v1p,out cp0);

                    float dot;
                    Vector3.Dot(ref cp0, ref triangleNormal, out dot);
                    if (dot >= edge_tolerance)
                    {
                        Vector3 v2p;
                        Vector3.Subtract(ref raw[2],ref point,out v2p);
                        Vector3 cp1; //= Vector3.Cross(v1p,v2p);
                        Vector3.Cross(ref v1p, ref v2p, out cp1);

                        float dot2;
                        Vector3.Dot(ref cp1, ref triangleNormal, out dot2);

                        if (dot2 >= edge_tolerance)
                        {
                            Vector3 cp2;
                            Vector3.Cross(ref v2p, ref v0p, out cp2);
                            float dot3;
                            Vector3.Dot(ref cp2, ref triangleNormal, out dot3);

                            if (dot3 >= edge_tolerance)
                            {
                                //@BP Mod
                                // Triangle normal isn't normalized
                                triangleNormal.Normalize();

                                //@BP Mod - Allow for unflipped normal when raycasting against backfaces
                                if (((m_flags & EFlags.kF_KeepUnflippedNormal) != 0) || (dist_a <= 0.0f))
                                {
                                    Vector3 negNormal = -triangleNormal;
                                    m_hitFraction = ReportHit(ref negNormal, distance, partId, triangleIndex);
                                }
                                else
                                {
                                    m_hitFraction = ReportHit(ref triangleNormal, distance, partId, triangleIndex);
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:HaKDMoDz,项目名称:InVision,代码行数:96,代码来源:TriangleRaycastCallback.cs


注:本文中的ObjectArray.GetRawArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。