|
Pokey, Newbie
Posted: 24 May 2013 06:20 AM Total Posts: 23
Hello,
I have been trying to manipulate UVs of a sphere mesh but I cannot figure out how to convert the CompactSubGeometry to a SubGeometry so I can call updateUVData().
var mold:Mesh = new Mesh( new SphereGeometry( 100, 200, 80 ), new TextureMaterial(Cast.bitmapTexture(surfaceDiffuse)));
When I run:
trace((mold.geometry.subGeometries[0]));
I get
[object CompactSubGeometry]
which does not support UV manipulation as far as I can tell. I am stuck.
Any help would be greatly appreciated.
TNX
|
loth, Sr. Member
Posted: 24 May 2013 07:39 AM Total Posts: 236
[ # 1 ]
yo
mold.geometry.convertToSeparateBuffers();
|
Pokey, Newbie
Posted: 24 May 2013 05:12 PM Total Posts: 23
[ # 2 ]
THANK YOU LOTH!
That is exactly what I needed (you don’t want to know how much code I typed trying to do that!).
|
loth, Sr. Member
Posted: 24 May 2013 05:24 PM Total Posts: 236
[ # 3 ]
yes a another thing don’t miss
mold.geometry.subGeometries[0].autoDeriveVertexNormals = false; mold.geometry.subGeometries[0].autoDeriveVertexTangents = false;
if you object move or you see performance fall
the best is look Advanced_ShallowWaterDemo exemple
|
Pokey, Newbie
Posted: 27 May 2013 05:47 AM Total Posts: 23
[ # 4 ]
|
Pokey, Newbie
Posted: 04 June 2013 06:00 AM Total Posts: 23
[ # 5 ]
BTW, this is broken in 4.1.1
trace((mold.geometry.subGeometries[0]));
after running
mold.geometry.convertToSeparateBuffers();
gives me an ISubGeometry which does not support the updateUVData() method.
|
Fabrice Closier, Administrator
Posted: 04 June 2013 05:34 PM Total Posts: 1265
[ # 6 ]
No it’s not a bug. It’s confusing and trust me I fighted within team to get this done otherways, but lost the battle
Tho, I did won a small handy method (yay)
/**
* Isolate and returns a Vector.Number of a specific buffer type
*
* - stripBuffer(0, 3), return only the vertices
* - stripBuffer(3, 3): return only the normals
* - stripBuffer(6, 3): return only the tangents
* - stripBuffer(9, 2): return only the uv’s
* - stripBuffer(11, 2): return only the secondary uv’s
*/
public function stripBuffer(offset : int, numEntries : int) : Vector.<Number>
{
In case you need the data as expected (just uv’s, just vertices etc…).
However, you will need to use from Vector to reconstruct/update.
Also note that this is only to be used in cases where you update once
in a while yet, and if you would want to keep teh subGeometries as compactGeometry. Otherwize, converting to “classic” is still the fastest way if you do edit your meshes a lot.
|
Pokey, Newbie
Posted: 05 June 2013 05:13 AM Total Posts: 23
[ # 7 ]
Well that explains that!
My brother (a perl programmer) suggested adding “as SubGeometry” like so
mold.geometry.subGeometries[0] as SubGeometry;
and my code started working again! Phew!
(I do need to do a LOT of UV manipulation BTW.)
Thanks.
|