Desperately Need Cubic Bezier Path/Cubic Bezier Surface & NURBS Support !!!

Software: Away3D 4.x

Concept Z, Sr. Member
Posted: 28 June 2011 05:33 AM   Total Posts: 124

hi , I still don’t know when will the NURBS Module ready for for Away3d 4…

 Signature 
signature_image

Anyone can cook but only the fearless can be great

   

Avatar
Greg Caldwell (Greg209), Administrator
Posted: 28 June 2011 10:22 AM   Total Posts: 45   [ # 1 ]

Hi,

I’m planning on porting/re-implementing the patches and NURBS from 3.6 but haven’t had much chance recently. It’s definitely on the TODO list but I’ll need to have a think about the best way to do this, to try and take advantage of the GPU if I can.

It may have to be a port first followed by a re-factor.

Greg

 

 Signature 

Home page : http://www.geepers.co.uk
Mobile apps : Sum It All Up

   

Avatar
kurono, Sr. Member
Posted: 06 October 2012 12:44 PM   Total Posts: 103   [ # 2 ]

Last day played around with Greg’s NURBS code and tried to write kinda port for Away4.
The only thing I’ve changed is mostly a way to construct mesh of computed bezier data. And that’s it - the grid is shown, but not the way I expected. As you can see, triangles are overlapped. I think the problem is in different ways to storage mesh data for Away 3.6 and Away 4. But the only expert in this area is Greg, so please help me smile

All the necessary classes are attached.

Usage:

var controlNet:Array = 
    
new WeightedVertex( -2000, -1501),
    new 
WeightedVertex( -200, -100, -751),
    new 
WeightedVertex( -200 , -10001),
    new 
WeightedVertex( -200,-100751),
    new 
WeightedVertex( -20001501),
    
    new 
WeightedVertex( -100, -100, -1501),
    new 
WeightedVertex( -100, -100, -751),
    new 
WeightedVertex( -100, -10001),
    new 
WeightedVertex( -100, -100751),
    new 
WeightedVertex( -100, -1001501),
    
    new 
WeightedVertex0, -100, -1501),
    new 
WeightedVertex0, -100, -751),
    new 
WeightedVertex025001),
    new 
WeightedVertex0, -100751),
    new 
WeightedVertex(0, -1001501),
     
    new 
WeightedVertex100, -100, -1501),
    new 
WeightedVertex100, -100, -751),
    new 
WeightedVertex100, -10001),
    new 
WeightedVertex(100, -100751),
    new 
WeightedVertex(100 , -1001501),
     
    new 
WeightedVertex(2000, -1501),
    new 
WeightedVertex200, -100, -751),
    new 
WeightedVertex200, -10001),
    new 
WeightedVertex200, -100751),
    new 
WeightedVertex2000150,1)];
    
   var 
nb:NURBSbuilder = new NURBSbuilder(controlNet55{ uSegments:20vSegments:20uOrder:4vOrder:4 });
   var 
mesh:Mesh buildMesh(nb.rawVerticesnb.rawFacesnb.rawUVs);
   
mesh.position = new Vector3D(02000);
   
view.scene.addChild(mesh); 

And small code I’ve made to build mesh from set of vertices and faces.

