コード例 #1
0
ファイル: symmetries.cpp プロジェクト: dtegunov/vlion
// Add matrix ==============================================================
void SymList::add_matrices(const Matrix2D<DOUBLE> &L, const Matrix2D<DOUBLE> &R,
                           int chain_length)
{
    if (MAT_XSIZE(L) != 4 || MAT_YSIZE(L) != 4 || MAT_XSIZE(R) != 4 || MAT_YSIZE(R) != 4)
        REPORT_ERROR( "SymList::add_matrix: Transformation matrix is not 4x4");
    if (TrueSymsNo() == SymsNo())
    {
        __L.resize(MAT_YSIZE(__L) + 4, 4);
        __R.resize(MAT_YSIZE(__R) + 4, 4);
        __chain_length.resize(__chain_length.size() + 1);
    }

    set_matrices(true_symNo, L, R);
    __chain_length(__chain_length.size() - 1) = chain_length;
    true_symNo++;
}
コード例 #2
0
ファイル: 2DRendering.cpp プロジェクト: sunhanpt/SoftR
void RB2DRenderingEffect::render(const RBCamera* cam, std::vector<RBD3D11Texture2D*>& objs)
{
	//g_env->d3d_context->OMSetRenderTargets(1, &g_env->d3d_RenderTargetView, g_env->d3d_DepthStencilView);
	//g_env->d3d_context->ClearRenderTargetView(g_env->d3d_RenderTargetView, reinterpret_cast<const float*>(&RBColorf::gray));
	//g_env->d3d_context->ClearDepthStencilView(g_env->d3d_DepthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);
	std::vector<RBD3D11Texture2D*>::iterator it;
	RBD3D11Texture2D* tex;
	apply();
	it = objs.begin();
	for (;it!=objs.end();++it)
	{
		tex = *it;
		if (!tex->obj->is_visible()) continue;
		ID3D11ShaderResourceView* view = tex->get_texture_view();
		g_env->d3d_context->PSSetShaderResources(0, 1, &view);
		
		g_env->d3d_context->PSSetSamplers(0, 1, &m_sampleState);
		
		RBMatrix m, v, o;
		tex->obj->_node->get_mat(m);
		cam->get_view_matrix(v);
		//cam->get_ortho(o);
		cam->get_perspective_matrix(o);
		set_matrices(m.get_transposed(), v.get_transposed(), o.get_transposed());
		if (tex->obj->debug_draw)
			active_normal();

		RBEffect::render(tex->obj);


		if (tex->obj->debug_draw)
			inactive_normal();


	}

	clear();
}
コード例 #3
0
ファイル: symmetries.cpp プロジェクト: dtegunov/vlion
// Read Symmetry file ======================================================
// crystal symmetry matices from http://cci.lbl.gov/asu_gallery/
int SymList::read_sym_file(FileName fn_sym)
{
    int i, j;
    FILE *fpoii;
    char line[80];
    char *auxstr;
    DOUBLE ang_incr, rot_ang;
    int  fold;
    Matrix2D<DOUBLE> L(4, 4), R(4, 4);
    Matrix1D<DOUBLE> axis(3);
    int pgGroup = 0, pgOrder = 0;
    std::vector<std::string> fileContent;

    //check if reserved word

    // Open file ---------------------------------------------------------
    if ((fpoii = fopen(fn_sym.c_str(), "r")) == NULL)
    {
        //check if reserved word and return group and order
        if (isSymmetryGroup(fn_sym, pgGroup, pgOrder))
        {
        	fill_symmetry_class(fn_sym, pgGroup, pgOrder, fileContent);
        }
        else
            REPORT_ERROR((std::string)"SymList::read_sym_file:Can't open file: "
                     + " or do not recognize symmetry group" + fn_sym);
    }
    else
    {
        while (fgets(line, 79, fpoii) != NULL)
        {
            if (line[0] == ';' || line[0] == '#' || line[0] == '\0')
            	continue;
			fileContent.push_back(line);
        }
        fclose(fpoii);
    }

    // Count the number of symmetries ------------------------------------
    true_symNo = 0;
    // count number of axis and mirror planes. It will help to identify
    // the crystallographic symmetry

    int no_axis, no_mirror_planes, no_inversion_points;
    no_axis = no_mirror_planes = no_inversion_points = 0;

    for (int n=0; n<fileContent.size(); n++)
    {
    	strcpy(line,fileContent[n].c_str());
        auxstr = firstToken(line);
        if (auxstr == NULL)
        {
            std::cout << line;
            std::cout << "Wrong line in symmetry file, the line is skipped\n";
            continue;
        }
        if (strcmp(auxstr, "rot_axis") == 0)
        {
            auxstr = nextToken();
            fold = textToInteger(auxstr);
            true_symNo += (fold - 1);
            no_axis++;
        }
        else if (strcmp(auxstr, "mirror_plane") == 0)
        {
            true_symNo++;
            no_mirror_planes++;
        }
        else if (strcmp(auxstr, "inversion") == 0)
        {
            true_symNo += 1;
            no_inversion_points = 1;
        }
    }
    // Ask for memory
    __L.resize(4*true_symNo, 4);
    __R.resize(4*true_symNo, 4);
    __chain_length.resize(true_symNo);
    __chain_length.initConstant(1);

    // Read symmetry parameters
    i = 0;
    for (int n=0; n<fileContent.size(); n++)
    {
        strcpy(line,fileContent[n].c_str());
        auxstr = firstToken(line);
        // Rotational axis ---------------------------------------------------
        if (strcmp(auxstr, "rot_axis") == 0)
        {
            auxstr = nextToken();
            fold = textToInteger(auxstr);
            auxstr = nextToken();
            XX(axis) = textToDOUBLE(auxstr);
            auxstr = nextToken();
            YY(axis) = textToDOUBLE(auxstr);
            auxstr = nextToken();
            ZZ(axis) = textToDOUBLE(auxstr);
            ang_incr = 360. / fold;
            L.initIdentity();
            for (j = 1, rot_ang = ang_incr; j < fold; j++, rot_ang += ang_incr)
            {
                rotation3DMatrix(rot_ang, axis, R);
                R.setSmallValuesToZero();
                set_matrices(i++, L, R.transpose());
            }
            __sym_elements++;
            // inversion ------------------------------------------------------
        }
        else if (strcmp(auxstr, "inversion") == 0)
        {
            L.initIdentity();
            L(2, 2) = -1;
            R.initIdentity();
            R(0, 0) = -1.;
            R(1, 1) = -1.;
            R(2, 2) = -1.;
            set_matrices(i++, L, R);
            __sym_elements++;
            // mirror plane -------------------------------------------------------------
        }
        else if (strcmp(auxstr, "mirror_plane") == 0)
        {
            auxstr = nextToken();
            XX(axis) = textToFloat(auxstr);
            auxstr = nextToken();
            YY(axis) = textToFloat(auxstr);
            auxstr = nextToken();
            ZZ(axis) = textToFloat(auxstr);
            L.initIdentity();
            L(2, 2) = -1;
            Matrix2D<DOUBLE> A;
            alignWithZ(axis,A);
            A = A.transpose();
            R = A * L * A.inv();
            L.initIdentity();
            set_matrices(i++, L, R);
            __sym_elements++;
        }
    }

    compute_subgroup();

    return pgGroup;
}
コード例 #4
0
ファイル: Camera.cpp プロジェクト: ptierney/cinder_sketches
 void Camera::update() {
     set_matrices();
 }