Ejemplo n.º 1
0
void CMeteorit::Init(CRoot * root, CScene * scene)
{
	//Textur draufwerfen
	m_zMaterialMeteorit[0].SetBumpStrength(2);
	m_zMaterialMeteorit[0].MakeTextureDiffuse("textures\\textur1.jpg");
	m_zMaterialMeteorit[0].MakeTextureBump("textures\\textur1Bump.png");

	m_zMaterialMeteorit[1].SetBumpStrength(2);
	m_zMaterialMeteorit[1].MakeTextureDiffuse("textures\\textur2.JPG");
	m_zMaterialMeteorit[1].MakeTextureBump("textures\\textur2Bump.png");

	m_zMaterialMeteorit[2].SetBumpStrength(2);
	m_zMaterialMeteorit[2].MakeTextureDiffuse("textures\\textur3.jpg");
	m_zMaterialMeteorit[2].MakeTextureBump("textures\\textur3Bump.png");

	//Kugel initialisieren
	m_zgMeteorit[0].Init(2.0F, &m_zMaterialMeteorit[0]);
	m_zgMeteorit[1].Init(2.0F, &m_zMaterialMeteorit[1]);
	m_zgMeteorit[2].Init(2.0F, &m_zMaterialMeteorit[2]);

	//Deformieren
	Deform();

	//Prepare Roation
	PrepareRotate(); 

	//Meteoriten hinzufügen
	for (int i = 0; i < MAX_METEOR; i++)
	{
		//Random wert
		float fGroesse = (float)((rand() % 35) / 50.0F) + 0.5F;

		//Random Meteoriten auswählen
		int varMeteor = (rand() % 3);

		//Meteorit Transformieren
		fScale[i] = fGroesse; 

		//Meteoriten dem Placement geben
		m_zpMeteoriten[i].AddGeo(&m_zgMeteorit[varMeteor]);
	}

	//Texturen dem Root hinzufügen
	for (int i = 0; i < 3; i++)
	{
		root->AddMaterial(&m_zMaterialMeteorit[i]);
	}

	//Meteoriten in die Szene laden
	for (int i = 0; i < MAX_METEOR; i++)
	{
		scene->AddPlacement(&m_zpMeteoriten[i]);
	}

}
Ejemplo n.º 2
0
// # Description
//   X方向の小さいモデルで転位を作ってX方向を拡張するためのプログラム
// # Arguments
// 1. ARGV[1]
//   cmdsファイル
// # Contents of cmds
// 1. コンディションファイル
// 2. 作成するモデル数
// 3. 拡張したいモデルの名前 拡張したいモデルの角度 拡張後のX方向大きさ SPBC_DZ
// 4. 拡張したいモデルの名前 拡張したいモデルの角度 拡張後のX方向大きさ SPBC_DZ
// 5.                                 :
// 6.                                 :
// 7.                                 :
int  main (int argc, char *argv[])
{
    LATTICE_t  lattice;
    MD_t md, cliped_md;
    CONDITION_t condition;
    lattice.x = NULL;
    md.atom = NULL;
    int  i, j, n, nx, ny, nz;
    char  output_file_name[256], cnd_file_name[256], cmd_name[256], mdl_name[256], cmds_update_output[256], cnd_file_input[256];
    double  b, b_x, b_z, new_x, scale_top_x, scale_bottom_x, rad, spbc_dz;
    FILE  *fp, *mdl_fp, *cmds_update_fp;
    char *home = getenv("HOME");

    char  file_name[256];
    if(argc > 1) {
        sprintf (file_name, "%s", argv[1]);
    } else {
        fprintf (stdout, "ファイル名: ");
        fflush (stdout);
        fscanf (stdin, "%s", file_name);
    }

    sprintf (cmd_name, "%s/lab_src/cmds/%s.cmds", home, file_name);
    fp = fopen (cmd_name, "r");
    if (fp == NULL) {
        fprintf (stdout, "%s ファイルが開けません\n", file_name);
        return 1;
    }
    sprintf (mdl_name, "%s/lab_src/mdls/%s.mdls", home, file_name);
    mdl_fp = fopen (mdl_name, "w");
    sprintf (cmds_update_output, "%s/lab_src/cmds/%s_update.cmds", home, file_name);
    cmds_update_fp = fopen (cmds_update_output, "w");

    fscanf (fp, "%s", cnd_file_name);
    fscanf (fp, "%d", &n);
    // fscanf (fp, "%lf %lf %lf", &lx, &ly, &lz);
    ARG_t arg[n];
    sprintf (cnd_file_input, "%s/lab_src/%s", home, cnd_file_name);

    fprintf(cmds_update_fp, "%s\n", cnd_file_name);
    fprintf(cmds_update_fp, "%d\n", n);

    for (i = 0; i < n; i++) {
        fscanf (fp, "%lf%lf%lf%lf%lf%lf",
                &arg[i].a0,
                &arg[i].deg,
                &arg[i].clip_x,
                &arg[i].lx,
                &arg[i].ly,
                &arg[i].lz);
    }

    for (i = 0; i < n; i++) {
        InitializeAtoms (&md);
        InitializeAtoms (&cliped_md);
        InitializeLattice (&lattice);

        sprintf (output_file_name, "%s/lab_src/lats/bcc110_deg%.4lf.lat", home, arg[i].deg);
        rad = (arg[i].deg - 90.0) * M_PI / 180.0;
        if (ReadLattice (&lattice, output_file_name)) {
            GenerateLatticeType0 (&lattice, arg[i].a0);
            GenerateAtoms (&md, &lattice, 200, 1, 200);
            for (j = 0; j < md.nAtoms; j++) {
                md.atom[j].x -= md.lx / 2.0;
                md.atom[j].y -= md.ly / 2.0;
                md.atom[j].z -= md.lz / 2.0;
            }
            ClipAtoms (&md, &cliped_md, arg[i].clip_x, arg[i].a0 / 4.0, rad, arg[i].a0);
            WriteLattice (&cliped_md, output_file_name);
            ReadLattice (&lattice, output_file_name);
        }

        nx = ceil (arg[i].lx / lattice.lx);
        ny = ceil (arg[i].ly / (2.0 * lattice.ly)) * 2; // 偶数
        nz = ceil (arg[i].lz / lattice.lz);
        GenerateAtoms (&md, &lattice, nx, ny, nz);

        // CheckAtomsInDiscRange (&md, md.lx / 2.0, md.ly / 2.0 + arg[i].a0 / 4.0, 0.0, 0.0, 0.0, 1.0, 11.2, md.lz * 10.0);
        // SetAtomType (&md, 1);
        // UncheckAllAtoms (&md);

        b = arg[i].a0 * sqrt (3) / 2.0;
        b_x = b * cos (rad);
        b_z = b * sin (rad);
        new_x = md.lx + b_x / 2.0;
        // new_x = md.lx; // 下に合わせる
        // new_x = md.lx + b_x; // 上に合わせる
        scale_top_x = new_x / (md.lx + b_x);
        scale_bottom_x = new_x / md.lx;
        spbc_dz = b_z / 2.0;

        // cutting from right bottom
        // CheckAtomsInCubeRange (&md, md.lx - b_x, md.lx, 0.0, md.ly / 2.0 - arg[i].a0 / 4.0, 0.0, md.lz);
        // cutting from left top
        CheckAtomsInCubeRange (&md, -INF, 2.0 * b_x, md.ly / 2.0 - arg[i].a0 / 4.0, INF, -INF, INF);
        DuplicateAtoms (&md, md.lx, 0.0, 0.0);
        // SetAtomType (&md, 1);
        UncheckAllAtoms (&md);

        CheckAtomsInYRange (&md, -INF, md.ly / 2.0 - arg[i].a0 / 4.0);
        Scale (&md, scale_bottom_x, 1.0, 1.0, scale_bottom_x, 1.0, 1.0);
        Deform (&md, md.lx, spbc_dz);
        UncheckAllAtoms (&md);

        CheckAtomsInYRange (&md, md.ly / 2.0 - arg[i].a0 / 4.0, INF);
        Scale (&md, scale_top_x, 1.0, 1.0, 1.0, 1.0, 1.0);
        Deform (&md, md.lx, -spbc_dz);
        UncheckAllAtoms (&md);

        // Displacement (&md, md.lx / 2.0, md.ly / 2.0 + arg[i].a0 / 4.0, b_x, b_z);

        CheckAtomsInYRange (&md, -INF, 10.6);
        CheckAtomsInYRange (&md, md.ly - 10.6, INF);
        SetFixAtomBC (&md, 2);
        UncheckAllAtoms (&md);

        CheckAtomsInXRange (&md, -INF, 2.0 * b_x);
        CheckAtomsInXRange (&md, md.lx - 2.0 * b_x, INF);
        ValidateDuplication (&md, spbc_dz, arg[i].a0 / 4.0);
        UncheckAllAtoms (&md);

        // sprintf (output_file_name, "deg_%lf.xxyz", arg[i].deg);
        // WriteAtomsToXXYZ (&md, output_file_name);

        ReadCondition (&condition, cnd_file_input);
        condition.bc.displacement_ux = cos(rad);
        condition.bc.displacement_uz = sin(rad);
        condition.bc.displacement_h = 10.6;
        condition.bc.stress_ex = cos(rad);
        condition.bc.stress_ez = sin(rad);
        condition.bc.spbc_dz = spbc_dz;

        sprintf (output_file_name, "%s_deg%.4lf_nx%d_ny%d_nz%d_mix", file_name, arg[i].deg, nx, ny, nz);
        fprintf(cmds_update_fp, "%s %lf %lf\n", output_file_name, arg[i].deg, spbc_dz);
        strcat (output_file_name, ".mdl");
        WriteAtomsToMDL (&md, output_file_name, condition);
        fprintf(mdl_fp, "%s\n", output_file_name);
    }

    fclose (fp);
    fclose (mdl_fp);
    fclose (cmds_update_fp);
    return 0;
}