Novodex2.6.2 fabric System

Source: Internet
Author: User

I tried novodex2.6.2's fabric system. It feels pretty good,
Simple and easy to use, powerful functions, and good speed,
The fabric system can be used not only to simulate the fabric, but also to describe the hair and many variability objects, such as the surface of an empty gas barrel. The company is planning to use this to make hair.

I don't want to talk about it anymore. The following is a summary: the figures and demos are too lazy to release. I am so sorry to come up with them.

Novodex 2.6.2 Fabric System 1 , Overview:

NovodexThe fabric system is a system composed of many vertices used to simulate deformation objects such as clothes and flags. InNovodexMedium, the fabric is different from the rigid simulation. The fabric has a special type:NxclothThis class does not inherit from any type.

 

2 And fabric attributes:

Cloth has many attributes.NxclothdescClass expression. The following lists common attributes:

Nxmat34 Nxclothdesc: globalpose Save the global position and posture

Nxreal Thickness Thickness

Nxreal Density Density

Nxreal bendingstiffness Bending flexibility, value options (0,1)

Nxreal stretchingstiffness Stretch softness, value in (0,1)

Nxreal dampingcoefficient  Fluctuation attenuation factor, value options (0,1)

Nxreal Friction Friction Factor, value in (0,1)

Nxcollisiongroup collisiongroupCollision Group

Nxgroupsmask groupsmaskCollisionMask

Nxu32 flags You can set some behavior attributes.FlagsAs follows:

Nx_clf_disable_collision Cancel collision with a rigid body

Nx_clf_selfcollisionEnable/disableAuto-collision

Nx_clf_gravity Enable/disableGravity

Nx_clf_bending Enable/disableBending Resistance

Nx_clf_bending_ortho Enable/disableRight-angle Bending Resistance

Nx_clf_collision_twoway Enable/disableThe interaction between the fabric and the rigid body, ifDisableThe cloth will not affect the rigid body. For example, if you drag a cloth, it will not drag the rigid body.EnableThen, drag the fabric and drag the rigid body at the same time.

Nx_clf_tearable Yes,EnableWhen the force applied on the fabric is large to a certain extent, the fabric can be torn, but the premise is that a tear line must be generated during initialization.

Nx_clf_hardware Whether to use hardware simulation

 

 

3 Create Fabric

To create a fabric, you must first create a fabric.Nxclothdesc,NxclothdescDescribes all the fabric attributes, and thenNxclothdescWearNxclothObject.

Because you need to specify the vertex and triangle data to create a cloth, you also needCookDataSDK.

However, this creation process is very cumbersome,Novodex SDKProvides the encapsulated auxiliary classes.MyclothClass. This class allows you to easily create square or irregular fabrics.

Create a block widthW, HeightH, Vertex IntervalDCloth:

Mycloth(Nxscene*Scene,Nxclothdesc&Desc,Nxreal W,Nxreal H,Nxreal D,Char*Texfilename,Bool Tearlines)

You can also use the complex3DModel cloth creation:

Read*. OBJFile Creation,OBJYou can use3D MAXDirect Conversion

Mycloth(Nxscene*Scene,Nxclothdesc&Desc,Char*Objfilename,Nxreal Scale)

 

4 , Fixed Fabric

Fabrics are different from rigid bodies, so they cannot be used.JointsTo fix the fabric,NxclothClass provides several functions for fixed fabric:

Void attachvertextoglobalposition (const nxu32 vertexid, const nxvec3 & Pos );

VertexidIt is a point on the fabric. This function is used to fix a point on the fabric to a position in the global space.

 

 

Void attachvertextoshape (nxu32 vertexid, const nxshape * shape, const nxvec3 & localpos, nxu32 attachmentflags );

This function holds a point on the fabric to a rigid body.Shape,LocalposIs the local coordinate relative to the rigid body.AttachmentflagsIndicates how the fabric will affect the Rigid BodyShape, This parameter has2Values, which areNx_cloth_attachment_twowayAndNx_cloth_attachment_tearable.Nx_cloth_attachment_twowayIndicates that the rigid body can affect the fabric or the rigid body. But there is a condition,ShapeIt must be dynamic, that is, ifNx_bf_kinematicThe fabric will not be affected.Shape.

Nx_cloth_attachment_tearableIndicates that the fabric does not affect the rigid body. The force applied to the fabric is sufficient to tear the fabric.

 

 

Void attachtocolpolicingshapes (nxu32 attachmentflags );

Void attachtoshape (const nxshape * shape, nxu32 attachmentflags );

This2The cloth is fixed on the rigid body, as long as it is the point of the intersection between the cloth and the rigid body, it will be fixed on the rigid body.

 

 

Void detachfromshape (const nxshape * shape );

Void freevertex (const nxu32 vertexid );

This2To remove the fabric.

 

5 Rendering:

Void mycloth: Draw (bool shadows)

MyclothClass provides a rendering function, the principle is actually very simple, just use the vertex when creating the fabricVertex ArrayDraw.

 

6 , Sleep

To accelerate rendering, you can setSleepWhen the speed of the cloth is lower than a certain value, the cloth is regarded as static.NovodexThe calculation of the fabric is ignored.

Use the following function to obtain/SetSleepSpeed threshold value:

 
Nxreal nxcloth: getsleeplinearvelocity () const;
 
Void nxcloth: setsleeplinearvelocity (nxreal threshold );
 
 

You can query whether the cloth is inSleepMedium:

 
Bool nxcloth: issleeping () const;
 
 

You can forceClothPlaceSleepStatus:

Void nxcloth: puttosleep ();

 

You can force wake-up in the following waysCloth:

Void nxcloth: wakeup (nxreal wakecountervalue = nx_sleep_interval );

 

 

7 , Raycasting

Most of the time you need to check whether a line is in line with the cloth, you need to useRaycasting,NxclothThis function is provided:

Bool raycast (const nxray & worldray, nxvec3 & hit, nxu32 & vertexid );

Where,HitThe coordinates of intersection points are saved,VertexidIt is the point of intersection between the cloth and the line.ID

 

 

8 Apply force

NxclothClass provides the following functions:

Virtual void addforceatvertex (const nxvec3 & force, nxu32 vertexid, nxforcemode mode = nx_force );

This function adds an additional force to the fabric.

 

 

Virtual void nxcloth: addforceatpos (const nxvec3 & position, const nxvec3 & force,

Nxreal radius, nxforcemode mode = nx_force)

This function Applies force to a radius area in the space, and all the cloth vertices in this area will be affected.

 

 

Virtual void nxcloth: setexternalacceleration (nxvec3 Acceleration)

This function applies an acceleration to all vertices on the fabric, excluding the fixed vertices.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.