Exemple #1
0
void SnowModel::checkBoundingBox() {
    float minX = 0.0f, minY = 0.0f, minZ = 0.0f;
    float maxX = 0.0f, maxY = 0.0f, maxZ = 0.0f;

    if (edge_groups.size() > 0) {
        std::vector<EdgeGroup*>::iterator it = edge_groups.begin();

        BBox3f bb = (*it)->GetBoundingBox();
        point3f minBB = bb.min;
        minX = minBB.x(), minY = minBB.y(), minZ = minBB.z();
        point3f maxBB = bb.max;
        maxX = maxBB.x(), maxY = maxBB.y(), maxZ = maxBB.z();

        // increment the iterator
        // (we handled the first edge group seperately)
        ++it;

        while (it != edge_groups.end()) {
            bb = (*it)->GetBoundingBox();
            minBB = bb.min;
            maxBB = bb.max;;

            if ( minBB.x() < minX ) minX = minBB.x();
            if ( minBB.y() < minY ) minY = minBB.y();
            if ( minBB.z() < minZ ) minZ = minBB.z();
            if ( maxBB.x() > maxX ) maxX = maxBB.x();
            if ( maxBB.y() > maxY ) maxY = maxBB.y();
            if ( maxBB.z() > maxZ ) maxZ = maxBB.z();

            ++it;
        }
    }

    m_boundingbox = BBox3f(point3f(minX, minY, minZ), point3f(maxX, maxY, maxZ));
}
Exemple #2
0
c_point_light::c_point_light(const c_transform& l2w, const c_spectrum& intensity, uint32_t num_samples)
	: super(l2w, num_samples)
	, m_intensity(intensity)
{
	// Transform into the world space
	m_light_pos = l2w.transform_pt(point3f(0.0f, 0.0f, 0.0f));
}
Exemple #3
0
void view::renderCoordinateSystem()
	{
		glDisable(GL_LIGHTING);

		// render coodinate system arrows
		glClear(GL_DEPTH_BUFFER_BIT); // everything after here is drawn on top

		glLoadIdentity();
		glTranslatef(-6.2f,-6.0f,-16.0f);
		glRotatef(cam_polar * 180 / PI, 1.0f, 0.0f, 0.0f);
		glRotatef(cam_azimut * 180 / PI, 0.0f, 1.0f, 0.0f);

		point3f pos = point3f(0.0f, 0.0f, 0.0f);

		glColor3f(1.0f, 0.0f, 0.0f); // X axis
		glLineWidth(1.0f);
		render_arrow(pos, point3f(1.0f,0.0f,0.0f), 0.45f, 0.3f);
		glBegin(GL_LINES);
			glVertex3f(1.1f,0.1f,0.0f);
			glVertex3f(1.2f,-0.1f,0.0f);
			glVertex3f(1.2f,0.1f,0.0f);
			glVertex3f(1.1f,-0.1f,0.0f);
		glEnd();

		glColor3f(0.0f, 1.0f, 0.0f); // Y axis
		render_arrow(pos, point3f(0.0f,1.0f,0.0f), 0.4f, 0.3f);
		glLineWidth(1.0f);
		glBegin(GL_LINES);
			glVertex3f(-0.1f, 1.25f, 0.0f);
			glVertex3f( 0.0f, 1.15f, 0.0f);
			glVertex3f( 0.1f, 1.25f, 0.0f);
			glVertex3f( 0.0f, 1.15f, 0.0f);
			glVertex3f( 0.0f, 1.15f, 0.0f);
			glVertex3f( 0.0f, 1.0f,  0.0f);
		glEnd();

		glColor3f(0.0f, 0.0f, 1.0f); // Z axis
		render_arrow(pos, point3f(0.0f,0.0f,1.0f), 0.4f, 0.3f);
		glLineWidth(1.0f);
		glBegin(GL_LINE_STRIP);
			glVertex3f( 0.0f, 0.1f, 1.1f);
			glVertex3f( 0.0f, 0.1f, 1.2f);
			glVertex3f( 0.0f,-0.1f, 1.1f);
			glVertex3f( 0.0f,-0.1f, 1.2f);
		glEnd();
	}
