public bool initialize() { start_time = DateTime.Now; rot_start_time = start_time; pause_time = start_time; m = new Model(); string tmp = session_path + "/" + current_trial.ToString() + "/model.txt"; // we are just saving isMonocular becasue when model is loaded it will be overwritten bool isMono = isMonocular; m.load(tmp); //create modified object modified_obj = new OffObject(); modified_obj.clear(); tmp = session_path + "/" + current_trial.ToString() + "/offObj.txt"; modified_obj.load(tmp); modified_obj.InitializeFaces(); modified_obj.InitializeEdges(); //for (int k = 0; k < 16; k++) //{ // modified_obj.verts[k].z *= -1; //} modified_obj.recalc_centre_norms_and_face_norms(); // Read the notes at declaration of just_model to undrstand whats going on. if (just_model) { isMonocular = isMono; set_display_params(); } else if (isMonocular) { line_width = 6.30f; wire_frm_dst = 5.50f; } else if (!isMonocular) { line_width = 0.006240f; wire_frm_dst = 3.80f; } //{ // modified_obj.translate = new Vector3(0.00f, 0, 5.0f); // m.delta_pos = new Vector3(0.60f, 0.0f, 0.0f); // line_width = 0.013240f; // wire_frm_dst = 3.80f; //} //double asm = modified_obj.degree_of_asymmetry(); //double cmp = modified_obj.compactess(); //Debug.Log("Assymmetry: " + asm.ToString() + ", Compactness: " + cmp.ToString()); //Debug.Log("Scale: " + m.scale.ToString()); //is_view_acceptable(); m.usr_mat[2, 0] = (float)Helper.get_random_double(-2.75, 2.75); m.usr_mat[2, 1] = (float)Helper.get_random_double(-2.75, 2.75); m.usr_mat[2, 2] = (float)Helper.get_random_double(0.1, 2.75); return(true); }
void set_display_params() { float ang_span_Thresh, tmp_scale; if (isMonocular) { m.delta_pos = new Vector3(513.0f, 0, 0.0f); m.pos = new Vector3(0.0f, 0, 1000.0f); modified_obj.translate = m.pos; m.fct = 0.75f; line_width = 6.30f; wire_frm_dst = 5.50f; ang_span_Thresh = 28; tmp_scale = 1e-5f; } else { m.delta_pos = new Vector3(0.60f, 0.0f, 0.0f); m.pos = new Vector3(0.00f, 0, 1.0f); modified_obj.translate = m.pos; m.fct = 0.75f; line_width = 0.006240f; wire_frm_dst = 3.80f; ang_span_Thresh = 28; tmp_scale = 1e-10f; } //Set scale according to angular span on screen obj = new OffObject(); obj.copy_properties_from(modified_obj); Matrix4x4 tmp1 = Matrix4x4.TRS(Vector3.zero, modified_obj.rotation, Vector3.one); obj.rotate_object(tmp1); // obj.scale_object(tmp_scale); obj.translate_object(modified_obj.translate); while (obj.max_angular_span() < ang_span_Thresh) { //restore to original scale obj.translate_object(-obj.centre); obj.scale_object((1.0f / tmp_scale)); //Rescale to new scale and translate tmp_scale *= 1.01f; obj.scale_object(tmp_scale); obj.translate_object(modified_obj.translate); } //if (modified_obj.compactess() < 0.14) // tmp_scale *= 1.3f; m.scale = tmp_scale; modified_obj.scale = tmp_scale; }
public static int[] CreateTriangleArray(OffObject ofObj) { // Triangles // tri is an array required by the Mesh of MeshFilter. int tot_trgs = ofObj.faces.Length; int[] tri = new int[3 * tot_trgs]; // Storing how each triangle will be drawn. for (int i = 0; i < tot_trgs; i++) { tri[3 * i] = (int)ofObj.faces[i].x; tri[3 * i + 1] = (int)ofObj.faces[i].y; tri[3 * i + 2] = (int)ofObj.faces[i].z; } return(tri); }
public OffObject generate_off_obj() { OffObject obj = new OffObject(); obj.InitializeVertices(verts, sym); obj.InitializeFaces(); obj.InitializeEdges(); //calling this would automatically compute face norms and norms and centre obj.recalc_centre_norms_and_face_norms(); //we want the object to have origin as centroid at the beginning obj.translate_object(obj.centre); ////stretch to vary compactness //AppData app = AppData.Instance; ////If it is a new session we always vary compactness //if (!app.is_saved_session) //{ // vary_cmpct_dir = UnityEngine.Random.Range(0, 2); // vary_cmpct_fctr = (float)Helper.get_random_double(0.2f, 5.0f); // Debug.Log("Current variance along: " + vary_cmpct_dir.ToString() + " By Fct: " + vary_cmpct_fctr.ToString()); // //Matrix4x4 tmp = Matrix4x4.identity; // if (vary_cmpct_dir == 1) // { // Matrix4x4 tmp = Helper.get_rot_Y(90); // obj.modify_object(tmp, vary_cmpct_fctr); // tmp = Matrix4x4.identity; // obj.modify_object(tmp, (1 / vary_cmpct_fctr)); // } // else // { // Matrix4x4 tmp = Matrix4x4.identity; // obj.modify_object(tmp, vary_cmpct_fctr); // tmp = Helper.get_rot_Y(90); // obj.modify_object(tmp, (1 / vary_cmpct_fctr)); // } //} //If it is a saved session, there are 2 possibilities: //1. The old model files are used which does not vary compactness. In this case, // The constructor sets the stretch factor to 1 and so no stretch happens. //2. The new model files which vary compactness is used. In this case, the load // function would load values for vary_cmpct_dir and vary_cmpct_fctr and the obj // would be stretched. return(obj); }
public void copy_properties_from(OffObject orig) { //Copy vertices int ln = orig.verts.Length; verts = new Vector3[ln]; for (int i = 0; i < ln; i++) { verts[i] = new Vector3(orig.verts[i].x, orig.verts[i].y, orig.verts[i].z); } //Copy faces (mapping) ln = orig.faces.Length; faces = new Vector3[ln]; for (int i = 0; i < ln; i++) { faces[i] = new Vector3(orig.faces[i].x, orig.faces[i].y, orig.faces[i].z); } //Copy edges ln = orig.edges.Length; edges = new Vector2[ln]; for (int i = 0; i < ln; i++) { edges[i] = new Vector2(orig.edges[i].x, orig.edges[i].y); } //Copy norms ln = orig.norms.Length; norms = new Vector3[ln]; for (int i = 0; i < ln; i++) { norms[i] = new Vector3(orig.norms[i].x, orig.norms[i].y, orig.norms[i].z); } //Copy face-norms ln = orig.face_norms.Length; face_norms = new Vector3[ln]; for (int i = 0; i < ln; i++) { face_norms[i] = new Vector3(orig.face_norms[i].x, orig.face_norms[i].y, orig.face_norms[i].z); } centre = new Vector3(orig.centre.x, orig.centre.y, orig.centre.z); scale = orig.scale; rotation = new Quaternion(orig.rotation.x, orig.rotation.y, orig.rotation.z, orig.rotation.w); translate = new Vector3(orig.translate.x, orig.translate.y, orig.translate.z); }
public double degree_of_asymmetry(OffObject obj2) { double ang_df = 0; int cntr = 0; for (int i = 0; i < 16; i++) { List <int> edg_lst = find_attached_edges(i); //for each pair of edges connected to vertex base for (int p = 0; p < edg_lst.Count; p++) { for (int q = p + 1; q < edg_lst.Count; q++) { ang_df += edge_angle_dif(i, edg_lst[p], edg_lst[q], obj2); cntr++; } } } return(ang_df / (cntr * Math.PI)); }
double edge_angle_dif(int i, int p, int q, OffObject obj2) { Vector3 p11, p12, p21, p22, v1, v2; //The current vertex being considered Vector3 base1 = verts[i]; Vector3 base2 = obj2.verts[i]; if (edges[p][0] != i) { p11 = verts[(int)edges[p][0]]; p21 = obj2.verts[(int)edges[p][0]]; } else { p11 = verts[(int)edges[p][1]]; p21 = obj2.verts[(int)edges[p][1]]; } if (edges[q][0] != i) { p12 = verts[(int)edges[q][0]]; p22 = obj2.verts[(int)edges[q][0]]; } else { p12 = verts[(int)edges[q][1]]; p22 = obj2.verts[(int)edges[q][1]]; } v1 = (p11 - base1).normalized; v2 = (p12 - base1).normalized; double cos_tht1 = Vector3.Dot(v1, v2); double tht1 = Math.Acos(cos_tht1); v1 = (p21 - base2).normalized; v2 = (p22 - base2).normalized; double cos_tht2 = Vector3.Dot(v1, v2); double tht2 = Math.Acos(cos_tht2); return(Math.Abs((tht1 - tht2))); }
public static void DisplayLine(OffObject ofObj, int startAt, GameObject[] lineGameObjz) { for (int i = 0; i < ofObj.edges.Length; i++) { var line = lineGameObjz[i + startAt].GetComponent <LineRenderer>(); Vector3 stPnt = ofObj.verts[(int)ofObj.edges[i].x]; Vector3 endPnt = ofObj.verts[(int)ofObj.edges[i].y]; stPnt += app.wire_frm_dst * (stPnt - ofObj.centre).normalized; // + ofObj.centre; endPnt += app.wire_frm_dst * (endPnt - ofObj.centre).normalized; // + ofObj.centre; // Number of vertices of the line, we need two vertices for drawing the edge. line.SetVertexCount(2); // Setting up the line and displaying it. line.SetPosition(0, stPnt); line.SetPosition(1, endPnt); line.SetWidth(app.line_width, app.line_width); line.material = new Material(Shader.Find("Particles/Additive")); line.SetColors(app.edge_clr, app.edge_clr); //line.useWorldSpace = true; line.useWorldSpace = false; } }
bool create_object(int isSym, int isCmp, float tSL, float tSH, float tCL, float tCH) { bool ret = true; m = new Model(); #region 1) Symmetric and Compact /* 1) ***************** Symmetric and Compact ******************/ if (isSym == 1 && isCmp == 1) { bool attempt_failed = true; int outCtr = 0, outCtrLmt = 100; do { m.regenerate(); modified_obj = m.generate_off_obj(); //The object is symmetric but if it is not compact if (modified_obj.compactess() < tCH) { attempt_failed = !modify_compactness(tCH, true); } outCtr++; } while (attempt_failed && outCtr < outCtrLmt); if (outCtr >= outCtrLmt) { ret = false; } } #endregion #region 2) Symmetric and in between Compact /* 2) ***************** Symmetric and in between Compact ******************/ if (isSym == 1 && isCmp == 0) { bool attempt_failed = true; int outCtr = 0, outCtrLmt = 100; do { m.regenerate(); modified_obj = m.generate_off_obj(); float df = (tCH - tCL); //The object is symmetric but if it is not compact if (modified_obj.compactess() < tCL) { float t = (float)Helper.get_random_double(tCL, tCH - (df / 4.0f)); attempt_failed = !modify_compactness(t, true); } //The object is symmetric but if it is compact else if (modified_obj.compactess() > tCH) { float t = (float)Helper.get_random_double(tCL + (df / 4.0f), tCH); attempt_failed = !modify_compactness(t, false); } outCtr++; } while (attempt_failed && outCtr < outCtrLmt); if (outCtr >= outCtrLmt) { ret = false; } } #endregion #region 3) Symmetric and Non-Compact /* 3) ***************** Symmetric and Non-Compact ******************/ if (isSym == 1 && isCmp == -1) { bool attempt_failed = true; int outCtr = 0, outCtrLmt = 100; do { m.regenerate(); modified_obj = m.generate_off_obj(); //The object is symmetric but if it is compact if (modified_obj.compactess() > tCL) { attempt_failed = !modify_compactness(tCL, false); } outCtr++; if (modified_obj.compactess() <= 0.11) { attempt_failed = true; } } while (attempt_failed && outCtr < outCtrLmt); if (outCtr >= outCtrLmt) { ret = false; } } #endregion #region 4) in between Symmetry and Compact /* 4) ***************** in between Symmetry and Compact ******************/ if (isSym == 0 && isCmp == 1) { bool isSat = false; int outOutCntr = 0, outOutCntrLmt = 100; do { int outCntr = 0, outCntrLmt = 100; bool tot_attempt_success = true; do { // First obtain desired compactness bool attempt_failed = true; int ctr = 0, ctrLmt = 100; float df = (tSH - tSL); //first we create a highly compact object, a little more compact than was asked for. float nwTCH = tCH + 0.3f * tCH; do { m.regenerate(); modified_obj = m.generate_off_obj(); if (modified_obj.compactess() < nwTCH) { attempt_failed = !modify_compactness(nwTCH, true); } ctr++; } while (attempt_failed && ctr < ctrLmt); if (ctr >= ctrLmt) { tot_attempt_success = false; } // Now modify Assymettry if (tot_attempt_success) { attempt_failed = true; ctr = 0; ctrLmt = 100; Matrix4x4 tmp = Matrix4x4.identity; tmp[2, 0] = 0.1f; tmp[2, 1] = 0.1f; do { if (modified_obj.degree_of_asymmetry() < tSL || modified_obj.degree_of_asymmetry() > tSH) { float ll = (float)Helper.get_random_double(tSL, tSL + 3.0 * df / 4.0f); attempt_failed = !modify_symmetry(ll, tSH, tmp); } ctr++; } while (attempt_failed && ctr < ctrLmt); if (ctr >= ctrLmt) { tot_attempt_success = false; } } outCntr++; } while (!tot_attempt_success && outCntr < outCntrLmt); if ((modified_obj.degree_of_asymmetry() >= tSL) && (modified_obj.degree_of_asymmetry() <= tSH) && (modified_obj.compactess() >= tCH)) { isSat = true; } outOutCntr++; } while (outOutCntr < outOutCntrLmt && !isSat); ret = isSat; } #endregion #region 5) in between Symmetry and in between Compactness /* 5) ***************** in between Symmetry and in between Compactness ******************/ if (isSym == 0 && isCmp == 0) { bool isSat = false; int outOutCntr = 0, outOutCntrLmt = 100; do { int outCntr = 0, outCntrLmt = 100; bool tot_attempt_success = true; do { // First obtain desired compactness bool attempt_failed = true; tot_attempt_success = true; int ctr = 0, ctrLmt = 100; float dfS = (tSH - tSL); //first we create a highly compact object, a little more compact than was asked for. do { m.regenerate(); modified_obj = m.generate_off_obj(); float dfC = (tCH - tCL); //The object is symmetric but if it is not compact if (modified_obj.compactess() < tCH) { //float t = (float)Helper.get_random_double(tCL + (dfC / 2.0f), tCH ); attempt_failed = !modify_compactness(tCH - dfC / 5.0f, true); } //The object is symmetric but if it is compact else if (modified_obj.compactess() > tCH) { //float t = (float)Helper.get_random_double(tCL + (dfC / 4.0f), tCH); attempt_failed = !modify_compactness(tCH - dfC / 5.0f, false); } ctr++; } while (attempt_failed && ctr < ctrLmt); if (ctr >= ctrLmt) { tot_attempt_success = false; } // Now modify Assymettry if (tot_attempt_success) { attempt_failed = true; ctr = 0; ctrLmt = 100; Matrix4x4 tmp = Matrix4x4.identity; tmp[2, 0] = 0.1f; tmp[2, 1] = 0.1f; do { if (modified_obj.degree_of_asymmetry() < tSL || modified_obj.degree_of_asymmetry() > tSH) { float ll = (float)Helper.get_random_double(tSL, tSL + 3.0 * dfS / 4.0f); attempt_failed = !modify_symmetry(ll, tSH, tmp); } ctr++; } while (attempt_failed && ctr < ctrLmt); if (ctr >= ctrLmt) { tot_attempt_success = false; } } outCntr++; } while (!tot_attempt_success && outCntr < outCntrLmt); if ((modified_obj.degree_of_asymmetry() >= tSL) && (modified_obj.degree_of_asymmetry() <= tSH) && (modified_obj.compactess() >= tCL) && (modified_obj.compactess() <= tCH)) { isSat = true; } outOutCntr++; } while (outOutCntr < outOutCntrLmt && !isSat); ret = isSat; } #endregion #region 6) in between Symmetry and not Compact /* 5) ***************** in between Symmetry and not Compact ******************/ if (isSym == 0 && isCmp == -1) { bool isSat = false; int outOutCntr = 0, outOutCntrLmt = 100; do { int outCntr = 0, outCntrLmt = 100; bool tot_attempt_success = true; do { // First obtain desired compactness bool attempt_failed = true; tot_attempt_success = true; int ctr = 0, ctrLmt = 100; float dfS = (tSH - tSL); float dfC = (tCH - tCL); //first we create a non compact object. do { m.regenerate(); modified_obj = m.generate_off_obj(); float t = tCL; if (modified_obj.compactess() > t) { attempt_failed = !modify_compactness(t, false); } ctr++; } while (attempt_failed && ctr < ctrLmt); if (ctr >= ctrLmt) { tot_attempt_success = false; } // Now modify Assymettry if (tot_attempt_success) { attempt_failed = true; ctr = 0; ctrLmt = 100; Matrix4x4 tmp = Matrix4x4.identity; tmp[2, 0] = 0.1f; tmp[2, 1] = 0.1f; do { if (modified_obj.degree_of_asymmetry() < tSL || modified_obj.degree_of_asymmetry() > tSH) { float ll = (float)Helper.get_random_double(tSL, tSL + 3.0 * dfS / 4.0f); attempt_failed = !modify_symmetry(ll, tSH, tmp); } ctr++; } while (attempt_failed && ctr < ctrLmt); if (ctr >= ctrLmt) { tot_attempt_success = false; } } outCntr++; } while (!tot_attempt_success && outCntr < outCntrLmt); if ((modified_obj.degree_of_asymmetry() >= tSL) && (modified_obj.degree_of_asymmetry() <= tSH) && (modified_obj.compactess() <= tCL) && (modified_obj.compactess() >= 0.11)) { isSat = true; } outOutCntr++; } while (outOutCntr < outOutCntrLmt && !isSat); ret = isSat; } #endregion #region 7) Asymmetric and Compact /* 7) ***************** Asymmetric and Compact ******************/ if (isSym == -1 && isCmp == 1) { bool isSat = false; int outOutCntr = 0, outOutCntrLmt = 100; do { int outCntr = 0, outCntrLmt = 100; bool tot_attempt_success = true; do { // First obtain desired compactness bool attempt_failed = true; tot_attempt_success = true; int ctr = 0, ctrLmt = 100; float df = (tSH - tSL); //first we create a highly compact object, a little more compact than was asked for. float nwTCH = tCH + 0.4f * tCH; do { m.regenerate(); modified_obj = m.generate_off_obj(); if (modified_obj.compactess() < nwTCH) { attempt_failed = !modify_compactness(nwTCH, true); } ctr++; } while (attempt_failed && ctr < ctrLmt); if (ctr >= ctrLmt) { tot_attempt_success = false; } // Now modify Assymettry if (tot_attempt_success) { attempt_failed = true; ctr = 0; ctrLmt = 100; Matrix4x4 tmp = Matrix4x4.identity; tmp[2, 0] = 0.1f; tmp[2, 1] = 0.1f; do { if (modified_obj.degree_of_asymmetry() < tSH) { float ll = (float)Helper.get_random_double(tSH, tSH + df / 4.0f); attempt_failed = !modify_symmetry(ll, 1.0f, tmp); } ctr++; } while (attempt_failed && ctr < ctrLmt); if (ctr >= ctrLmt) { tot_attempt_success = false; } } outCntr++; } while (!tot_attempt_success && outCntr < outCntrLmt); if ((modified_obj.degree_of_asymmetry() >= tSH) && (modified_obj.compactess() >= tCH)) { isSat = true; } outOutCntr++; } while (outOutCntr < outOutCntrLmt && !isSat); ret = isSat; } #endregion #region 8) Asymmetric and in between Compact /* 7) ***************** Asymmetric and in between Compact ******************/ if (isSym == -1 && isCmp == 0) { bool isSat = false; int outOutCntr = 0, outOutCntrLmt = 100; do { int outCntr = 0, outCntrLmt = 100; bool tot_attempt_success = true; do { // First obtain desired compactness bool attempt_failed = true; tot_attempt_success = true; int ctr = 0, ctrLmt = 100; float df = (tSH - tSL); //first we create a highly compact object, a little more compact than was asked for. float nwTCH = tCH + 0.4f * tCH; do { m.regenerate(); modified_obj = m.generate_off_obj(); float dfC = (tCH - tCL); //The object is symmetric but if it is not compact if (modified_obj.compactess() < tCH) { //float t = (float)Helper.get_random_double(tCL + (dfC / 2.0f), tCH ); attempt_failed = !modify_compactness(tCH, true); } //The object is symmetric but if it is compact else if (modified_obj.compactess() > tCH) { //float t = (float)Helper.get_random_double(tCL + (dfC / 4.0f), tCH); attempt_failed = !modify_compactness(tCH + dfC / 8.0f, false); } ctr++; } while (attempt_failed && ctr < ctrLmt); if (ctr >= ctrLmt) { tot_attempt_success = false; } // Now modify Assymettry if (tot_attempt_success) { attempt_failed = true; ctr = 0; ctrLmt = 100; Matrix4x4 tmp = Matrix4x4.identity; tmp[2, 0] = 0.1f; tmp[2, 1] = 0.1f; do { if (modified_obj.degree_of_asymmetry() < tSH) { float ll = (float)Helper.get_random_double(tSH, tSH + df / 4.0f); attempt_failed = !modify_symmetry(ll, 1.0f, tmp); } ctr++; } while (attempt_failed && ctr < ctrLmt); if (ctr >= ctrLmt) { tot_attempt_success = false; } } outCntr++; } while (!tot_attempt_success && outCntr < outCntrLmt); if ((modified_obj.degree_of_asymmetry() >= tSH) && (modified_obj.compactess() >= tCL) && (modified_obj.compactess() <= tCH)) { isSat = true; } outOutCntr++; } while (outOutCntr < outOutCntrLmt && !isSat); ret = isSat; } #endregion #region 9) Asymmetric and non-Compact /* 7) ***************** Asymmetric and non-Compact ******************/ if (isSym == -1 && isCmp == -1) { bool isSat = false; int outOutCntr = 0, outOutCntrLmt = 100; do { int outCntr = 0, outCntrLmt = 100; bool tot_attempt_success = true; do { // First obtain desired compactness bool attempt_failed = true; tot_attempt_success = true; int ctr = 0, ctrLmt = 100; float df = (tSH - tSL); //first we create a highly compact object, a little more compact than was asked for. float nwTCH = tCH + 0.4f * tCH; do { m.regenerate(); modified_obj = m.generate_off_obj(); float t = tCL + (tCH - tCL) / 2; if (modified_obj.compactess() > t) { attempt_failed = !modify_compactness(t, false); } ctr++; } while (attempt_failed && ctr < ctrLmt); if (ctr >= ctrLmt) { tot_attempt_success = false; } // Now modify Assymettry if (tot_attempt_success) { attempt_failed = true; ctr = 0; ctrLmt = 100; Matrix4x4 tmp = Matrix4x4.identity; tmp[2, 0] = 0.1f; tmp[2, 1] = 0.1f; do { if (modified_obj.degree_of_asymmetry() < tSH) { float ll = (float)Helper.get_random_double(tSH, tSH + df / 4.0f); attempt_failed = !modify_symmetry(ll, 1.0f, tmp); } ctr++; } while (attempt_failed && ctr < ctrLmt); if (ctr >= ctrLmt) { tot_attempt_success = false; } } outCntr++; } while (!tot_attempt_success && outCntr < outCntrLmt); if ((modified_obj.degree_of_asymmetry() >= tSH) && (modified_obj.compactess() <= tCL) && (modified_obj.compactess() >= 0.11)) { isSat = true; } outOutCntr++; } while (outOutCntr < outOutCntrLmt && !isSat); ret = isSat; } #endregion return(ret); }
bool is_view_acceptable() { obj = new OffObject(); obj.copy_properties_from(modified_obj); //Rotate obj.rotate_object(m.rv_rot_mat); //scale obj.scale_object((float)m.scale); //translate //m.pos.z *= -1; obj.translate_object(m.pos); //Unity is left-handed for (int k = 0; k < 16; k++) { obj.verts[k].z *= -1; } obj.recalc_centre_norms_and_face_norms(); // int[] baze = { 0, 1, 2, 3, 8, 9, 10, 11 }; int[] non_baze = { 4, 5, 6, 7, 12, 13, 14, 15 }; //Among the non-baze, how many are vsible? int vis_num = 0; int tmpCntr; for (int i = 0; i < 8; i++) { tmpCntr = 0; Vector3 cv = obj.verts[non_baze[i]]; for (int j = 0; j < obj.faces.Length; j++) { //if the trg contains this vertex if (obj.faces[j].x == non_baze[i] || obj.faces[j].y == non_baze[i] || obj.faces[j].z == non_baze[i]) { tmpCntr++; continue; } Vector3[] trg = { obj.verts[(int)obj.faces[j].x], obj.verts[(int)obj.faces[j].y], obj.verts[(int)obj.faces[j].z] }; if (Helper.is_vertex_occluded(trg, cv)) { break; } tmpCntr++; } // if none of the faces block it if (tmpCntr++ >= obj.faces.Length) { vis_num++; } } //Debug.Log("vis_num:" + vis_num.ToString()); //if atleast 5 of them are not visible, return failed if (vis_num < 6) { //if (cntr == (attLmt - 1)) //{ // Debug.Log("Non-base vertex count fail"); //} return(false); } //Now we need to check if a total of 10 vertices are visible for (int i = 0; i < 8; i++) { Vector3 cv = obj.verts[baze[i]]; tmpCntr = 0; for (int j = 0; j < obj.faces.Length; j++) { //if the trg contains this vertex if (obj.faces[j].x == baze[i] || obj.faces[j].y == baze[i] || obj.faces[j].z == baze[i]) { tmpCntr++; continue; } Vector3[] trg = { obj.verts[(int)obj.faces[j].x], obj.verts[(int)obj.faces[j].y], obj.verts[(int)obj.faces[j].z] }; if (Helper.is_vertex_occluded(trg, cv)) { break; } tmpCntr++; } if (tmpCntr >= obj.faces.Length) { vis_num++; } if (vis_num >= 11) { return(true); } } //if (cntr == (attLmt - 1)) //{ // Debug.Log("All vertex count fail"); //} return(false); }