Beispiel #1
0
//甘特图等 xy坐标轴交换的 bar
QWidget * Widget::addSwapXY()
{
    XYChart * _xychart= new XYChart(800,800);
    _xychart->swapXY(true);

    std::vector<int> _vec(10,1);
    _vec[2]=10;
    _vec[4]=100;

    int array[_vec.size()];
    memcpy(array,(void *)(&_vec[0]),sizeof(int)*_vec.size());

    for(int i=0;i< _vec.size();++i)
    {
        qDebug()<<"cccccccccccccccccc:"<< array[i];
    }



    QWidget * _widget= new QWidget();
    QChartViewer * _v= new QChartViewer(_widget);
    _v->setChart(_xychart);
    return _widget;
}
Beispiel #2
0
 double vector_t::at(int index) const
 {
     PRX_ASSERT( (int)_vec.size() > index );
     return _vec(index);
 }
Beispiel #3
0
//--------------------------------------------------------------
void testApp::update(){
    
    float t = (ofGetElapsedTimef()) * 0.9f;
    float div = 250.0;
    
    for (int j=0; j<NUM_STRIP; j++)
    {
        //
        
        
        ofVec3f _vec(ofSignedNoise(t, pos[j].y/div, pos[j].z/div),
                    ofSignedNoise(pos[j].x/div, t, pos[j].z/div),
                    0);
        _vec *=  ofGetLastFrameTime()*50;
//        vec.x+=ofGetLastFrameTime()*1000;
        vec[j]+=_vec;
        vec[j]+=acc[j];
        vec[j]*=0.9;
        if(pos[j].y<-200)
        {
            age[j] = 1;
            pos[j].y = ofGetHeight();
            for (int i=0; i<LOC_LENGTH; i++)
            {
                int index = i+(j*LOC_LENGTH);
                loc[index].set(pos[j]);
            }
        }
        else if(pos[j].x<-200)
        {
                        age[j] = 1;
            pos[j].x = ofGetWidth();
            for (int i=0; i<LOC_LENGTH; i++)
            {
                int index = i+(j*LOC_LENGTH);
                loc[index].set(pos[j]);
            }
        }
        else if(pos[j].y>ofGetHeight()+200)
        {
                        age[j] = 1;
            pos[j].y = 0;
            for (int i=0; i<LOC_LENGTH; i++)
            {
                int index = i+(j*LOC_LENGTH);
                loc[index].set(pos[j]);
            }
        }
        else if(pos[j].x>ofGetWidth()+200)
        {
                        age[j] = 1;
            pos[j].x = 0;
            for (int i=0; i<LOC_LENGTH; i++)
            {
                int index = i+(j*LOC_LENGTH);
                loc[index].set(pos[j]);
            }
        }
        else if(age[j]>0)
        {
            ofVec3f Off;
            float radius = 10;
            for (int i=LOC_LENGTH-1; i>=1; i--)
            {
                int index = i+(j*LOC_LENGTH);
                loc[index].set(loc[index-1]);
            }
            for (int i=0; i<LOC_LENGTH; i++)
            {
                int index = i+(j*LOC_LENGTH);
                int index2 = (i*2)+(j*LENGTH);
                

                radius = sinf(PI*float(i*1.f/LOC_LENGTH))*5;
                {
                    ofVec3f perp0 = loc[index] - loc[index+1];
                    ofVec3f perp1 = perp0.getCrossed( ofVec3f( 0, 1, 0 ) ).getNormalized();
                    ofVec3f perp2 = perp0.getCrossed( perp1 ).getNormalized();
                    perp1 = perp0.getCrossed( perp2 ).getNormalized();
                    Off.x        = perp1.x * radius*age[j];// * agePer * per * .05;
                    Off.y       = perp1.y * radius*age[j];// * agePer * per * .05;
                    Off.z        = perp1.z * radius*age[j];// * agePer * per * .05;
                    
                    strip[(index2)]=loc[index]-Off;
                    
                    strip[(index2+1)]=loc[index]+Off;
                }
            }
            loc[j*LOC_LENGTH] = pos[j];
            pos[j]+=vec[j];
            age[j]-=0.01;
        }
        else
        {
            for (int i=0; i<LOC_LENGTH; i++)
            {
                int index = i+(j*LOC_LENGTH);
                loc[index].set(pos[j]);
            }
        }
        
        
    }
}
Beispiel #4
0
void DrawOBB(Mtx M_view, OBB& box, u32 color, bool drawAxes) {
	//for (int i = 0; i < 3; i++)
		//SYS_LOG(L"u%i={%.3f, %.3f, %.3f}", i, box.u[i].x, box.u[i].y, box.u[i].z);
	//SYS_LOG(L"color=%x", color);
	GX_ClearVtxDesc();

	GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
    GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);

    GX_SetVtxAttrFmt(GX_VTXFMT5, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
    GX_SetVtxAttrFmt(GX_VTXFMT5, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);

	// build and load model-view matrix
	Mtx M_modelView;
	guMtxIdentity(M_modelView);
	
	// rotation
	M_modelView[0][0] = box.u[0].x;		M_modelView[0][1] = box.u[0].y;		M_modelView[0][2] = box.u[0].z;
	M_modelView[1][0] = box.u[1].x;		M_modelView[1][1] = box.u[1].y;		M_modelView[1][2] = box.u[1].z;
	M_modelView[2][0] = box.u[2].x;		M_modelView[2][1] = box.u[2].y;		M_modelView[2][2] = box.u[2].z;
	
	// translation
	M_modelView[0][3] = box.c.x;		M_modelView[1][3] = box.c.y;		M_modelView[2][3] = box.c.z;

	guMtxConcat(M_view, M_modelView, M_modelView);
	GX_LoadPosMtxImm(M_modelView, GX_PNMTX0);

	GX_SetNumChans(1); // default, color = vertex color
	//GX_SetNumTexGens(0);

    GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
    GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);

	u8 indices[8] = {0, 1, 0, 2, 1, 3, 2, 3};
	f32* e = box.e;

	guVector v_bottom[4];
	v_bottom[0] = _vec(-e[0], -e[1], +e[2]);
	v_bottom[1] = _vec(+e[0], -e[1], +e[2]);
	v_bottom[2] = _vec(-e[0], -e[1], -e[2]);
	v_bottom[3] = _vec(+e[0], -e[1], -e[2]);

	guVector v_top[4];
	for (int i = 0; i < 4; i++)
		v_top[i] = _vec(v_bottom[i].x, e[1], v_bottom[i].z);

	GX_Begin(GX_LINES, GX_VTXFMT5, 24);
		// draw bottom
		for (u8 i = 0; i < 8; i += 2) {
			guVector& v0 = v_bottom[indices[i]];
			guVector& v1 = v_bottom[indices[i+1]];

			SendVertex(v0, color);
			SendVertex(v1, color);
		}

		// draw top
		for (u8 i = 0; i < 8; i += 2) {
			guVector& v0 = v_top[indices[i]];
			guVector& v1 = v_top[indices[i+1]];

			SendVertex(v0, color);
			SendVertex(v1, color);
		}

		// connect bottom vertices with the top ones
		for (u8 i = 0; i < 4; i++) {
			guVector& v0 = v_bottom[i];
			guVector& v1 = v_top[i];

			SendVertex(v0, color);
			SendVertex(v1, color);
		}
	GX_End();

	if (!drawAxes)
		return;

	// axes
	const f32 len = 150;
	GX_Begin(GX_LINES, GX_VTXFMT5, 6);
		guVector zero	= {0, 0, 0};
		guVector x_unit = {len, 0, 0};
		guVector y_unit = {0, len, 0};
		guVector z_unit = {0, 0, len};

		color = 0xFF0000FF;
		SendVertex(zero, color);
		SendVertex(x_unit, color);

		color = 0x00FF00FF;
		SendVertex(zero, color);
		SendVertex(y_unit, color);

		color = 0x0000FFFF;
		SendVertex(zero, color);
		SendVertex(z_unit, color);
	GX_End();
}
Beispiel #5
0
void DrawAABB(MtxP M_model, Mtx M_view, AABB& box, u32 color) {
	GX_ClearVtxDesc();

	GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
    GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);

    GX_SetVtxAttrFmt(GX_VTXFMT5, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
    GX_SetVtxAttrFmt(GX_VTXFMT5, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);

	// build and load model-view matrix
	Mtx M_modelView;
	guMtxIdentity(M_modelView);
	guMtxConcat(M_view, M_model, M_modelView);
	GX_LoadPosMtxImm(M_modelView, GX_PNMTX0);

	GX_SetNumChans(1); // default, color = vertex color
	//GX_SetNumTexGens(0);

    GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
    GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);

	u8 indices[8] = {0, 1, 0, 2, 1, 3, 2, 3};
	guVector& m = box.min;
	f32* d = box.d;

	guVector v_bottom[4];
	v_bottom[0] = _vec(m.x,			m.y,	m.z);	
	v_bottom[1] = _vec(m.x + d[0],	m.y,	m.z);
	v_bottom[2] = _vec(m.x,			m.y,	m.z + d[2]);
	v_bottom[3] = _vec(m.x + d[0],	m.y,	m.z + d[2]);

	guVector v_top[4];
	for (int i = 0; i < 4; i++)
		v_top[i] = _vec(v_bottom[i].x, v_bottom[i].y + d[1], v_bottom[i].z);

	GX_Begin(GX_LINES, GX_VTXFMT5, 24);
		// draw bottom
		for (u8 i = 0; i < 8; i += 2) {
			guVector& v0 = v_bottom[indices[i]];
			guVector& v1 = v_bottom[indices[i+1]];

			SendVertex(v0, color);
			SendVertex(v1, color);
		}

		// draw top
		for (u8 i = 0; i < 8; i += 2) {
			guVector& v0 = v_top[indices[i]];
			guVector& v1 = v_top[indices[i+1]];

			SendVertex(v0, color);
			SendVertex(v1, color);
		}

		// connect bottom vertices with the top ones
		for (u8 i = 0; i < 4; i++) {
			guVector& v0 = v_bottom[i];
			guVector& v1 = v_top[i];

			SendVertex(v0, color);
			SendVertex(v1, color);
		}
	GX_End();
}