Ejemplo n.º 1
0
        public unsafe void SetLine(ref Vector3 start, ref Vector3 end, ref Vector3 extDir, float halfWidth)
        {
            var axisDir = end - start;

            EngineNS.Quaternion rot = EngineNS.Quaternion.Identity;
            var rotAngle            = (float)(System.Math.PI * 2 / 3);

            fixed(GeometryLinePosition *tempPtr = &this)
            {
                float *vertPtr = (float *)tempPtr;

                for (int i = 0; i < 3; i++)
                {
                    EngineNS.Quaternion.RotationAxis(ref axisDir, rotAngle * i, out rot);
                    var   curExtDir = EngineNS.Vector3.TransformCoordinate(extDir, rot);
                    float nextAngle = 0;
                    if (i < 3 - 1)
                    {
                        nextAngle = rotAngle * (i + 1);
                    }
                    EngineNS.Quaternion.RotationAxis(ref axisDir, nextAngle, out rot);
                    var nextExtDir = EngineNS.Vector3.TransformCoordinate(extDir, rot);
                    var v0         = start + nextExtDir * halfWidth;
                    var v1         = start + curExtDir * halfWidth;
                    var v2         = end + curExtDir * halfWidth;
                    var v4         = end + nextExtDir * halfWidth;
                    var v5         = v0;

                    vertPtr[i * 18 + 0] = v0.X;
                    vertPtr[i * 18 + 1] = v0.Y;
                    vertPtr[i * 18 + 2] = v0.Z;

                    vertPtr[i * 18 + 3] = v1.X;
                    vertPtr[i * 18 + 4] = v1.Y;
                    vertPtr[i * 18 + 5] = v1.Z;

                    vertPtr[i * 18 + 6] = v2.X;
                    vertPtr[i * 18 + 7] = v2.Y;
                    vertPtr[i * 18 + 8] = v2.Z;

                    vertPtr[i * 18 + 9]  = v2.X;
                    vertPtr[i * 18 + 10] = v2.Y;
                    vertPtr[i * 18 + 11] = v2.Z;

                    vertPtr[i * 18 + 12] = v4.X;
                    vertPtr[i * 18 + 13] = v4.Y;
                    vertPtr[i * 18 + 14] = v4.Z;

                    vertPtr[i * 18 + 15] = v0.X;
                    vertPtr[i * 18 + 16] = v0.Y;
                    vertPtr[i * 18 + 17] = v0.Z;
                }
            }
        }
Ejemplo n.º 2
0
        public void BuildWalkables(EngineNS.Vector3 startpos, EngineNS.Vector3 pos, EngineNS.Vector3 scale, EngineNS.Quaternion rotation)
        {
            //HollowMakerAgent.BuildGeoBoxs(box.Minimum.X, box.Minimum.Y, box.Minimum.Z,
            //               box.Maximum.X - box.Minimum.X,
            //               box.Maximum.Y - box.Minimum.Y,
            //               box.Maximum.Z - box.Minimum.Z);

            HollowMakerAgent.BuildGeoBoxs(pos, scale, rotation);


            //var iX = Math.Min((int)(((startpos.X - pos.X) + scale.X * 0.5f) / HollowMakerAgent.AgentGridSize), HollowMakerAgent.GeoBoxs.GetLength(0) - 1);
            //var iY = Math.Min((int)(((startpos.Y - pos.Y) + scale.Y * 0.5f) / HollowMakerAgent.AgentGridSize), HollowMakerAgent.GeoBoxs.GetLength(1) - 1);
            //var iZ = Math.Min((int)(((startpos.Z - pos.Z) + scale.Z * 0.5f) / HollowMakerAgent.AgentGridSize), HollowMakerAgent.GeoBoxs.GetLength(2) - 1);
            // startpos的位置是相对与volumn的,这里不能再减volumne的绝对位置,而且要保证startpos在volume里面
            var iX = Math.Min((int)((startpos.X + scale.X * 0.5f) / HollowMakerAgent.AgentGridSize), HollowMakerAgent.GeoBoxs.GetLength(0) - 1);
            var iY = Math.Min((int)((startpos.Y + scale.Y * 0.5f) / HollowMakerAgent.AgentGridSize), HollowMakerAgent.GeoBoxs.GetLength(1) - 1);
            var iZ = Math.Min((int)((startpos.Z + scale.Z * 0.5f) / HollowMakerAgent.AgentGridSize), HollowMakerAgent.GeoBoxs.GetLength(2) - 1);

            //int maxDepth = 0;
            //HollowMakerAgent.BuildWalkables(VP1.World, HollowMakerAgent.GeoBoxs[iX, iY, iZ], 0, ref maxDepth);
            var stack = new Stack <EngineNS.Bricks.HollowMaker.Agent.GeoBox>();

            stack.Push(HollowMakerAgent.GeoBoxs[iX, iY, iZ]);
            HollowMakerAgent.BuildWalkables2(VP1.World, stack);
        }