Hey everyone,
I am writing the following code to create custom geometry, which is basically few planes beside each other - as seen in the attached image.
PROBLEM:
The way I have created the UVs is not giving me the desired result. Current code applies a planner UV to each plane. Rather I want to apply a single UV for the entire mesh - please see attached image
Any pointers on how to achieve this. Appreciate your time and efforts.
Thanks a lot,
ak
var geometry:Geometry = new Geometry();
var subGeometry:SubGeometry = new SubGeometry();
var vertices:Vector.<Number> = new Vector.<Number>();
vertices.push( -100, 100, 0 );
vertices.push( 100, 100, 0 );
vertices.push( 100, -100, 0 );
vertices.push( -100, -100, 0 );
vertices.push( 100, 100, 0 );
vertices.push( 200, 100, 0 );
vertices.push( 200, 80, 0 );
vertices.push( 100, 80, 0 );
vertices.push( 200, 100, 0 );
vertices.push( 400, 100, 0 );
vertices.push( 400, -100, 0 );
vertices.push( 200, -100, 0 );
var indices:Vector.<uint> = new Vector.<uint>();
for (var i:int = 0; i <= vertices.length/4; i+=4) {
indices.push( i, i + 1, i + 2 );
indices.push( i, i + 2, i + 3 );
}
var rawUvData:Vector.<Number>
rawUvData = Vector.<Number>([0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1,0, 0, 1, 0, 1, 1, 0, 1]);
subGeometry.updateUVData(rawUvData);
//make it double sided
indices = indices.concat( indices.concat().reverse() );
subGeometry.updateIndexData( indices );
geometry.addSubGeometry( subGeometry );
subGeometry.autoDeriveVertexTangents = true;
subGeometry.autoDeriveVertexNormals = true;
var mesh:Mesh = new Mesh(geometry, gradMat);
mesh.scale(2);
view.scene.addChild( mesh );