We found a Maya NURBS curve cannot be reconstructed correctly by
AbcExport, then AbcImport.
Attached image illustrates the situation.
I'm not so familiar with definition of Maya curves, but knot vector
must be calculated as follows to match the shape of original Maya
curves
(in the context of open, cubic and multiple-endknots-enabled Maya NURBS curve)
NurbsCurveHelper.cpp::createCurves()
...
MDoubleArray knots;
int numKnots = numVerts + degree - 1;
// Wrong!
//for (j = 0; j < numKnots; ++j)
//{
// knots.append(j/(double)(numKnots-1));
//}
// Correct solution(For open, cubic and multiple-endknots curve).
for (j = 0; j < degree-1; ++j) {
knots.append(0.0);
}
for (j = 0; j < numVerts - 2; ++j) {
knots.append(j);
}
for (j = 0; j < degree-1; ++j) {
knots.append(numVerts - 2 - 1);
}
...
More to say, another problem arising is that how Alembic defines
curves primitive.
Apparently, AbcExport only exports CVs in straight manner, so it is
easy to cause incompatibility with 3rd party tools, e.g. RenderMan's
RiCurves.
Alembic wiki does not describe so much on how curves are defined and exchanged.
(For example, I can see a property of basis matrix in OCurves, but
AbcExport doesn't use this field, and also wiki doesn't describe
it...).
As I said, I am not a Maya curves and NURBS expert, so any comments on
curves primitive are welcome.
Thanks in advance,
Syoyo
The solution you provide doesn't allow for a uniform distribution of end knots.
The full snippet of code from AbcImport:
// for now evenly distribute the knots
MDoubleArray knots;
int numKnots = numVerts + degree - 1;
for (j = 0; j < numKnots; ++j)
{
knots.append(j/(double)(numKnots-1));
}
// we need to make sure the first 3 and last 3 knots repeat
if (form == MFnNurbsCurve::kClosed && degree == 3 && numKnots > 2)
{
knots[1] = knots[0];
knots[2] = knots[0];
knots[numKnots-2] = knots[numKnots-1];
knots[numKnots-3] = knots[numKnots-1];
}
The knots are evenly distributed, and if the curve happens to be
cubic, and closed the end knots are repeated.
We haven't tried to support the other types of basis functions in Maya
(when possible).
We would gladly accept any contributions from the community if this is
needed in various pipelines.
Lucas
> --
> You received this message because you are subscribed to the Google
> Groups "alembic-discussion" group.
> To post to this group, send email to alembic-d...@googlegroups.com
> To unsubscribe from this group, send email to
> alembic-discuss...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/alembic-discussion?hl=en
>
> For RSS or Atom feeds related to Alembic, see:
>
> http://groups.google.com/group/alembic-dev/feeds
>
> http://groups.google.com/group/alembic-discussion/feeds
>
Thanks for the explanation!
> 1) If knots are not stored with the actual Nurbs curve there is no way
> to make it work.
> 2) Repeating last knows to some default values like "0" (as suggested
> by Mr. Fujita) will also fail once in a while. If something has to be
> repeated , that's the values already stored at the beginning and the
> end of the knot vector (there is no guarantee that the knot sequence
> starts at 0).
>
> Now, if I remember correctly, Maya stores Nurbs curves in some kind of
> "shortened" form and has 2 knots less than the equivalent RenderMan
> standard representation (one at the beginning and one at the end is
> missing). In our 3Delight For Maya plug-in, the knot is constructed
> like this:
I have just discussed NURBS things internally with a NURBS expert guy,
and yes, as you pointed out,
1) Knot vectors should be exported by AbcExport.
2) # of knot vectors to be exported should be +2'ed and replicate knot
value in beginning and ending element, in terms of standard NURBS
definition.
3) Knot values are not necessarily in range [0, 1]. It depends on how
knots values are defined in Maya(or more generally in NURBS modeler
and NURBS modeling designer)
So, in next phase, I would like to propose defining "knot" property as
a predefined symbol in curves primitive(OCurves, ICurves), and
AbcExport care about to exporting knot vectors in standard NURBS
manner.
I am ready to provide a patch if a proposal was accepted.
--
Syoyo
> 1) Knot vectors should be exported by AbcExport.
They should be optionally exported with a flag.
> 2) # of knot vectors to be exported should be +2'ed and replicate knot
> value in beginning and ending element, in terms of standard NURBS
> definition.
Agreed.
> 3) Knot values are not necessarily in range [0, 1]. It depends on how
> knots values are defined in Maya(or more generally in NURBS modeler
> and NURBS modeling designer)
The uniform range 0 to 1 import, would only occur in AbcImport if the
knot values weren't filled in.
> So, in next phase, I would like to propose defining "knot" property as
> a predefined symbol in curves primitive(OCurves, ICurves), and
> AbcExport care about to exporting knot vectors in standard NURBS
> manner.
It should be part of the schema but treated as optional (only created
if knot values are specified) and a flag should be added to write this
data out.
> I am ready to provide a patch if a proposal was accepted.
Please do, feel free to add the location of the patch to the ticket
you opened for this issue.
Thanks,
Lucas
1) What does AbcGeom's Curves schema describe? As previously
mentioned, it maps directly to the RiCurves interface within the
RenderMan specification. It does not currently store enough
information to describe a nurbs curve.
While Alembic has proven useful in additional ways, its initial use at
the original contributing studios (ILM and Sony) has been as a baked
cache for rendering and comparable downstream hand-offs. While it
appears to be a fairly common extension to the RenderMan interface,
RiNuCurves is not officially part of that specification (at least it
doesn't appear in Pixar's RenderMan documentation). At both of our
studios, our experience with the RenderMan interface is primarily
through prman -- which explains why AbcGeom 1.0 does not include a
schema matching RiNuCurves.
If there's a consensus that storing NURBS curves in AbcGeom would be
useful -- and it sounds like there might be -- there are a few
approaches we could take.
There could be a separate AbcGeom schema matching RiNuCurves or the
existing Curves schema could grow optional fields for knots and
weights so that it could answer, "Am I NURBS or not?" Given that some
of its existing fields (such as CurveType, CurvePeriodicity,
BasisType) wouldn't apply directly for NURBS curves (at least as
described by RiNuCurves), it probably makes more sense as a separate
schema. That's a departure from our initial thoughts but we haven't
had many internal discussions yet -- much less reached any decisions.
In either case, that means that some curves are NURBS and some curves
aren't -- which leads us to the second issue.
2) Alembic includes reference implementations of Maya export and
import plugins (AbcExport and AbcImport). Because it's the only
exporter currently included with the Alembic library, it's easy to
conflate its behaviors with the design and intentions of the AbcGeom
layer.
NURBS curves are the common (only?) curve primitives in Maya. Even if
AbcGeom supported NURBS curves directly, it'd still be necessary and
useful to have the option to export to the existing RiCurves-like form
for use in systems which don't support NURBS curves. With the existing
implementation, that can create situations in which a round trip out
and into maya doesn't produce an identical curve -- which is what I
think started this thread. The same issue applies when reading
RiCurves-like data back into Maya.
Assuming that NURBS curves are natively supported in AbcGeom in some
form or another, the second issue is specific to the behavior of
AbcExport and AbcImport:
a) What's the convention (either with command flags or maya
attributes) for indicating whether a NURBS curve should be written as
NURBS or the RiCurves-like form?
b) When writing a NURBS curve in RiCurves form, what technique should
be used to convert the data? It's clear that the current technique
(based on code we've used internally for a long time) does not fit
everyone's needs.
These behaviors are specific to AbcExport and AbcImport and are best
addressed independently of the AbcGeom-level decisions.
-stevel