本文整理汇总了C++中TriObject::GetMesh方法的典型用法代码示例。如果您正苦于以下问题:C++ TriObject::GetMesh方法的具体用法?C++ TriObject::GetMesh怎么用?C++ TriObject::GetMesh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriObject
的用法示例。
在下文中一共展示了TriObject::GetMesh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildColConvex
void bhkProxyObject::BuildColConvex()
{
proxyMesh.FreeAll();
MeshDelta md(proxyMesh);
for (int i = 0;i < pblock2->Count(PB_MESHLIST); i++) {
INode *tnode = NULL;
pblock2->GetValue(PB_MESHLIST,0,tnode,FOREVER,i);
if (tnode)
{
ObjectState os = tnode->EvalWorldState(0);
Matrix3 wm = tnode->GetNodeTM(0);
TriObject *tri = (TriObject *)os.obj->ConvertToType(0, Class_ID(TRIOBJ_CLASS_ID, 0));
if (tri)
{
Mesh& mesh = tri->GetMesh();
MeshDelta tmd (mesh);
md.AttachMesh(proxyMesh, mesh, wm, 0);
md.Apply(proxyMesh);
}
}
}
compute_convex_hull(proxyMesh, proxyMesh);
BuildOptimize(proxyMesh);
proxyPos = Point3::Origin;
forceRedraw = true;
}
示例2: BuildColCapsule
void bhkProxyObject::BuildColCapsule()
{
proxyMesh.FreeAll();
MeshDelta md(proxyMesh);
for (int i = 0;i < pblock2->Count(PB_MESHLIST); i++) {
INode *tnode = NULL;
pblock2->GetValue(PB_MESHLIST,0,tnode,FOREVER,i);
if (tnode)
{
ObjectState os = tnode->EvalWorldState(0);
Matrix3 wm = tnode->GetNodeTM(0);
TriObject *tri = (TriObject *)os.obj->ConvertToType(0, Class_ID(TRIOBJ_CLASS_ID, 0));
if (tri)
{
Mesh& mesh = tri->GetMesh();
MeshDelta tmd (mesh);
md.AttachMesh(proxyMesh, mesh, wm, 0);
md.Apply(proxyMesh);
}
}
}
Point3 pt1 = Point3::Origin;
Point3 pt2 = Point3::Origin;
float r1 = 0.0;
float r2 = 0.0;
if (proxyMesh.getNumVerts() > 3) // Doesn't guarantee that the mesh is not a plane.
{
CalcCapsule(proxyMesh, pt1, pt2, r1, r2);
BuildCapsule(proxyMesh, pt1, pt2, r1, r2);
}
proxyPos = Point3::Origin;
forceRedraw = true;
}
示例3: GetMesh
Mesh* SGP_MaxInterface::GetMesh( INode* pNode )
{
if( !IsMesh( pNode ) )
return NULL;
TimeValue time = 0;
// get max mesh instance
ObjectState os;
os = pNode->EvalWorldState(time);
Object* obj = os.obj;
if( !os.obj )
{
assert( false );
return NULL;
}
TriObject* triObj = (TriObject *)obj->ConvertToType( time, triObjectClassID );
if( !triObj )
{
assert( false );
return NULL;
}
Mesh* pMesh = &triObj->GetMesh();
return pMesh;
}
示例4: BuildColBox
void bhkProxyObject::BuildColBox()
{
Box3 box; box.Init();
for (int i = 0;i < pblock2->Count(PB_MESHLIST); i++) {
INode *tnode = NULL;
pblock2->GetValue(PB_MESHLIST,0,tnode,FOREVER,i);
if (tnode)
{
ObjectState os = tnode->EvalWorldState(0);
Matrix3 wm = tnode->GetNodeTM(0);
TriObject *tri = (TriObject *)os.obj->ConvertToType(0, Class_ID(TRIOBJ_CLASS_ID, 0));
if (tri)
{
Box3 box2; box2.Init();
Mesh& mesh = tri->GetMesh();
CalcAxisAlignedBox(mesh, box2, &wm);
box += box2;
}
}
}
BuildBox(proxyMesh, box.Max().y-box.Min().y, box.Max().x-box.Min().x, box.Max().z-box.Min().z);
MNMesh mn(proxyMesh);
Matrix3 tm(true);
tm.SetTranslate(box.Center());
mn.Transform(tm);
mn.OutToTri(proxyMesh);
//proxyPos = box.Center();
proxyPos = Point3::Origin;
forceRedraw = true;
}
示例5: ImportTriStripsShape
bool CollisionImport::ImportTriStripsShape(INode *rbody, bhkRigidBodyRef body, bhkNiTriStripsShapeRef shape, INode *parent, Matrix3& tm)
{
if (shape->GetNumStripsData() != 1)
return NULL;
if ( ImpNode *node = ni.i->CreateNode() )
{
TriObject *triObject = CreateNewTriObject();
node->Reference(triObject);
INode *inode = node->GetINode();
// Texture
Mesh& mesh = triObject->GetMesh();
NiTriStripsDataRef triShapeData = shape->GetStripsData(0);
if (triShapeData == NULL)
return false;
// Temporary shape
NiTriStripsRef triShape = new NiTriStrips();
vector<Triangle> tris = triShapeData->GetTriangles();
ni.ImportMesh(node, triObject, triShape, triShapeData, tris);
CreatebhkCollisionModifier(inode, bv_type_shapes, shape->GetMaterial(), OL_UNIDENTIFIED, 0);
ImportBase(body, shape, parent, inode, tm);
AddShape(rbody, inode);
return true;
}
return false;
}
示例6: ModifyObject
void CVDModifier::ModifyObject(TimeValue t, ModContext &mc, ObjectState *os, INode *node)
{
if (!os->obj->IsSubClassOf(triObjectClassID)) return;
// Get a mesh from input object
TriObject *tobj = (TriObject*)os->obj;
Mesh* mesh = &tobj->GetMesh();
int numVert = mesh->getNumVerts();
// Get parameters from pblock
float sparam = 0.0f;
Interval valid = FOREVER;
pblock->GetValue(cvd_codev, t, sparam, valid);
// Take over the channel, realloc with size == number of verts
mesh->setVDataSupport(MY_CHANNEL,TRUE);
// Get a pointer back to the floating point array
float *vdata = mesh->vertexFloat(MY_CHANNEL);
if(vdata)
{
// loop through all verticies
// Ask the random number generator for a value bound to the
// paramblock value
// and encode it into the vertex.
for(int i=0;i<numVert;i++)
{
vdata[i] = randomGen.getf(sparam);
}
}
}
示例7: CreateNewMesh
bool BakeRadiosity::CreateNewMesh (INode *orgNode,
Mesh *orgMesh,
Matrix3 orgMtx)
{
if((orgNode == NULL)||(orgMesh == NULL)){
DebugPrint(_T("Mesh error\n"));
return false;
}
// Creates an instance of a registered class.
Object *newObj = (Object*)(ip->CreateInstance(
GEOMOBJECT_CLASS_ID,
Class_ID(TRIOBJ_CLASS_ID, 0)));
if(newObj == NULL){
DebugPrint(_T("CreateInstance error\n"));
return false;
}
// Creates a new node in the scene with the given object.
INode *newNode = ip->CreateObjectNode(newObj);
if(newNode == NULL){
DebugPrint(_T("CreateObjectNode error\n"));
return false;
}
// Sets the name of the node.
if(keepOrgFlag != true){
newNode->SetName(orgNode->GetName());
} else {
TSTR newName;
newName.printf(_T("%s_BAKED"), orgNode->GetName());
newNode->SetName(newName);
}
// Sets the renderer material used by the node.
newNode->SetMtl(orgNode->GetMtl());
// Returns a reference to the mesh data member of new TriObject.
TriObject *newTriObj = (TriObject *)newObj;
Mesh &newMesh = newTriObj->GetMesh();
// Returns the number of vertices from original mesh.
int nbVert = orgMesh->getNumVerts();
// Sets the number of geometric vertices in the new mesh.
newMesh.setNumVerts(nbVert);
// The loop will continue until handling all vertices...
for(int i=0; i<nbVert; i++) {
newMesh.verts[i] = orgMtx * orgMesh->verts[i];//Set new vertices
}
// Returns the number of faces in the original mesh.
int nbFace = orgMesh->getNumFaces();
// Sets the number of faces in the new mesh
// and previous faces are discarded.
newMesh.setNumFaces(nbFace, FALSE);
// The loop will continue until handling all faces...
for(int i=0; i<nbFace; i++){ // Set new faces and Material id
newMesh.faces[i] = orgMesh->faces[i];
newMesh.faces[i].setMatID(orgMesh->faces[i].getMatID());
}
// Makes a complete copy of the specified channels
// of the original Mesh object into new Mesh.
newMesh.DeepCopy(orgMesh, CNVERT_CHANNELS);
return true;
}
示例8: GetFaceSelectionFromMesh
void UnwrapMod::GetFaceSelectionFromMesh(ObjectState *os, ModContext &mc, TimeValue t)
{
TriObject *tobj = (TriObject*)os->obj;
MeshTopoData *d = (MeshTopoData*)mc.localData;
if (d)
{
d->SetFaceSel(tobj->GetMesh().faceSel, this, t);
UpdateFaceSelection(d->faceSel);
}
}
示例9: ConvertToType
Object* bhkProxyObject::ConvertToType(TimeValue t, Class_ID obtype)
{
if (obtype == triObjectClassID)
{
int bvType = 0;
pblock2->GetValue(PB_BOUND_TYPE, 0, bvType, FOREVER, 0);
if (bvType != 0)
{
TriObject *ob = CreateNewTriObject();
#if VERSION_3DSMAX >= ((5000<<16)+(15<<8)+0) // Version 5+
ob->GetMesh().CopyBasics(proxyMesh);
#else
ob->GetMesh() = proxyMesh;
#endif
ob->SetChannelValidity(TOPO_CHAN_NUM,ObjectValidity(t));
ob->SetChannelValidity(GEOM_CHAN_NUM,ObjectValidity(t));
return ob;
}
}
return 0;
}
示例10: ConvertToType
Object* SimpleObject::ConvertToType(TimeValue t, Class_ID obtype)
{
if (obtype==defObjectClassID||obtype==triObjectClassID||obtype==mapObjectClassID) {
TriObject *triob;
UpdateMesh(t);
triob = CreateNewTriObject();
triob->GetMesh() = mesh;
triob->SetChannelValidity(TOPO_CHAN_NUM,ObjectValidity(t));
triob->SetChannelValidity(GEOM_CHAN_NUM,ObjectValidity(t));
return triob;
}
#ifndef NO_PATCHES
if (obtype == patchObjectClassID) {
UpdateMesh(t);
PatchObject *patchob = new PatchObject();
patchob->patch = mesh; // Handy Mesh->PatchMesh conversion
patchob->SetChannelValidity(TOPO_CHAN_NUM,ObjectValidity(t));
patchob->SetChannelValidity(GEOM_CHAN_NUM,ObjectValidity(t));
return patchob;
}
#endif
if (Object::CanConvertToType (obtype)) {
UpdateMesh (t);
return Object::ConvertToType(t,obtype);
}
if (CanConvertTriObject(obtype)) {
UpdateMesh (t);
TriObject *triob = CreateNewTriObject ();
triob->GetMesh() = mesh;
triob->SetChannelValidity(TOPO_CHAN_NUM,ObjectValidity(t));
triob->SetChannelValidity(GEOM_CHAN_NUM,ObjectValidity(t));
Object *ob = triob->ConvertToType (t, obtype);
if (ob != triob) triob->DeleteThis (); // (ob should never = tob.)
return ob;
}
return NULL;
}
示例11: ModifyObject
void AFRMod::ModifyObject (TimeValue t, ModContext &mc, ObjectState *os, INode *node) {
Interval iv = FOREVER;
float f, p, b;
int backface;
Point3 pt1, pt2;
pblock->GetValue(PB_FALLOFF,t,f,iv);
pblock->GetValue(PB_PINCH,t,p,iv);
pblock->GetValue(PB_BUBBLE,t,b,iv);
pblock->GetValue(PB_BACKFACE,t,backface,iv);
p1->GetValue(t,&pt1,iv,CTRL_ABSOLUTE);
p2->GetValue(t,&pt2,iv,CTRL_ABSOLUTE);
if (f==0.0) {
os->obj->UpdateValidity(GEOM_CHAN_NUM,iv);
return;
}
Tab<Point3> normals;
if (backface) {
// Need to get vertex normals.
if (os->obj->IsSubClassOf(triObjectClassID)) {
TriObject *tobj = (TriObject*)os->obj;
AverageVertexNormals (tobj->GetMesh(), normals);
} else if (os->obj->IsSubClassOf (polyObjectClassID)) {
PolyObject *pobj = (PolyObject *) os->obj;
MNMesh &mesh = pobj->GetMesh();
normals.SetCount (mesh.numv);
Point3 *vn = normals.Addr(0);
for (int i=0; i<mesh.numv; i++) {
if (mesh.v[i].GetFlag (MN_DEAD)) vn[i]=Point3(0,0,0);
else vn[i] = mesh.GetVertexNormal (i);
}
#ifndef NO_PATCHES
} else if (os->obj->IsSubClassOf (patchObjectClassID)) {
PatchObject *pobj = (PatchObject *) os->obj;
normals.SetCount (pobj->NumPoints ());
Point3 *vn = normals.Addr(0);
for (int i=0; i<pobj->NumPoints(); i++) vn[i] = pobj->VertexNormal (i);
#endif
}
}
if (normals.Count()) {
AFRDeformer deformer(mc,f,p,b,pt1,pt2,&normals);
os->obj->Deform(&deformer, TRUE);
} else {
AFRDeformer deformer(mc,f,p,b,pt1,pt2);
os->obj->Deform(&deformer, TRUE);
}
os->obj->UpdateValidity(GEOM_CHAN_NUM,iv);
}
示例12: mn
INode *CollisionImport::ImportCollisionMesh(
const vector<Vector3>& verts,
const vector<Triangle>& tris,
const vector<Vector3>& norms,
Matrix3& tm,
INode *parent
)
{
INode *returnNode = NULL;
if ( ImpNode *node = ni.i->CreateNode() )
{
TriObject *triObject = CreateNewTriObject();
node->Reference(triObject);
Mesh& mesh = triObject->GetMesh();
INode *tnode = node->GetINode();
// Vertex info
{
int nVertices = verts.size();
mesh.setNumVerts(nVertices);
for (int i=0; i < nVertices; ++i){
Vector3 v = verts[i] * ni.bhkScaleFactor;
mesh.verts[i].Set(v.x, v.y, v.z);
}
}
// Triangles and texture vertices
ni.SetTriangles(mesh, tris);
//ni.SetNormals(mesh, tris, norms);
MNMesh mn(mesh);
mn.Transform(tm);
mn.OutToTri(mesh);
mesh.checkNormals(TRUE);
ni.i->AddNodeToScene(node);
returnNode = node->GetINode();
returnNode->EvalWorldState(0);
if (parent != NULL)
parent->AttachChild(tnode, 1);
}
return returnNode;
}
示例13: BuildColOBB
void bhkProxyObject::BuildColOBB()
{
proxyMesh.FreeAll();
MeshDelta md(proxyMesh);
for (int i = 0;i < pblock2->Count(PB_MESHLIST); i++) {
INode *tnode = NULL;
pblock2->GetValue(PB_MESHLIST,0,tnode,FOREVER,i);
if (tnode)
{
ObjectState os = tnode->EvalWorldState(0);
Matrix3 wm = tnode->GetNodeTM(0);
TriObject *tri = (TriObject *)os.obj->ConvertToType(0, Class_ID(TRIOBJ_CLASS_ID, 0));
if (tri)
{
Mesh& mesh = tri->GetMesh();
MeshDelta tmd (mesh);
md.AttachMesh(proxyMesh, mesh, wm, 0);
md.Apply(proxyMesh);
}
}
}
Matrix3 rtm(true);
Point3 center = Point3::Origin;;
float udim = 0.0f, vdim = 0.0f, ndim = 0.0f;
if (proxyMesh.getNumVerts() > 3) // Doesn't guarantee that the mesh is not a plane.
{
// First build a convex mesh to put the box around;
// the method acts oddly if extra vertices are present.
BuildColConvex();
CalcOrientedBox(proxyMesh, udim, vdim, ndim, center, rtm);
BuildBox(proxyMesh, vdim, udim, ndim);
}
MNMesh mn(proxyMesh);
mn.Transform(rtm);
mn.OutToTri(proxyMesh);
proxyPos = Point3::Origin;
forceRedraw = true;
}
示例14: nodeEnum
BOOL FaceDataExport::nodeEnum(INode* node,Interface *ip) {
if(!exportSelected || node->Selected()) {
ObjectState os = node->EvalWorldState(ip->GetTime());
IFaceDataMgr *pFDMgr = NULL;
if (os.obj->IsSubClassOf(triObjectClassID)) {
TriObject *tobj = (TriObject *)os.obj;
Mesh* mesh = &tobj->GetMesh();
pFDMgr = static_cast<IFaceDataMgr*>(mesh->GetInterface( FACEDATAMGR_INTERFACE ));
} else if (os.obj->IsSubClassOf (polyObjectClassID)) {
PolyObject *pobj = (PolyObject *)os.obj;
MNMesh *mesh = &pobj->GetMesh();
pFDMgr = static_cast<IFaceDataMgr*>(mesh->GetInterface( FACEDATAMGR_INTERFACE ));
}
if (pFDMgr == NULL) return FALSE;
SampleFaceData* SampleDataChan = NULL;
IFaceDataChannel* fdc = pFDMgr->GetFaceDataChan( FACE_MAXSAMPLEUSE_CLSID );
if ( fdc != NULL ) SampleDataChan = dynamic_cast<SampleFaceData*>(fdc);
if ( SampleDataChan == NULL) {
fileStream.Printf(_T("Node %s does not have our Face Data\n"),node->GetName());
return false;
}
//OK so We have Face data lets dump it out..
fileStream.Printf(_T("\nNode %s has %d faces with FaceFloats\n"),node->GetName(), SampleDataChan->Count());
for(ULONG i=0;i<SampleDataChan->Count();i++) {
float data = SampleDataChan->data[i];
fileStream.Printf(_T("Face %d, float %f\n"),i,data);
}
}
// Recurse through this node's children, if any
for (int c = 0; c < node->NumberOfChildren(); c++) {
if (!nodeEnum(node->GetChildNode(c), ip)) return FALSE;
}
return TRUE;
}
示例15: CreateNewTriObject
int
OBJImport::DoImport(const TCHAR *filename,ImpInterface *i,Interface *gi, BOOL suppressPrompts) {
TriObject *object = CreateNewTriObject();
if(!object)
return 0;
if(objFileRead(filename, &object->GetMesh())) {
ImpNode *node = i->CreateNode();
if(!node) {
delete object;
return 0;
}
Matrix3 tm;
tm.IdentityMatrix();
node->Reference(object);
node->SetTransform(0,tm);
i->AddNodeToScene(node);
node->SetName(GetString(IDS_TH_WAVE_OBJ_NAME));
i->RedrawViews();
return 1;
}
return 0;
}