コード例 #1
0
ファイル: layout.c プロジェクト: Bgods/r-source
void allocateRemainingHeight(SEXP layout, int *relativeHeights,
			     double remainingHeightCM, 
			     LViewportContext parentContext,
			     const pGEcontext parentgc,
			     pGEDevDesc dd,
			     double *npcHeights)
{
    int i;
    SEXP heights = layoutHeights(layout);
    double sumHeight;
    sumHeight = totalUnrespectedHeight(layout, relativeHeights,
				       parentContext, parentgc, dd);
    if (sumHeight > 0) {
        for (i=0; i<layoutNRow(layout); i++) 
            if (relativeHeights[i])
                if (!rowRespected(i, layout))
                    npcHeights[i] = remainingHeightCM*
                        transformHeight(heights, i, parentContext, parentgc,
				    /* 
				     * NOTE: 0, 0, here is ok
				     * because we are only 
				     * obtaining "null" units
				     */
                                        0, 0, 1, 0, dd)/
                        sumHeight;
    } else {
        /* 
         * If ALL relative heights are zero then they all get 
         * allocated zero height
         */
        setRemainingHeightZero(layout, relativeHeights, npcHeights);
    }
}
コード例 #2
0
void TerrainRenderer::drawNode(GLdouble offsetX, GLdouble offsetY, GLdouble size, QuadTreeNode *node){
    size = size/2;
    for(int i=0; i<2; i++){
        for(int j=0; j<2; j++){
            QuadTreeNode *child;
            if(i==0 && j==0) child = node->tlNode;
            if(i==1 && j==0) child = node->trNode;
            if(i==0 && j==1) child = node->blNode;
            if(i==1 && j==1) child = node->brNode;
            GLfloat tile_x = size*i+offsetX;
            GLfloat tile_y = size*i+offsetY;
            
            GLfloat d = getTileDistance(tile_x, tile_y, transformHeight(child->min), transformHeight(child->max), size);

            if(tile_x == 0.0 && tile_y == 0.0 && size == 0.5)
                printf("Distance from %i, %i: %f\n", i, j, d);
            if(d < size*2 && !child->isLeaf()){
                drawNode(size*i+offsetX, size*j+offsetY, size, child);
            }else{
                drawHeightmap(size*i+offsetX, size*j+offsetY, size, child);
            }
        }
    }
}
コード例 #3
0
void TerrainRenderer::drawHeightmap(GLdouble offsetX, GLdouble offsetY, GLdouble size, QuadTreeNode *node){

    glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );

    glPushMatrix();
    glTranslatef(offsetX, 0.0, offsetY);

    glBegin(GL_TRIANGLES);

    GLdouble vertexSpacing;
    vertexSpacing = size / (HEIGHTMAP_SIZE-1);

    for(int i=0; i<(HEIGHTMAP_SIZE-1); i++){
        for(int j=0; j<(HEIGHTMAP_SIZE-1); j++){
            GLdouble x = (i)*vertexSpacing;
            GLdouble z = (j)*vertexSpacing;

            GLdouble h1 = transformHeight(node->heightmap[i][j]);
            GLdouble h2 = transformHeight(node->heightmap[i+1][j]);
            GLdouble h3 = transformHeight(node->heightmap[i][j+1]);
            GLdouble h4 = transformHeight(node->heightmap[i+1][j+1]);
            //triangle 1
            glVertex3d(x, h1, z);
            glVertex3d(x+vertexSpacing, h2, z);
            glVertex3d(x+vertexSpacing, h4, z+vertexSpacing);
            //triangle 2
            glVertex3d(x, h1, z);
            glVertex3d(x, h3, z+vertexSpacing);
            glVertex3d(x+vertexSpacing, h4, z+vertexSpacing);
        }
    }

    glEnd();

    glPopMatrix();
}
コード例 #4
0
ファイル: layout.c プロジェクト: Bgods/r-source
void allocateKnownHeights(SEXP layout, 
			  int *relativeHeights,
			  double parentWidthCM, double parentHeightCM,
			  LViewportContext parentContext,
			  const pGEcontext parentgc,
			  pGEDevDesc dd,
			  double *npcHeights, double *heightLeftCM) 
{
    int i;
    SEXP heights = layoutHeights(layout);
    for (i=0; i<layoutNRow(layout); i++) 
	if (!relativeHeights[i]) {
	    npcHeights[i] = transformHeight(heights, i, parentContext,
					    parentgc,
					    parentWidthCM, parentHeightCM, 
					    0, 0, dd)*2.54;
	    *heightLeftCM -= npcHeights[i];
	}
}
コード例 #5
0
ファイル: layout.c プロジェクト: Bgods/r-source
double totalHeight(SEXP layout, int *relativeHeights,
		   LViewportContext parentContext,
		   const pGEcontext parentgc,
		   pGEDevDesc dd)
{
    int i;
    SEXP heights = layoutHeights(layout);
    double totalHeight = 0;
    for (i=0; i<layoutNRow(layout); i++) 
	if (relativeHeights[i])
	    totalHeight += transformHeight(heights, i, parentContext, 
					   parentgc,
					   /* 
					    * NOTE: 0, 0, here is ok
					    * because we are only 
					    * obtaining "null" units
					    */
					   0, 0, 1, 0, dd);
    return totalHeight;
}