public function buildMesh(rawVerts:Vector.<Number>, rawFaces:Vector.<uint>, rawUVs:Vector.<Number> = null):Mesh {
   
var sub:SubGeometry = new SubGeometry();
   var 
geometry:Geometry = new Geometry();
   
geometry.addSubGeometry(sub);
   
   if (
rawUVs == null{
    
var i:uint;
    
// auto-build uvs
    
rawUVs = new Vector.<Number>();
    for (
0rawFaces.lengthi++){
     rawUVs
.push(2); rawUVs.push(0); rawUVs.push(1);
    
}
   }
   
   with 
(sub{
    autoDeriveVertexNormals 
true;
    
autoDeriveVertexTangents true;
    
updateVertexData(rawVerts);
    
updateIndexData(rawFaces);
    
updateUVData(rawUVs);
   
}
   
return new Mesh(geometrynull);
  

 

File Attachments
nurbs.zip  (File Size: 3KB - Downloads: 431)
   

Avatar
80prozent, Sr. Member
Posted: 06 October 2012 03:00 PM   Total Posts: 430   [ # 3 ]

Hi

i changed the rawFaces of the NURBSbuilder.as into this, and it seams to work:

public function get rawFaces():Vector.<uint{
 
var rawfaces:Vector.<uint> = new Vector.<uint>();
 if (
_faces{
  
var i:uint;
  for (
i=0i<_faces.lengthi++) {
   rawfaces
.push(i*3);
   
rawfaces.push(i*3+1);
   
rawfaces.push(i*3+2);
  
}
 }
 
return rawfaces;

hope that works for you too.

 

 Signature 

sorry…i hope my actionscript is better than my english…

   

Avatar
kurono, Sr. Member
Posted: 06 October 2012 03:35 PM   Total Posts: 103   [ # 4 ]

Thanks a lot, 80prozent!
That’s exactly what I want. Now I’m at least 80% happier smile

 

   

Avatar
80prozent, Sr. Member
Posted: 06 October 2012 03:51 PM   Total Posts: 430   [ # 5 ]

no problem.

i do not not fully understand this class yet, but i believe it could be optimizied to produce meshes with much smaller verticles-count.

as it is right now, each triangle produces 3 verticles, while they really could share them.

you could reduce the verticle-count by using the weld function afterwards, but i think welding the mesh while producing it, would be much more effiecient.

anyway, i allways liked the bezier nurbs classes for their smooth looking meshes, and i am more than 80% happy to see some of it finaly coming to away3d 4.

smile

 

 Signature 

sorry…i hope my actionscript is better than my english…

   

Avatar
kurono, Sr. Member
Posted: 06 October 2012 04:19 PM   Total Posts: 103   [ # 6 ]

with the help of community)
I didn’t include interactive control grid for this port, btw. But it surely could be expanded using small cubes (with “mouseEnabled” property) and Drag3D.

 

   

Avatar
Greg Caldwell (Greg209), Administrator
Posted: 07 October 2012 06:54 PM   Total Posts: 45   [ # 7 ]

Nice one guys!! Sorry I haven’t got around to it before you - other things have taken priority - not really a good excuse I know.

Glad you got it working.

I’m definitely looking into the feasibility of a GPU based NURBS implementation by pushing part of the creation to the GPU and not just the mesh rendering, to improve the whole process.

I’ll also look into getting a direct port integrated into main repo.

Greg

 

 Signature 

Home page : http://www.geepers.co.uk
Mobile apps : Sum It All Up

   

Avatar
80prozent, Sr. Member
Posted: 07 October 2012 08:42 PM   Total Posts: 430   [ # 8 ]

hi greg

one question about the GPU calculation stuff.

would this be the basic workflow for this?

- calculate number of verticles and create vertexbuffer.
- calculate faces and create indexBuffer.
- upload to GPU (subgeometry)
- use a vertexshader to calculate vertex positions

i am trying to understand how this would work, so it would be great to know if i am theoretical on the right way…

 

 Signature 

sorry…i hope my actionscript is better than my english…

   

Avatar
Greg Caldwell (Greg209), Administrator
Posted: 09 October 2012 12:28 PM   Total Posts: 45   [ # 9 ]

Hey guys,

You’ve got me interested in those NURBS again so I took a go at re-working the NURBS for 4.0. As a result, there is now a class available in the 4.1 dev branch on GitHub. Check it out and let me know if it works okay for you.

I’ve posted a quick demo at : http://bit.ly/OQp5Lx

This shows 40x40 segment NURBS geometry that is also animated by shifting the 3 of the control points. Also includes a ball moving across the surface.

Let me know what you think.

@80prozent, in terms of GPU calcs, there are a number of options but principally yes, my first approach will be to send pre-sized vertex/index buffers to the GPU and let the shaders do the calcs to push the vertices in the correct place. The current animated NURBS in the demo require a vertices upload between frames - which starts to slow down when the meshes are large.

Sorry I didn’t get around to it sooner.

Greg

 

 Signature 

Home page : http://www.geepers.co.uk
Mobile apps : Sum It All Up

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X