GeometryTexturePatch16::GeometryTexturePatch16( int x , int y , int sizeC , int scaleC , osg::ref_ptr<osg::Image> image , double dAdd , double dScale )
{
	//сдвиг и масштабирование
	m_dAdd = dAdd;
	m_dScale = dScale;

	//создать объект для хранения в нем геометрии
	m_patchGeom = new osg::Geometry;

	//создать массив вершин
	m_patchGeom->setVertexArray( CreateVertexArray( x , y , sizeC , scaleC ).get() );

	//создать массив текстурных координат
	m_patchGeom->setTexCoordArray( 0, CreateTexCoordArray( x , y , sizeC , scaleC , 
		image->data() ).get() );

	// Create an array for the single normal.
	osg::ref_ptr< osg::Vec3Array > n = new osg::Vec3Array;
	n->push_back( osg::Vec3( 0, -1, 0 ) );
	m_patchGeom->setNormalArray( n.get() );
	m_patchGeom->setNormalBinding( osg::Geometry::BIND_OVERALL );

	std::vector< unsigned int > m_vIndex;

	//заполнить вектор индексами
	FillIndexVector( m_vIndex , sizeC );

	m_patchGeom->addPrimitiveSet( new osg::DrawElementsUInt(
		osg::PrimitiveSet::TRIANGLE_STRIP, m_vIndex.size() , &m_vIndex[ 0 ] ) );
}
Example #2
0
		bool Mesh::Initialize(void * buffer)
		{
			bool wereThereErrors = false;
			if (!CreateVertexArray())
			{
				wereThereErrors = true;
			}
			free(buffer);
			if (wereThereErrors)
				ShutDown();
			return !wereThereErrors;
		}
GLuint CreateGroundPlaneData(){
	int width = 10;
	int length = 10;
	int numVertices = width * length;
	CustomVertexNormBiTangentUV* groundPlaneData = new CustomVertexNormBiTangentUV[numVertices];

	int halfWidth = width / 2;
	int halfHeight = length / 2;

	int index = 0;
	//create a buffer of vertex info using the height map
	for (int x = 0; x < width; x++){
		for (int z = 0; z < length; z++){
			index = x * length + z;
			groundPlaneData[index].vertexPoint.x = (x - halfWidth) * 25.0f;
			groundPlaneData[index].vertexPoint.y = -5.0f;
			groundPlaneData[index].vertexPoint.z = (z - halfHeight) * 25.0f;
			groundPlaneData[index].normal	 = vec3(0.0f, 1.0f, 0.0f);
			groundPlaneData[index].biTangent = vec3(1.0f, 0.0f, 0.0f);
			groundPlaneData[index].tangent   = vec3(0.0f, 0.0f, -1.0f);
			groundPlaneData[index].uv.x = x * 0.5f;
			groundPlaneData[index].uv.y = z * 0.5f;
		}
	}

	int numIndices = (width - 1) * (length - 1) * 6;
	unsigned int *indices = new unsigned int[numIndices];

	index = 0;

	for (int x = 0; x < width - 1; x++){
		for (int z = 0; z < length - 1; z++){
			indices[index++] = (width * x) + z;
			indices[index++] = (width * x) + z + 1;
			indices[index++] = (width * (x + 1)) + z;

			indices[index++] = (width * (x + 1)) + z;
			indices[index++] = (width * x) + z + 1;
			indices[index++] = (width * (x + 1)) + z + 1;
		}
	}

	GLuint data = CreateVertexArray(groundPlaneData, numVertices, sizeof(CustomVertexNormBiTangentUV), 5, indices, numIndices / 3);
	
	delete[] indices;
	delete[] groundPlaneData;
	return data;
}
void DynamicGroupLevel2048Node::AddGeometry( int i )
{
	//добавить геометрию в i'ый узел

	//создать объект для хранения в нем геометрии
	osg::ref_ptr< osg::Geometry > geom = new osg::Geometry;

	//создать массив вершин
	geom->setVertexArray( CreateVertexArray( 0 , 0 , 68 , 2048 ).get() );

	std::vector< unsigned short > m_vIndex;

	//заполнить вектор индексами
	FillIndexVector( m_vIndex , 68 );

	geom->addPrimitiveSet( new osg::DrawElementsUShort(
		osg::PrimitiveSet::TRIANGLE_STRIP, m_vIndex.size() / GEOM_DIV , &m_vIndex[ 0 ] ) );

	osg::BoundingBox bbox( 0, 0, 0, 512 * 512 , 512 * 512 , 64 );
	geom->setInitialBound( bbox );

	//добавить рисуемую геометрию
	m_vData[ i ].m_Geode->addDrawable( geom.get() );
}
Example #5
0
VertexArray::VertexArray(const VertexDeclarationPtr* declarations, size_t declCount, boost::shared_ptr<IndexBuffer> indexBuffer)
	: declarations(declarations, declarations + declCount)
{
	vao = CreateVertexArray(this->declarations, NULL);
}
Example #6
0
VertexArray::VertexArray(const VertexDeclarationPtr* declarations, size_t declCount)
	: declarations(declarations, declarations + declCount)
{
	vao = CreateVertexArray(this->declarations, NULL);
}
Example #7
0
VertexArray::VertexArray(const DeclarationList& declarations, boost::shared_ptr<IndexBuffer> indexBuffer)
	: declarations(declarations), indexBuffer(indexBuffer), vao(CreateVertexArray(declarations, indexBuffer))
{
}
Example #8
0
VertexArray::VertexArray(const DeclarationList& declarations)
	: declarations(declarations), vao(CreateVertexArray(declarations, NULL))
{
}
Example #9
0
void SpriteBatch::Init(Shader shader)
{
	this->shader = shader;
	CreateVertexArray();
}