Exemple #4
0
bool CXueWeiLoader::Load(CRectNode* Rects, CLineNode* Lines)
{
	xuewei = new XUEWEI[400];
	jingluo = new JINGLUO[20];

	FILE *fp;	

	MString ms;
#if 1
	fp = fopen(ms.str_join(g_Engine->MediaPath,XUEWEI_FILE_NAME),"r");

	for (int n=0;n<XUEWEI_NUM;n++)
	{	
		fscanf(fp,"%f %f %f %f %f %f %f %f %d %s %s %d %s %s %s %s"
			,&xuewei[n].world_x,&xuewei[n].world_y,&xuewei[n].world_z
			,&xuewei[n].mx,&xuewei[n].my,&xuewei[n].dx
			,&xuewei[n].jiaodu_x,&xuewei[n].jiaodu_y,&xuewei[n].xuewei_id
			,&xuewei[n].xuewei_ename,&xuewei[n].xuewei_cname,&xuewei[n].jingluo_id
			,&xuewei[n].jingluo_cname,&xuewei[n].shiyi,&xuewei[n].gongneng,&xuewei[n].weizhi);	
		
		//special process for 13 14
		if(xuewei[n].xuewei_id >= 310)
		{
			xuewei[n].world_x/=3.0;xuewei[n].world_y/=3.0;xuewei[n].world_z/=3.0;
		}

		SetJingluo(xuewei[n]);
		point4f color = GetJingluoColor(xuewei[n].jingluo_id);

		Rects->addTransformedElement(point3f(xuewei[n].world_x,xuewei[n].world_y,xuewei[n].world_z),
			point3f(xuewei[n].jiaodu_x,xuewei[n].jiaodu_y/*+180*/,0),point3f(0.02,0.02,0.02),color,xuewei[n].jingluo_id);

		if(Lines && n>0 && xuewei[n].jingluo_id == xuewei[n-1].jingluo_id)
		{
			Lines->AddElement(0,point3f(xuewei[n-1].world_x,xuewei[n-1].world_y,xuewei[n-1].world_z),point3f(xuewei[n].world_x,xuewei[n].world_y,xuewei[n].world_z),0,color);
		}

		//Rects->AddElement(0,point3f(xuewei[n].world_x,xuewei[n].world_y,xuewei[n].world_z),
		//	point3f(0,0,0),point3f(0.2,0.2,0.2),0);
	}
	fclose(fp);
#else
	fp = _wfopen(L"./xwsj.lj",L"r,ccs=UTF-8");
	for (int n=0;n<XUEWEI_NUM;n++)
	{	
		fwscanf(fp,L"%f %f %f %f %f %f %f %f %d %s %s %d %s %s %s %s"
			,&xuewei[n].world_x,&xuewei[n].world_y,&xuewei[n].world_z
			,&xuewei[n].mx,&xuewei[n].my,&xuewei[n].dx
			,&xuewei[n].jiaodu_x,&xuewei[n].jiaodu_y,&xuewei[n].xuewei_id
			,&xuewei[n].xuewei_ename,&xuewei[n].xuewei_cname,&xuewei[n].jingluo_id
			,&xuewei[n].jingluo_cname,&xuewei[n].shiyi,&xuewei[n].gongneng,&xuewei[n].weizhi);	
		//Rects->AddElement(0,point3f(xuewei[n].world_x,xuewei[n].world_y,xuewei[n].world_z),0);
		SetJingluo(xuewei[n]);
		point4f color = GetJingluoColor(xuewei[n].jingluo_id);

		Rects->addTransformedElement(point3f(xuewei[n].world_x,xuewei[n].world_y,xuewei[n].world_z),
			point3f(xuewei[n].jiaodu_x,xuewei[n].jiaodu_y/*+180*/,0),point3f(0.02,0.02,0.02),color,0);

		//Rects->AddElement(0,point3f(xuewei[n].world_x,xuewei[n].world_y,xuewei[n].world_z),
		//	point3f(0,0,0),point3f(0.2,0.2,0.2),0);
	}
	fclose(fp);

#endif
	return true;
}