当前位置: 首页>>代码示例>>C++>>正文


C++ Geometry::GetVertices方法代码示例

本文整理汇总了C++中Geometry::GetVertices方法的典型用法代码示例。如果您正苦于以下问题:C++ Geometry::GetVertices方法的具体用法?C++ Geometry::GetVertices怎么用?C++ Geometry::GetVertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Geometry的用法示例。


在下文中一共展示了Geometry::GetVertices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GenerateElementData

// Called on a decorator to generate any required per-element data for a newly decorated element.
DecoratorDataHandle DecoratorTiledImage::GenerateElementData(Element* element)
{
	// Calculate the tile's dimensions for this element.
	tile.CalculateDimensions(element, *GetTexture(tile.texture_index));

	Geometry* data = new Geometry(element);
	data->SetTexture(GetTexture());

	// Generate the geometry for the tile.
	tile.GenerateGeometry(data->GetVertices(), data->GetIndices(), element, Vector2f(0, 0), element->GetBox().GetSize(Box::PADDING), tile.GetDimensions(element));

	return reinterpret_cast<DecoratorDataHandle>(data);
}
开发者ID:1vanK,项目名称:libRocket-Urho3D,代码行数:14,代码来源:DecoratorTiledImage.cpp

示例2: GenerateElementData

// Called on a decorator to generate any required per-element data for a newly decorated element.
DecoratorDataHandle DecoratorTiledImage::GenerateElementData(Element* element)
{
	// Calculate the tile's dimensions for this element.
	tile.CalculateDimensions(element, *GetTexture(tile.texture_index));

	Geometry* data = new Geometry(element);
	data->SetTexture(GetTexture());

	Vector2f dest = element->GetBox().GetSize(Box::PADDING);
	Vector2f source = tile.GetDimensions(element);

	// Generate the geometry for the tile.
	switch(tile.scaling_mode) {
	case IGNORE /* default */: tile.GenerateGeometry(data->GetVertices(), data->GetIndices(), element, Vector2f(0, 0), dest, source, color_multiplier); break;
	case FILL:
	case FIT: {
	  Vector2f offset(0, 0); float f; 
	  switch(tile.scaling_mode) {
	  case FILL: {
	    RenderInterface* render_interface = element->GetRenderInterface();
	    Vector2i texture_dimensions = GetTexture(tile.texture_index)->GetDimensions(render_interface);
	    f = max(dest.y / source.y, dest.x / source.x); 
	  }; break;
	  case FIT: 
	    f = min(dest.y / source.y, dest.x / source.x); 
	    source *= f;
	    offset.x = (dest.x - source.x)/2;
	    offset.y = (dest.y - source.y)/2;
	    dest = source;
	    break;
	  }
	  tile.GenerateGeometry(data->GetVertices(), data->GetIndices(), element, offset, dest, source, color_multiplier); 
	}; break;
	case CENTER: 
	  Vector2f offset(0, 0);
	  Vector2i texture_dimension;
	  if (!tile.texcoords_absolute[0][0] || !tile.texcoords_absolute[1][0] || !tile.texcoords_absolute[0][1] || !tile.texcoords_absolute[1][1]) {
	    RenderInterface* render_interface = element->GetRenderInterface();
	    texture_dimension = GetTexture(tile.texture_index)->GetDimensions(render_interface);
	  }
	  if (source.x > dest.x) { // crop width of image
	    float diff_begin = (source.x - dest.x)/2, diff_end = diff_begin;
	    if (!tile.texcoords_absolute[0][0] || !tile.texcoords_absolute[1][0]) {
	      if (!tile.texcoords_absolute[0][0]) diff_begin /= texture_dimension.x;
	      if (!tile.texcoords_absolute[1][0]) diff_end /= texture_dimension.x;
	    }
	    tile.texcoords[0].x += diff_begin; // -s-begin
	    tile.texcoords[1].x -= diff_end; // -s-end
	    source.x = dest.x;
	  } else {                 // center image
	    offset.x = (dest.x - source.x)/2;
	    dest.x = source.x;
	  }
	  if (source.y > dest.y) { // crop height of image
	    float diff_begin = (source.y - dest.y)/2, diff_end = diff_begin;
	    if (!tile.texcoords_absolute[0][1] || !tile.texcoords_absolute[1][1]) {
	      if (!tile.texcoords_absolute[0][1]) diff_begin /= texture_dimension.y;
	      if (!tile.texcoords_absolute[1][1]) diff_end /= texture_dimension.y;
	    }
	    tile.texcoords[0].y += diff_begin; // -s-begin
	    tile.texcoords[1].y -= diff_end; // -s-end
	    source.y = dest.y;
	  } else {                 // center image
	    offset.y = (dest.y - source.y)/2;
	    dest.y = source.y;
	  }
	  tile.GenerateGeometry(data->GetVertices(), data->GetIndices(), element, offset, dest, source, color_multiplier); 
	  break;
	}

	return reinterpret_cast<DecoratorDataHandle>(data);
}
开发者ID:ppiecuch,项目名称:libRocket,代码行数:73,代码来源:DecoratorTiledImage.cpp


注:本文中的Geometry::GetVertices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。