Flip Faces on Primitive

Software: Away3D 4.x

Avatar
theMightyAtom, Sr. Member
Posted: 29 June 2011 06:43 PM   Total Posts: 669

I’m getting an error when attempting to turn a cylinder primitive inside out.
http://videometry.net/broomstick/RealtimeDeformation.html

I’m trying to add bullet holes to an armoured plate. I add the hole, but I want a tube to show the depth of the plate. So far I’m able to add the tube in the right place (click on the plate to add a bullet hole) but the material of the cylinder is only on the outside (check out blue colour on flipside of plate)

var holeMat:ColorMaterial = new ColorMaterial(0x0000FF1);
   
holeMat.lights [_light];
   
holeMat.bothSides true;
   
   var 
c:Cylinder = new Cylinder(holeMat,-23, -20,20,16,1,false,false,false);
   
//MeshHelper.invertFaces(c);
   
plate.addChild(c); 

Using MeshHelper.invertFaces, I get the following:

RangeErrorError #3669: Bad input size.
 
at flash.display3D::VertexBuffer3D/uploadFromVector()
 
at away3d.core.base::SubGeometry/getVertexNormalBuffer()
 
at away3d.core.base::SubMesh/getVertexNormalBuffer()
 
at away3d.materials.passes::DefaultScreenPass/render()
 
at away3d.materials::MaterialBase/renderPass()
 
at away3d.core.render::DefaultRenderer/drawRenderables()
 
at away3d.core.render::DefaultRenderer/draw()
 
at away3d.core.render::RendererBase/executeRender()
 
at away3d.core.render::RendererBase/render()
 
at away3d.core.render::DefaultRenderer/render()
 
at away3d.containers::View3D/render()
 
at RealtimeDeformation/redraw() 

Reading through the google group I found this, http://groups.google.com/group/away3d-dev/browse_thread/thread/a1e72ffa17b07e48/a0fbaa0683f372a5?hl=en_US&lnk=gst&q=invert+faces+primitive#a0fbaa0683f372a5

I tried with a cube and get the same error.
I have the latest version of MeshHelper.as

Any ideas?

Cheers,

Pete

 

   

Avatar
theMightyAtom, Sr. Member
Posted: 29 June 2011 06:49 PM   Total Posts: 669   [ # 1 ]

I should also mention, generally I can’t get lights to work on the reverse side of faces even with bothsides=true on the material. They are always black. I have hunted for a bothSides for the PointLight, but haven’t found any way to apply light on both sides of a plane.

 

   

Avatar
Choons, Sr. Member
Posted: 29 June 2011 09:39 PM   Total Posts: 281   [ # 2 ]

I see what you mean. Still looks good though. Normal mapping for the bent metal edge of the hole?

 

   

John Brookes, Moderator
Posted: 29 June 2011 10:04 PM   Total Posts: 732   [ # 3 ]

It is a bug.
Works if you don’t add a light to the material.

 

   

Avatar
theMightyAtom, Sr. Member
Posted: 30 June 2011 06:44 AM   Total Posts: 669   [ # 4 ]

That’s a big bug. So I guess the only workaround at the moment is to double the geometry, using a plane for each side?

Choons, yeah, you sussed it wink
For me that’s the real power of Molehill over other engines, the ability to easily build and manipulate complex multi-layer materials, with vector and bitmap layers, blend modes, etc. at runtime.

 

   

John Brookes, Moderator
Posted: 30 June 2011 09:20 AM   Total Posts: 732   [ # 5 ]

The normal and vertexData gets lost in the Invert function.
As in
normals = new Vector.<Number>();
tangents = new Vector.<Number>();

but nothing is put into them. So when you add a light it breaks.

This ‘seems’ to work.

//...
for (0i<numSubGeoms; ++i){
 subGeom 
SubGeometry(subGeometries[i]);
 
indices subGeom.indexData;
 
normals subGeom.vertexNormalData//new Vector.<Number>();
 
tangents subGeom.vertexTangentData//new Vector.<Number>();
 
trace(indices.length);
 for (
0j<indices.lengthj+=3){
  indV0 
indices[j];
  
indices[j] indices[ind j+1];
  
indices[ind] indV0;
 
}
 
for (0normals.lengthj++)
 
{
   normals[j] 
*=-1
 }
 
 subGeom
.updateIndexData(indices);
 
subGeom.updateVertexNormalData(normals);
 
subGeom.updateVertexTangentData(tangents);

Id wait for Fabrice to fix wink

 

   

Avatar
theMightyAtom, Sr. Member
Posted: 30 June 2011 02:00 PM   Total Posts: 669   [ # 6 ]

Cheers John, that worked like a charm smile
http://videometry.net/broomstick/RealtimeDeformation.html

 

   

Avatar
Fabrice Closier, Administrator
Posted: 30 June 2011 02:34 PM   Total Posts: 1265   [ # 7 ]

I’m busy on Prefab 2.0 atm, but will try look at this one asap..

 

   

John Brookes, Moderator
Posted: 30 June 2011 03:15 PM   Total Posts: 732   [ # 8 ]

Fabrice, maybe also an option to flip faces for a subMesh as well as the whole mesh.
Sort of
invertFaces(mesh:Mesh,subg:uint)

 

   

Avatar
Fabrice Closier, Administrator
Posted: 30 June 2011 03:25 PM   Total Posts: 1265   [ # 9 ]

That’s a very good idea John. Added it to my skyhigh todo list :D

 

   

Concept Z, Sr. Member
Posted: 01 July 2011 02:55 AM   Total Posts: 124   [ # 10 ]

see the plane

 

 Signature 
signature_image

Anyone can cook but only the fearless can be great

   

Avatar
theMightyAtom, Sr. Member
Posted: 01 July 2011 06:52 AM   Total Posts: 669   [ # 11 ]

Nice one forrest,
You win the prize for stress testing the demo smile

Next step is “randomly ragged” holes that take into account the firing angle.
Work, work, work…

 

   

Avatar
Ringo Blanken, Administrator
Posted: 01 July 2011 07:14 AM   Total Posts: 120   [ # 12 ]

Zug zug smile

Very cool!

 

 Signature 

Freelancer: http://www.ringo.nl/en/
http://www.jiglibflash.com
http://www.awayphysics.com
http://www.away3d.com

   

Avatar
Choons, Sr. Member
Posted: 01 July 2011 07:15 AM   Total Posts: 281   [ # 13 ]

uhhh was that a bug or just OCD, forrest? @ Pete that looks way cool

 

   

Avatar
theMightyAtom, Sr. Member
Posted: 01 July 2011 08:09 AM   Total Posts: 669   [ # 14 ]

Cheers Choons!

Truth be known I was supposed to be making a demo showing how a kitchen sink is dynamically placed into a work top, but I got a bit carried away…

 

   

Avatar
Choons, Sr. Member
Posted: 01 July 2011 03:26 PM   Total Posts: 281   [ # 15 ]

LOL! Sinks by GlockĀ® new for 2011

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X