Question about Cross-Sections not Normal to the Yarn

General discussion about TexGen.

Moderators: Martin, Developers

Post Reply
bluezoe
Regular
Posts: 13
Joined: Tue Aug 20, 2019 2:38 am

Question about Cross-Sections not Normal to the Yarn

Post by bluezoe »

Hello,

From the scripting guide, I have learned the rotated cross-section example.

Code: Select all

#rotate the cross-sections at mid node index=1
node = yarn.GetNode(index) 
node.SetAngle(PI/4) 
yarn.ReplaceNode(index, node)
However, as shown in the figure,
1635381644(1).png
1635381644(1).png (27.46 KiB) Viewed 9901 times
the tangent vector normal to the cross section rotated in the x-y plane.
How can I make the tangent vector rotated in the z-x plane?

Thanks
Zoe
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: Question about Cross-Sections not Normal to the Yarn

Post by louisepb »

Hi Zoe,

Sorry for the delay in replying - I've tried a couple of times and they have disappeared! The rotation is created using the CNode GetSide() and GetNormal() function where a quaternion is created using the angle and the up-vector. By default the up-vector is 0,0,1 so the rotation is about the z-axis. If you change the up-vector to 0,1,0 then the rotation is about the y-axis which I think is what you're trying to achieve. You can change the up-vector either by editing the .tg3 file or by using the CNode::SetUp() function. You just need to be careful depending on the orientation of your yarns. If the tangent is close to the up-vector then there can be issues calculating the cross-product and you might get some strange effects in the rendering. I have a screenshot but I think that may be what's caused problems posting so I'll send this and then try to put the figure in a separate message.
Hope that helps,
Louise
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: Question about Cross-Sections not Normal to the Yarn

Post by louisepb »

Hi Zoe,
For some reason it doesn't like the image file so I'm trying a zip!
Louise
Attachments
bluezoeAngleChangedUp.zip
(42.38 KiB) Downloaded 140 times
bluezoe
Regular
Posts: 13
Joined: Tue Aug 20, 2019 2:38 am

Re: Question about Cross-Sections not Normal to the Yarn

Post by bluezoe »

Hi,
After changing the global coordinate, the problem has been solved.
Thanks for your reply.
zoe
Post Reply