本文整理汇总了C++中Geometry::AddVertexBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ Geometry::AddVertexBuffer方法的具体用法?C++ Geometry::AddVertexBuffer怎么用?C++ Geometry::AddVertexBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geometry
的用法示例。
在下文中一共展示了Geometry::AddVertexBuffer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateGeometry
Geometry BubbleEmitter::CreateGeometry( unsigned int numOfPatch )
{
unsigned int numVertex = numOfPatch*4u;
std::vector<Vertex> vertexData;
vertexData.reserve( numVertex );
unsigned int numIndex = numOfPatch*6u;
Vector<unsigned int> indexData;
indexData.Reserve( numIndex );
for(unsigned int i = 0; i < numOfPatch; i++)
{
float curSize = RandomRange(mBubbleSizeRange.x, mBubbleSizeRange.y, mRandomSeed);
float index = static_cast<float>( i );
vertexData.push_back( Vertex( index, Vector2(0.f,0.f), Vector2(0.f,0.f) ) );
vertexData.push_back( Vertex( index, Vector2(0.f,curSize), Vector2(0.f,1.f) ) );
vertexData.push_back( Vertex( index, Vector2(curSize,curSize), Vector2(1.f,1.f) ) );
vertexData.push_back( Vertex( index, Vector2(curSize,0.f), Vector2(1.f,0.f) ) );
unsigned int idx = index * 4;
indexData.PushBack( idx );
indexData.PushBack( idx+1 );
indexData.PushBack( idx+2 );
indexData.PushBack( idx );
indexData.PushBack( idx+2 );
indexData.PushBack( idx+3 );
}
Property::Map vertexFormat;
vertexFormat["aIndex"] = Property::FLOAT;
vertexFormat["aPosition"] = Property::VECTOR2;
vertexFormat["aTexCoord"] = Property::VECTOR2;
PropertyBuffer vertices = PropertyBuffer::New( vertexFormat, numVertex );
vertices.SetData( &vertexData[0] );
Property::Map indexFormat;
indexFormat["indices"] = Property::INTEGER;
PropertyBuffer indices = PropertyBuffer::New( indexFormat, numIndex );
indices.SetData( &indexData[0] );
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( vertices );
geometry.SetIndexBuffer( indices );
return geometry;
}
示例2: CreateTexturedGeometry
/**
* @brief Creates a geometry object from vertices and indices.
* @param[in] vertices The object vertices
* @param[in] indices The object indices
* @return A geometry object
*/
Geometry CreateTexturedGeometry( Vector<TexturedVertex>& vertices, Vector<unsigned short>& indices )
{
// Vertices
Property::Map vertexFormat;
vertexFormat[POSITION] = Property::VECTOR3;
vertexFormat[NORMAL] = Property::VECTOR3;
vertexFormat[TEXTURE] = Property::VECTOR2;
PropertyBuffer surfaceVertices = PropertyBuffer::New( vertexFormat );
surfaceVertices.SetData( &vertices[0u], vertices.Size() );
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( surfaceVertices );
// Indices for triangle formulation
geometry.SetIndexBuffer( &indices[0u], indices.Size() );
return geometry;
}
示例3: AddVertexBuffer
/**
* Add a PropertyBuffer to be used as source of geometry vertices
*
* @method addVertexBuffer
* @for Geometry
* @param {Object} vertexBuffer PropertyBuffer to be used as source of geometry vertices
* @return {interger} Index of the newly added buffer, can be used with RemoveVertexBuffer
* to remove this buffer if no longer required
* @example
*```
* var vertexFormat ={ "aPosition" : dali.PROPERTY_VECTOR2 };
* var vertexData = [ 0, 1,
* -0.95, 0.31,
* -0.59, -0.81,
* 0.59, -0.81,
* 0.95, 0.31];
*
* var vertexDataArray = new Float32Array(vertexData.length);
* vertexDataArray.set(vertexData, 0);
* var vertices = new dali.PropertyBuffer(vertexFormat, 5);
* vertices.setData(vertexDataArray);
*
* var geometry = new dali.Geometry();
* geometry.addVertexBuffer( vertices );
*```
*/
void GeometryApi::AddVertexBuffer( const v8::FunctionCallbackInfo< v8::Value >& args )
{
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope handleScope( isolate );
Geometry geometry = GetGeometry( isolate, args );
bool found( false );
PropertyBuffer vertexBuffer = PropertyBufferApi::GetPropertyBufferFromParams( 0, found, isolate, args );
if( !found )
{
DALI_SCRIPT_EXCEPTION( isolate, "invalid property buffer parameter" );
}
else
{
args.GetReturnValue().Set( v8::Integer::New( isolate, geometry.AddVertexBuffer(vertexBuffer) ) );
}
}
示例4: CreateQuadGeometry
Geometry CreateQuadGeometry(void)
{
PropertyBuffer vertexData = CreatePropertyBuffer();
const float halfQuadSize = .5f;
struct TexturedQuadVertex { Vector2 position; Vector2 textureCoordinates; };
TexturedQuadVertex texturedQuadVertexData[4] = {
{ Vector2(-halfQuadSize, -halfQuadSize), Vector2(0.f, 0.f) },
{ Vector2( halfQuadSize, -halfQuadSize), Vector2(1.f, 0.f) },
{ Vector2(-halfQuadSize, halfQuadSize), Vector2(0.f, 1.f) },
{ Vector2( halfQuadSize, halfQuadSize), Vector2(1.f, 1.f) } };
vertexData.SetData(texturedQuadVertexData, 4);
unsigned short indexData[6] = { 0, 3, 1, 0, 2, 3 };
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( vertexData );
geometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) );
return geometry;
}