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); }
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); }