Ejemplo n.º 1
0
bool GeoDataLineString::operator==( const GeoDataLineString &other ) const
{
    if ( !GeoDataGeometry::equals(other) ||
          size() != other.size() ||
          tessellate() != other.tessellate() ) {
        return false;
    }

    const GeoDataLineStringPrivate* d = p();
    const GeoDataLineStringPrivate* other_d = other.p();

    QVector<GeoDataCoordinates>::const_iterator itCoords = d->m_vector.constBegin();
    QVector<GeoDataCoordinates>::const_iterator otherItCoords = other_d->m_vector.constBegin();
    QVector<GeoDataCoordinates>::const_iterator itEnd = d->m_vector.constEnd();
    QVector<GeoDataCoordinates>::const_iterator otherItEnd = other_d->m_vector.constEnd();

    for ( ; itCoords != itEnd && otherItCoords != otherItEnd; ++itCoords, ++otherItCoords ) {
        if ( *itCoords != *otherItCoords ) {
            return false;
        }
    }

    Q_ASSERT ( itCoords == itEnd && otherItCoords == otherItEnd );
    return true;
}
Ejemplo n.º 2
0
bool GeoDataPolygon::operator==( const GeoDataPolygon &other ) const
{
    const GeoDataPolygonPrivate *d = p();
    const GeoDataPolygonPrivate *other_d = other.p();

    if ( !GeoDataGeometry::equals(other) ||
         tessellate() != other.tessellate() ||
         isClosed() != other.isClosed() ||
         d->inner.size() != other_d->inner.size() ||
         d->outer != other_d->outer ) {
        return false;
    }

    QVector<GeoDataLinearRing>::const_iterator itBound = d->inner.constBegin();
    QVector<GeoDataLinearRing>::const_iterator itEnd = d->inner.constEnd();
    QVector<GeoDataLinearRing>::const_iterator otherItBound = other_d->inner.constBegin();
    QVector<GeoDataLinearRing>::const_iterator otherItEnd= other_d->inner.constEnd();

    for ( ; itBound != itEnd && otherItBound != otherItEnd; ++itBound, ++otherItBound ) {
        if ( *itBound != *otherItBound) {
            return false;
        }
    }

    Q_ASSERT ( itBound == itEnd && otherItBound == otherItEnd );
    return true;
}
Ejemplo n.º 3
0
void
Mipmapping::render()
{
	_build_trianlges = 0;

	tessellate();
}
Ejemplo n.º 4
0
void SolidOfRotation::draw(void)
{
    //
    // ASSIGNMENT (PA10)
    //
    // Modify your previous (PA04) solution as follows:
    //
    // - If tessellation is required, after it's done:
    //
    //   * Call `tessellation->setTextureCoordinates(1.0, 1.0)` to
    //     define the texture coordinates.
    //
    //   * Call `tessellation->updateBuffers()` to update the
    //     tessellation's buffers, which will send the texture
    //     coordinates to the GPU.
    //

    if (!tessellationMesh)
    {
        tessellate();

        // 'tessellation' or 'tessellationMesh'?
        tessellationMesh->setTextureCoordinates(1.0, 1.0);
        tessellationMesh->updateBuffers();
    }

    tessellationMesh->render();

}
Ejemplo n.º 5
0
void Surface::draw(void)
{
    if (!tessellationMesh) {
        tessellate();
    }

    tessellationMesh->render();
}
Ejemplo n.º 6
0
//----------------------------------------------------------
vector<ofPolyline> & ofPath::getOutline() {
	if(windingMode!=OF_POLY_WINDING_ODD){
		tessellate();
		return tessellatedContour;
	}else{
		generatePolylinesFromCommands();
		return polylines;
	}
}
Ejemplo n.º 7
0
void ScreenAlignedText::changed(BitVector whichField, UInt32 origin)
{
	//cout << "******** ScreenAlignedText::changed called ********** " << endl;

  if( whichField & PositionFieldMask ||
      whichField & FontFieldMask ||
      whichField & TextFieldMask ||
      whichField & VerticalLineDistanceFieldMask ||
      whichField & AlignmentFieldMask ) 
  {
	  tessellate();
  }

    Inherited::changed(whichField, origin);
}
Ejemplo n.º 8
0
void
Subdivider::tessellation( Bin& bin, Patchlist &patchlist )
{
    // tessellate unsampled trim curves
    tessellate( bin, patchlist.pspec[1].sidestep[1], patchlist.pspec[0].sidestep[1],
	 patchlist.pspec[1].sidestep[0], patchlist.pspec[0].sidestep[0] );

    // set interior sampling rates
    slicer.setstriptessellation( patchlist.pspec[0].stepsize, patchlist.pspec[1].stepsize );

    // set boundary sampling rates
    stepsizes[0] = patchlist.pspec[1].stepsize;
    stepsizes[1] = patchlist.pspec[0].stepsize;
    stepsizes[2] = patchlist.pspec[1].stepsize;
    stepsizes[3] = patchlist.pspec[0].stepsize;
}
Ejemplo n.º 9
0
void SolidOfRotation::draw(void)
{
    //
    // ASSIGNMENT (PA04)
    //
    // Modify your previous (PA03) solution to not pass
    // `viewTransform` to the render() method, since vertex transforms
    // are now handled in the GPU.
    //
    // 4 lines in instructor solution (YMMV)
    //

	if (!tessellationMesh)
		tessellate();

	tessellationMesh->render();

}
Ejemplo n.º 10
0
//----------------------------------------------------------
void ofPath::draw(){
	if(ofGetCurrentRenderer()->rendersPathPrimitives()){
		ofGetCurrentRenderer()->draw(*this);
	}else{
		tessellate();


		ofColor prevColor;
		if(bUseShapeColor){
			prevColor = ofGetStyle().color;
		}

		if(bFill){
			if(bUseShapeColor){
				ofSetColor(fillColor);
			}

			ofGetCurrentRenderer()->draw(cachedTessellation,bUseShapeColor,false,false);

		}

		if(hasOutline()){
			float lineWidth = ofGetStyle().lineWidth;
			if(bUseShapeColor){
				ofSetColor(strokeColor);
			}
			ofSetLineWidth( strokeWidth );
			vector<ofPolyline> & polys = getOutline();
			for(int i=0;i<(int)polys.size();i++){
				ofGetCurrentRenderer()->draw(polys[i]);
			}
			ofSetLineWidth(lineWidth);
		}

		if(bUseShapeColor){
			ofSetColor(prevColor);
		}
	}
}
Ejemplo n.º 11
0
//----------------------------------------------------------
ofMesh & ofPath::getTessellation(){
	tessellate();
	return cachedTessellation;
}
Ejemplo n.º 12
0
INT WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR, INT )
{
    srand( static_cast<unsigned>( time(NULL) ) );
    
    SkinningVertex * cylinder_vertices = NULL;
    Index * cylinder_indices = NULL;
    Vertex * tesselated_vertices = NULL;
    Index * tesselated_indices = NULL;
    try
    {
        Application app;

        VertexShader skinning_shader(app.get_device(), SKINNING_VERTEX_DECL_ARRAY, SKINNING_SHADER_FILENAME);
        VertexShader morphing_shader(app.get_device(), VERTEX_DECL_ARRAY, MORPHING_SHADER_FILENAME);
        
        // -------------------------- C y l i n d e r -----------------------

        cylinder_vertices = new SkinningVertex[CYLINDER_VERTICES_COUNT];
        cylinder_indices = new Index[CYLINDER_INDICES_COUNT];

        float height = 2.0f;
        cylinder( 0.7f, height,
                  colors, colors_count,
                  cylinder_vertices, cylinder_indices );

        SkinningModel cylinder1(app.get_device(),
                                D3DPT_TRIANGLESTRIP,
                                skinning_shader,
                                cylinder_vertices,
                                CYLINDER_VERTICES_COUNT,
                                cylinder_indices,
                                CYLINDER_INDICES_COUNT,
                                CYLINDER_INDICES_COUNT - 2,
                                D3DXVECTOR3(0.5f, 0.5f, -height/2),
                                D3DXVECTOR3(0,0,0),
                                D3DXVECTOR3(0,0,-1));

        height = 2.3f;
        cylinder( 0.3f, height,
                  &SECOND_CYLINDER_COLOR, 1,
                  cylinder_vertices, cylinder_indices );

        SkinningModel cylinder2(app.get_device(),
                                D3DPT_TRIANGLESTRIP,
                                skinning_shader,
                                cylinder_vertices,
                                CYLINDER_VERTICES_COUNT,
                                cylinder_indices,
                                CYLINDER_INDICES_COUNT,
                                CYLINDER_INDICES_COUNT - 2,
                                D3DXVECTOR3(-1.0f, 0.5f, height/2),
                                D3DXVECTOR3(D3DX_PI,0,-D3DX_PI/4),
                                D3DXVECTOR3(0,0,1));

        
        // -------------------------- P y r a m i d -----------------------
        const Index PLANES_PER_PYRAMID = 8;
        const D3DXVECTOR3 normal_up(0,0,1);
        const Vertex pyramid_vertices[]=
        {
            Vertex(D3DXVECTOR3(  0.5f, -0.5f,  0.00f ),normal_up),
            Vertex(D3DXVECTOR3( -0.5f, -0.5f,  0.00f ),normal_up),
            Vertex(D3DXVECTOR3( -0.5f,  0.5f,  0.00f ),normal_up),
            Vertex(D3DXVECTOR3(  0.5f,  0.5f,  0.00f ),normal_up),
            Vertex(D3DXVECTOR3(  0.0f,  0.0f,  0.7071f ),normal_up),
            Vertex(D3DXVECTOR3(  0.0f,  0.0f, -0.7071f ),normal_up),
        };
        const Index pyramid_indices[PLANES_PER_PYRAMID*VERTICES_PER_TRIANGLE] =
        {
            0, 4, 3,
            3, 4, 2,
            2, 4, 1,
            1, 4, 0,

            0, 3, 5,
            3, 2, 5,
            2, 1, 5,
            1, 0, 5,
        };

        const Index ALL_TESSELATED_VERTICES_COUNT = PLANES_PER_PYRAMID*TESSELATED_VERTICES_COUNT; // per 8 tessellated triangles
        const DWORD ALL_TESSELATED_INDICES_COUNT = PLANES_PER_PYRAMID*TESSELATED_INDICES_COUNT; // per 8 tessellated triangles

        tesselated_vertices = new Vertex[ALL_TESSELATED_VERTICES_COUNT];
        tesselated_indices = new Index[ALL_TESSELATED_INDICES_COUNT];

        for( DWORD i = 0; i < PLANES_PER_PYRAMID; ++i )
        {
            tessellate( pyramid_vertices, pyramid_indices, i*VERTICES_PER_TRIANGLE,
                        &tesselated_vertices[i*TESSELATED_VERTICES_COUNT], i*TESSELATED_VERTICES_COUNT,
                        &tesselated_indices[i*TESSELATED_INDICES_COUNT], SPHERE_COLOR );
        }
        
        MorphingModel pyramid( app.get_device(),
                               D3DPT_TRIANGLELIST,
                               morphing_shader,
                               tesselated_vertices,
                               ALL_TESSELATED_VERTICES_COUNT,
                               tesselated_indices,
                               ALL_TESSELATED_INDICES_COUNT,
                               ALL_TESSELATED_INDICES_COUNT/VERTICES_PER_TRIANGLE,
                               D3DXVECTOR3(0, -1.3f, -0.2f),
                               D3DXVECTOR3(0,0,0),
                               0.7071f);

        app.add_model(cylinder1);
        app.add_model(cylinder2);
        app.add_model(pyramid);
        app.run();
        delete_array(&tesselated_indices);
        delete_array(&tesselated_vertices);
        delete_array(&cylinder_indices);
        delete_array(&cylinder_vertices);
    }
    catch(RuntimeError &e)
    {
        delete_array(&tesselated_indices);
        delete_array(&tesselated_vertices);
        delete_array(&cylinder_indices);
        delete_array(&cylinder_vertices);
        const TCHAR *MESSAGE_BOX_TITLE = _T("Lighting error!");
        MessageBox(NULL, e.message(), MESSAGE_BOX_TITLE, MB_OK | MB_ICONERROR);
        return -1;
    }
    return 0;
}
Ejemplo n.º 13
0
RenderableConcave::RenderableConcave(const Polygon3D& polygon, Texture* texture) : Renderable(GL_TRIANGLES) {
	this->texture = texture;

	tessellate(polygon);
}
Ejemplo n.º 14
0
RenderableConcave::RenderableConcave(const Polygon3D& polygon, const QColor& color) : Renderable(GL_TRIANGLES) {
	tessellate(polygon, color);
}
Ejemplo n.º 15
0
Archivo: ui.c Proyecto: XAMEUS/CPROJ6
int Display_Application(int argc, char *argv[])
{

	SDL_Window *window;	// Declare a pointer, main window
	int width = 640;
	int height = 480;
	GLdouble dx = 0;
	GLdouble dy = 0;
	GLdouble zoom = 1.0;

	initNodesBounds(argv[1]);

	min_x = minx;
	max_x = maxx;
	min_y = miny;
	max_y = maxy;

	// Initialize SDL2
	if (SDL_Init(SDL_INIT_VIDEO) != 0) {
		fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
		exit(EXIT_FAILURE);
	}
	// Create an application window with the following settings:
	window = SDL_CreateWindow("OSM Renderer",	// window title
				  SDL_WINDOWPOS_UNDEFINED,	// initial x position
				  SDL_WINDOWPOS_UNDEFINED,	// initial y position
				  width,	// width, in pixels
				  height,	// height, in pixels
				  SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE	// flags
	    );

	// Check that the window was successfully created
	if (window == NULL) {
		// In the case that the window could not be made...
		fprintf(stderr, "SDL_CreateWindow failed: %s\n",
			SDL_GetError());
		exit(EXIT_FAILURE);
	}

	fprintf(stdout, "Press the 'F' key to switch fullscreen.\n");
	fprintf(stdout, "Press the 'R' key to reset the view.\n");
	fprintf(stdout, "Press the [x] button to close the window.\n");

	SDL_Renderer *displayRenderer = NULL;
	SDL_RendererInfo displayRendererInfo;
	displayRenderer =
	    SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
	SDL_GetRendererInfo(displayRenderer, &displayRendererInfo);
	if ((displayRendererInfo.flags & SDL_RENDERER_ACCELERATED) == 0 ||
	    (displayRendererInfo.flags & SDL_RENDERER_TARGETTEXTURE) == 0) {
		fprintf(stderr,
			"We have no render surface and not accelerated.\n");
	}

	Display_InitGL();

	Display_SetViewport(width, height, dx, dy, zoom);

	int fullscreen = 0;
	int drag = 0;
	int xcursor = 0;
	int ycursor = 0;
	SDL_Event event;
	int quit = 0;
	time_t t = time(NULL);
	time_t ctime = time(NULL);
	int frames = 0;

	GList *l;

	for (l = g_hash_table_get_values(ways_hashtable); l != NULL;
	     l = l->next) {
		way *w = l->data;
		w->glist = tessellate(*w);
	}

	g_list_free(l);

	while (!quit) {
		Display_SetViewport(width, height, dx, dy, zoom);
		Display_Render(displayRenderer, width, height, dx, dy, zoom);
		while (SDL_PollEvent(&event))	// User's actions
		{
			switch (event.type) {
			case SDL_QUIT:	// Close button
				quit = 1;
				break;
			case SDL_KEYUP:	// Key release
				if (event.key.keysym.sym == SDLK_f)	// F key
				{
					if (fullscreen == 0) {
						fullscreen = 1;
						SDL_SetWindowFullscreen(window,
									SDL_WINDOW_FULLSCREEN);
					} else if (fullscreen == 1) {
						fullscreen = 0;
						SDL_SetWindowFullscreen(window,
									0);
					}
				}
				if (event.key.keysym.sym == SDLK_KP_PLUS) {
					if (zoom > 0.1) {
						dx = dx +
						    0.1 * pixelsize * (xcursor -
								       width /
								       2);
						dy = dy -
						    0.1 * pixelsize * (ycursor -
								       height /
								       2);
					}
					if (zoom > 0.1)
						zoom -= 0.1;
				}
				if (event.key.keysym.sym == SDLK_KP_MINUS) {
					dx = dx - 0.1 * pixelsize * (xcursor -
								     width / 2);
					dy = dy + 0.1 * pixelsize * (ycursor -
								     height /
								     2);
					zoom += 0.1;
				}
				if (event.key.keysym.sym == SDLK_r) {
					zoom = 1.0;
					dx = 0.0;
					dy = 0.0;
				}
				if (event.key.keysym.sym == SDLK_s) {
					if (showFrame)
						showFrame = 0;
					else
						showFrame = 1;
				}
				if (event.key.keysym.sym == SDLK_c) {
					screenshoot = 1;
				}
				if (event.key.keysym.sym == SDLK_p) {
					projection = !projection;
					if (projection) {
						min_x = minx;
						max_x = maxx;
						min_y = miny;
						max_y = maxy;
					} else {
						min_x = minlon;
						max_x = maxlon;
						min_y = minlat;
						max_y = maxlat;
					}
				}
				break;
			case SDL_WINDOWEVENT:
				switch (event.window.event) {
				case SDL_WINDOWEVENT_RESIZED:
					width = event.window.data1;
					height = event.window.data2;
					break;
				case SDL_WINDOWEVENT_SIZE_CHANGED:
					width = event.window.data1;
					height = event.window.data2;
					break;
				default:
					// printf("Window %d got unknown event %d\n", event.window.windowID, event.window.event);
					break;
				}
				break;
			case SDL_MOUSEBUTTONDOWN:
				if (event.button.button == SDL_BUTTON_LEFT)
					drag = 1;
				break;
			case SDL_MOUSEBUTTONUP:
				if (event.button.button == SDL_BUTTON_LEFT)
					drag = 0;
				break;
			case SDL_MOUSEMOTION:
				xcursor = event.motion.x;
				ycursor = event.motion.y;
				if (drag != 0) {
					dx -=
					    pixelsize * event.motion.xrel *
					    zoom;
					dy +=
					    pixelsize * event.motion.yrel *
					    zoom;
				}
				break;
			case SDL_MOUSEWHEEL:
				if (zoom > 0.01) {
					dx = dx +
					    0.02 * pixelsize * event.wheel.y *
					    (xcursor - width / 2);
					dy = dy -
					    0.02 * pixelsize * event.wheel.y *
					    (ycursor - height / 2);
				}
				if (event.wheel.y > 0 && zoom > 0.01)
					zoom -= 0.02;
				else if (event.wheel.y < 0)
					zoom += 0.02;
				break;
			default:
				//printf("unknown event");
				break;
			}
		}
		frames++;
		ctime = time(NULL);
		if (t != ctime) {
			t = ctime;
			//fprintf(stdout, "%d fps\n", frames);
			frames = 0;
		}
	}

	// Close and destroy the window
	SDL_DestroyWindow(window);

	// Clean up
	SDL_Quit();

	return EXIT_SUCCESS;
}