marlu, Newbie Posted: 28 June 2013 02:24 PM Total Posts: 8
Hello,
I’m trying to create a Mesh with the new NURBSGeometry class, but it won’t appear. Did anybody work with this before and point me in the right direction?
I’ve looked into the Away3D NURBS & NURBS Explorer and have used the vectordata of one of the examples. This example is build with an older away3d version though and some of the classes seem to have changed.
My code looks like this at the moment.
var controlNet:Vector.<NURBSVertex> = new Vector.<NURBSVertex>( [ new NURBSVertex( -300, -100, -300, 1), new NURBSVertex( -300, -100, -150, 1), new NURBSVertex( -300, -100, 0, 1), new NURBSVertex( -300, -100, 150, 1),
new NURBSVertex( -150, -100, -300, 1), new NURBSVertex( -150, -100, -150, 1), new NURBSVertex( -150, -100, 0, 1), new NURBSVertex( -150, -100, 150, 1),
new NURBSVertex( 0, -100, -300, 1), new NURBSVertex( 0, -100, -150, 1), new NURBSVertex( 0, -100, 0, 1), new NURBSVertex( 0, -100, 150, 1),
new NURBSVertex( 150, -100, -300, 1), new NURBSVertex( 150, -100, -150, 1), new NURBSVertex( 150, -100, 0, 1), new NURBSVertex( 150, -100, 150, 1)] );
var nurb:NURBSGeometry = new NURBSGeometry( controlNet, 4, 4, 4, 4, 15, 15 );
meshObject = new Mesh(nurb, planeMaterial); nurb.refreshNURBS(); view.scene.addChild(meshObject);
GoroMatsumoto, Sr. Member Posted: 28 June 2013 05:14 PM Total Posts: 166
[ # 1 ]
Maybe, your problem is outside of the snippet.
Basically, your snippet worked.
But I have a question for the class.
My above code, NURBS animation, works.
But it seems working without GPU.
Performance is not so good.
Or, my updating way is bad?
marlu, Newbie Posted: 28 June 2013 07:17 PM Total Posts: 8
[ # 2 ]
Awesome GoroMatsumoto, thank you for this.
I seem to have a mistake in the actual NURBSVertex data set in the controlNet and the parameters passed to the NURBSGeometry.
As far as I can see your code looks correct on how the animation should be handled
Because the motion itself is in kind of a fixed range I wouldn’t just increment the angleA value all the time, but instead make sure it would stay within a range. Not sure, but it might help with the calculation.
I will be investigating NURBSGeometry in the following period, so if I have more insight on this I’ll keep you posted.
That is the correct way for animating NURBS at the moment but as you say, the animation aspect of the NURBS is not currently handled by the GPU so isn’t as performant as it should be. This is something that needs looking into when I get chance.
Cheers
Greg
marlu, Newbie Posted: 30 June 2013 08:01 PM Total Posts: 8
[ # 4 ]
Hello Greg,
First of all I would like to thank you for the great post on the Away3D NURBS & NURBS Explorer. It is helping me wrapping my mind on the matter.
To get the nurbs surface data of a 3Dmodel, I’ve tried an export from 3DsMax in an obj file and parsing this to a Vector.<NURBSVertex>, but so far no luck yet ... I think I have a bug in the parse sequence.
Would you know the best way of exporting this Nurbs surface data?
For the complex models in your explorer (the dolphin and goblet data for example), you have the nurbs surface data stored in array with WeightedVertex’s to build up the mesh.
In terms of the current Away3d 4.x NURBS code, a Vector.<NURBSVertex> is required for your control points. The NURBS Explorer is only using Away3D 3.6 so doesn’t take advantage of the GPU at all and did rely on the data being in an Array of WeightedVertices (the 3.x version of NURBSVertex).
The code that @GoroMatsumoto provided is the typical way to define the control points, where each NURBVertex in the Vector defines the x,y,z and weighting of the control point.
If you are having difficulties in creating the data from a model, could you try and post the model or code and I could perhaps take a quick look.
Cheers
Greg
marlu, Newbie Posted: 01 July 2013 03:02 PM Total Posts: 8
[ # 6 ]
Hello Greg,
Thank you for the reply.
I’ve managed to make the conversion to the Vector.<NURBSVertex> list and could translate the data of the models you use in your NURBS Explorer in the new Away3d 4.1.1 format.
The model I’m currently using is an export from Cinema4D and have to be honest that my 3D knowledge is basic. I’ve been reading up on it this weekend, but the correct translation of the exported .obj file to NURBSVertex coordinates are currently not working for me.
From what I understand:
v = list of vertices
vt = texture coordinates
f = face definition
Attached you find the .obj file - it should look like kind of a bumpy potato shape.
The reason I want to use the nurbs data is because I want to be able to mold the shape dynamically and this could be achieved by tweening the control points.
At this moment I’m not so sure if this is the right approach though, also thinking about the performance. I start to believe that maybe I’m overcomplicating it and that a displacement map would be a better approach to create this molding effect.
Netherless I still really would like to know how I could create the control points data from a model, so any insight in this is more then welcome.
I’ve loaded the model and it loads fine as an .obj, however I’m not sure if it’s the kind of data you are needing.
One of the advantages of NURBS is being able to provide a limited number of control points which then can be used to create a highly smoothed object, based on those points. As you saw in the NURBS explorer, the complexity of the mesh (number of vertices and faces) is far greater than the number of control points.
In the model you have provided, it looks like it could be a candidate for representing as a set of control points but not from the data in the model. Your model has over 2500 vertices which, if you wanted to use those as control points, would be asking a lot from the current (or any) NURBS system.
Was the original Cinema 4D model a NURBS model? If so, the export looks like it has simply generated a mesh from the NURBS definition. What you’ld really want to do is somehow export the NURBS data - but not having used Cinema4D, I wouldn’t be able to tell you how.
Greg
marlu, Newbie Posted: 01 July 2013 08:03 PM Total Posts: 8
[ # 8 ]
Hello Greg,
Sorry, maybe I wasn’t clear before: this is basically the point I stranded.
The .obj loads and I can create the Mesh object with it, but the reason I like to use the NURBS (NURBSGeometry) is; like you point out: the fact of the smooth curves that can be created with it.
As far as I understand my .obj file is exported from a polygon / mesh model instead of a NURBS model and therefor the data I see in the .obj file is not representing the data that I can use as control points.
I’ve actually tried to parse the vertices data into a Vector.<NURBSVertex> list to check the data… all of them .. but the object that shows doesn’t represent the shape that was modelled.
I suspect that Cinema4D is not the right tool for this.
This is why I was wondering how you retrieved the data of the models you use in your NURBS explorer. From which program would you export it (blender, 3dsmax?) Or what kind of dataset format did you use to make the conversion to the array with WeightedVertex’s in your example?
Ah ok. Basically I used the NURBS Explorer to create the objects so there wasn’t any other app involved. I got the control points close to what I wanted and then manually tweaked the output (clicking the ‘SRC’ button in the Explorer) values to tidy them up a bit before plugging the data back into the application.
There are tools out there, including Cinema4D & Blender which do handle NURBS but I’ve not really explored them as yet. That’s on the TODO list
I must admit, a re-work of the NURBS Explorer is much needed now.
marlu, Newbie Posted: 02 July 2013 07:07 AM Total Posts: 8
[ # 10 ]
You used the Explorer itself to create the objects: Thank you for that insight!
I am confinced though that it should be possible to export the data and parse it directly to the Vector.<NURBSVertex> list.
The NURBS Explorer itself is still very effective: It is based on an older away3D version, but therefor also forced me to dive deeper into the theorie, which is I think always much more effective than getting it served directly on a plate:)
I’m sure it is possible to recreate the control points from any given mesh but it would be a very complicated task as you would need to examine the surface of the mesh and recreate the B-spline curves that best fit, across the entire surface to simplify it. Generally, the control point don’t lie on the surface either, other than at the edges of the control point net.
In the end you would end up with probably <100 NURBVertices to describe your particular mesh, rather than the 2500+ vertices it currently has.
Greg
marlu, Newbie Posted: 03 July 2013 06:58 AM Total Posts: 8
[ # 12 ]
Well, the theorie about what is needed to retrieve the nurbs control point data I get, but to be honest my mind doesn’t work that way that it can recalculate this with the given mesh data:)
A much more realistic approach for me would be to port the NURBS Explorer to the last away version. And model my potato like shape by hand (the models I need are not too complex). I think this could be usefull for more people as well, so I’ll post it when the project is finished.