Is this simple code is going to give me a delta vector between
base model and deformed one while called from within a customOperator ?

PolygonMesh meshModeling(prim.GetGeometry(0,siConstructionModeModeling));
PolygonMesh meshAnimation(prim.GetGeometry(0,siConstructionModeAnimation));

CVertexRefArray pointsModeling(meshModeling.GetVertices());
CVertexRefArray pointsAnimation(meshAnimation.GetVertices());

CVector3Array vectorsModeling = pointsModeling.GetPositionArray();
CVector3Array vectorsAnimation = pointsAnimation.GetPositionArray();

for (int p=0;p<vectorsModeling.GetCount();p++){
 CVector3 delta = CVector3().Sub(vectorsAnimation[0],vectorsModeling[0]);
app.LogMessage(CString(delta.GetX())+":"+CString(delta.GetX())+":"+CString(delta.GetX()));
}


On Mon, Apr 15, 2013 at 10:06 AM, Chris Chia <[email protected]>wrote:

> Hi Bartek,
> See below for our Dev's comments on your script:
>
> His example code is not clear. In first 2 lines, user works with input at
> line 2 which is mesh. In line 3, he works with outMesh.
>
> Our dev gives the following example:
>        Primitive prim = ctxt.GetInputValue( 0 );
>        PolygonMesh mesh( prim.GetGeometry( 0, siConstructionModeAnimation
> ) );
>        CVertexRefArray points = mesh.GetVertices();
>        MATH::CVector3Array pos = points.GetPositionArray();
>        const MATH::CVector3* l_pSrc = &pos[0];
>
> l_pSrc contains non-zero values.
>
>
> Hope this explains.
>
>
> From: [email protected] [mailto:
> [email protected]] On Behalf Of Bartek Opatowiecki
> Sent: Saturday, April 13, 2013 8:36 PM
> To: [email protected]
> Subject: Re: How to make a deformer absolute ?
>
> Primitive prim = (CRef)ctx.GetInputValue(0,0);
> PolygonMesh mesh(prim.GetGeometry(0,siConstructionModeAnimation));
> CVertexRefArray outPoints = outMesh.GetVertices();
> CVector3Array pos = outPoints.GetPositionArray();
>
> I'm calling that block of code from inside of a customOperator, ok ?
> There is an Envelope Operator below. It has some bones
>  so the mesh is being deformed by that bones.
>
> PolygonMesh
>      - Secondary Shape Modeling
>      - Animation
>           - MyOperator
>           - EnvelopeOperator ->
>       -Shape Modeling
>      - Modeling
>
> How to get result of  "EnvelopeOperator" as an Array of absolute vectors,
> from within "MyOperator" Update callback ?
> Actually  "pos " is filled with zeroes.
>
> Hope, you get what I mean :)
>
> Thanks
>
>
>
>
> On Sat, Apr 13, 2013 at 3:04 AM, Raffaele Fragapane <
> [email protected]<mailto:[email protected]>> wrote:
> If you transform the vectors by the global kine transform of the object
> they come from they will be in world space.
> Assuming you are reading from another object and getting its point
> positions (and those are local) and want their global coordinates the above
> step is what you need.
> If you want them in the space of another object then you will have to do
> the above and also multiply by the inverse of the object's global transform
> you want them to be in the space of.
>
> You can chain those two matrices outside the loop taking care of the
> pointpos vectors, as they are per object, to save some cycles.
>
> Unless you were asking for something else.
>
> On Sat, Apr 13, 2013 at 6:45 AM, Bartosz Opatowiecki <
> [email protected]<mailto:[email protected]>> wrote:
> Actually it is false, because I got deformed vertices
> into my deformer any way. So anything I do inside my operator
> is relative to the previous operator in the stack...
>
> Instead, I want to get vertices in world space or in X3DObject space
> fed into my deformer. How can I do that ?
>
> W dniu 2013-04-12 22:33, Alan Fregtman pisze:
> Yeah, it should.
>
> You're reading from the Modeling stack, so the envelope didn't happen at
> that point.
>
> Then you're setting the positions, so anything between your operator and
> the Modeling marker might as well not exist because it's overridden by your
> data.
>
>
> On Fri, Apr 12, 2013 at 4:26 PM, Bartosz Opatowiecki <
> [email protected]<mailto:[email protected]>> wrote:
> Hey,
>
> Lets forget about node transformations, only vertices are being deformed.
> If, within an update function I get a geometry like this:
>
> Primitive prim = (CRef)ctx.GetInputValue(0,0);
> PolygonMesh mesh(prim.GetGeometry(0,siConstructionModeModeling));
> CVertexRefArray outPoints = outMesh.GetVertices();
> CVector3Array pos = outPoints.GetPositionArray();
>
> and put its data back:
>
> Primitive outPrim(ctx.GetOutputTarget());
> PolygonMesh outMesh(outPrim.GetGeometry(0,siConstructionModeModeling));
> CVertexRefArray outPoints = outMesh.GetVertices();
> outPoints.PutPositionArray(pos);
>
> my output mesh should stay still even if envelope operator is below it.
> Am I right ?
>
> W dniu 2013-04-12 20:10, Alan Fregtman pisze:
> >From what you said you're already setting the pointpositions (aka
> deforming), so you have already taken over. You can set the deformation to
> be absolute if your data is absolute and taking the object's transform into
> consideration.
>
> If you mean if you can disable operators downwards... no, you can't.
>
>
> On Fri, Apr 12, 2013 at 12:18 PM, Bartek Opatowiecki <
> [email protected]<mailto:[email protected]>> wrote:
> Hi,
>
> I'm working on a customOperator which is deforimg a mesh.
> It is sitting at the top of an animation construction mode .
> I would like it to take over the deformation at some point
> and ignore entire construction stack below it.
>
> thanks,
> Bartek
>
>
>
>
>
>
>
> --
> Our users will know fear and cower before our software! Ship it! Ship it
> and let them flee like the dogs they are!
>
>

Reply via email to