Exemplo n.º 1
0
 private CheckerInfo PredicateCheckerInfo(PredicateInfo predicate)
 {
     CheckerInfo result;
     if (checkerInfoTable.TryGetValue(predicate, out result))
         return result;
     return checkerInfoTable[predicate] = new CheckerInfo();
 }
Exemplo n.º 2
0
        private void MarkDefined(PredicateInfo predicate, KnowledgeBaseRule rule)
        {
            CheckerInfo predicateCheckerInfo = PredicateCheckerInfo(predicate);

            if (predicateCheckerInfo.DefiningRule == null)
            {
                predicateCheckerInfo.DefiningRule = rule;
            }
        }
Exemplo n.º 3
0
        private CheckerInfo PredicateCheckerInfo(PredicateInfo predicate)
        {
            CheckerInfo result;

            if (checkerInfoTable.TryGetValue(predicate, out result))
            {
                return(result);
            }
            return(checkerInfoTable[predicate] = new CheckerInfo());
        }
Exemplo n.º 4
0
        public List <object> List(ApiCall call)
        {
            List <CheckerInfo> result = new List <CheckerInfo>();
            var all = Kooboo.Sites.Diagnosis.Manager.ListCheckers(call.Context);

            foreach (var item in all)
            {
                CheckerInfo info = new CheckerInfo();
                info.Name  = item.Name;
                info.Group = item.Group;
                info.Id    = item.Id;
                result.Add(info);
            }

            return(result.ToList <object>());
        }
    public void ReceiveRaycastData(CheckerInfo checkerInfo)
    {
        switch (viewToolManager.VTMMode)
        {
        case VTMMode.Default3D:
            ProcessRCData3DMeshMultipleLayers(checkerInfo);
            break;

        case VTMMode.Default2D:
            ProcessRCData2DMesh(checkerInfo);
            break;

        case VTMMode.ConsolidateCast3D:
            ProcessRCDataConsolidateTo2DMesh(checkerInfo);
            break;

        case VTMMode.IgnoreVertical2D:
            ProcessRCData2DMesh(checkerInfo);
            break;

        case VTMMode.ViewCentreCast3D:
            ProcessRCData2DMesh(checkerInfo);
            break;

        case VTMMode.SpecificSlice2D:
            // using the new specific slice checker info
            ProcessRCData2DMesh(checkerInfo);
            break;

        case VTMMode.SpecificSliceOLD3D:
            // using the old method of having a full 3d raycast check and then only getting the specific slice
            ProcessRCDataSpecificSliceOld(checkerInfo);
            break;

        default:
            break;
        }
    }
    // this mode will also ignore the hits only option and just act as if it is true
    protected void ProcessRCDataConsolidateTo2DMesh(CheckerInfo checkerInfo)
    {
        // get the max number of verts
        // max number of verts will be the number of horizontal casts multiplied by the vertical casts plus 1 more vert for the origin vertex
        int maxNumberOfVerts = (checkerInfo.horizontalCasts * checkerInfo.verticalCasts) + 1;

        Vector3[] finalVerts  = new Vector3[maxNumberOfVerts];
        int[]     finalTris   = new int[0];
        Color[]   finalColors = new Color[maxNumberOfVerts];

        // bring the vertex position back to the origin instead of being built from the position of the raycast checker
        // this is done as the view mesh generator is parented to the raycast checker which moves with the attached player
        // when creating a mesh it will be built around the origin so moving it requires building around the origin and not an world position
        //Vector3 offsetPosition = this.transform.position;
        Vector3 offsetPosition = Vector3.zero;

        // create a list of complete triangles to convert to the final triangles array
        List <TriangleData> listOfCompleteTriangles = new List <TriangleData>();

        // go through all the checker cast infos and add them to the verts
        // current vertex index will be increased before adding to each vertex id in the array of vertex
        int currentVertexIndex = 0;

        // add the origin point vert
        finalVerts[0]  = checkerInfo.castOrigin - offsetPosition;
        finalColors[0] = toolUserSettings.VertexColorModeDefaultColor;

        // used for only showing collider hits
        LastVertInfo lastCheckedVert = new LastVertInfo();

        lastCheckedVert.wasHit = false;
        lastCheckedVert.vertID = 0;

        // move all the the same height as the cast origin
        float consolidateHeight = checkerInfo.castOrigin.y;

        // add all cast hit points as vertexs
        for (int verticalCastCount = 0; verticalCastCount < checkerInfo.verticalCasts; verticalCastCount++)
        {
            for (int horizontalCastCount = 0; horizontalCastCount < checkerInfo.horizontalCasts; horizontalCastCount++)
            {
                // check that not passed the end of the max number of verts
                if (currentVertexIndex >= maxNumberOfVerts)
                {
                    //Debug.Log("Current vert id is larger than max number of Verts: " + maxNumberOfVerts);
                    break;
                }

                // get the cast info that we are checking
                CastInfo checkingInfo = checkerInfo.castInfos[horizontalCastCount, verticalCastCount];


                // if point was a hit
                if (checkingInfo.HitID != HitID.Miss)
                {
                    // increase vertex index before updating vert information
                    currentVertexIndex++;

                    // adjust the position by the offset position
                    Vector3 adjustedPosition = checkingInfo.HitPosition - offsetPosition;
                    // move all positions to the same y height
                    adjustedPosition.y = consolidateHeight;

                    // add new vert to the array of verts
                    finalVerts[currentVertexIndex] = adjustedPosition;

                    // set vertex color according to if the cast info was a hit or not
                    // hit player
                    if (checkingInfo.HitID == HitID.HitPlayer)
                    {
                        finalColors[currentVertexIndex] = toolUserSettings.VertexColorModeHitPlayerColor;
                    }
                    // hit object
                    else if (checkingInfo.HitID == HitID.HitObject)
                    {
                        finalColors[currentVertexIndex] = toolUserSettings.VertexColorModeHitObjectColor;
                    }

                    // if there are atleast 3 vertexes already in the list of verts
                    // and the vert checked before this was also a hit
                    // and is atleast the second horizontal cast
                    if (currentVertexIndex >= 2 && lastCheckedVert.wasHit && horizontalCastCount > 0)
                    {
                        // create new triangle data to fill
                        TriangleData newTriangle = new TriangleData();
                        newTriangle.FirstVertID  = 0;
                        newTriangle.SecondVertID = currentVertexIndex - 1;
                        newTriangle.ThirdVertID  = currentVertexIndex;
                        // add the new triangle to the list of triangles
                        listOfCompleteTriangles.Add(newTriangle);
                    }

                    // set last checked vert info
                    lastCheckedVert.wasHit = true;
                    lastCheckedVert.vertID = currentVertexIndex;
                }
                // point checking was not a hit
                else
                {
                    // set the last checked vert info
                    lastCheckedVert.wasHit = false;
                    lastCheckedVert.vertID = 0; // there isnt a vertex created for the miss so will just be set as the origin
                }
            }
        }

        // check if needing to resize the vertex array
        // checking the current vertex index will show which was the last array element edited (+1 as arrays start at 0)
        // if the last array element edited wasnt the end of the array then resize it
        if (currentVertexIndex < finalVerts.Length)
        {
            //Debug.Log("Resizing the final vert array");
            // resize to the size of the current vertex index plus 1
            Array.Resize(ref finalVerts, currentVertexIndex + 1);
            Array.Resize(ref finalColors, currentVertexIndex + 1);
        }

        // convert complete triangles to the final tris array
        finalTris = new int[listOfCompleteTriangles.Count * 3];
        int currentBaseTriID = 0;

        foreach (TriangleData triData in listOfCompleteTriangles)
        {
            // add all the triangle data to the final tri array
            finalTris[currentBaseTriID + 0] = triData.FirstVertID;
            finalTris[currentBaseTriID + 1] = triData.SecondVertID;
            finalTris[currentBaseTriID + 2] = triData.ThirdVertID;

            // increase the base tri id
            currentBaseTriID += 3;
        }

        // finally update the mesh
        UpdateMesh(finalVerts, finalTris, finalColors);
    }