本文整理汇总了C++中TriObject类的典型用法代码示例。如果您正苦于以下问题:C++ TriObject类的具体用法?C++ TriObject怎么用?C++ TriObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TriObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
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;
}
示例2: CreateNewTriObject
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;
}
示例3: DoMaterialSet
void MatMod::ModifyObject(TimeValue t, ModContext &mc, ObjectState *os, INode *node)
{
Interval valid = FOREVER;
int id;
pblock->GetValue(PB_MATID,t,id,valid);
id--;
if (id<0) id = 0;
if (id>0xffff) id = 0xffff;
// For version 4 and later, we process patch meshes as they are and pass them on. Earlier
// versions converted to TriMeshes (done below). For adding other new types of objects, add
// them here!
#ifndef NO_PATCHES
if(version >= MATMOD_VER4 && os->obj->IsSubClassOf(patchObjectClassID)) {
PatchObject *patchOb = (PatchObject *)os->obj;
PatchMesh &pmesh = patchOb->GetPatchMesh(t);
BOOL useSel = pmesh.selLevel >= PO_PATCH;
for (int i=0; i<pmesh.getNumPatches(); i++) {
if (!useSel || pmesh.patchSel[i]) {
pmesh.setPatchMtlIndex(i,(MtlID)id);
}
}
pmesh.InvalidateGeomCache(); // Do this because there isn't a topo cache in PatchMesh
patchOb->UpdateValidity(TOPO_CHAN_NUM,valid);
}
else
#endif // NO_PATCHES
// Process PolyObjects
if(os->obj->IsSubClassOf(polyObjectClassID)) {
PolyObject *polyOb = (PolyObject *)os->obj;
MNMesh &mesh = polyOb->GetMesh();
BOOL useSel = mesh.selLevel == MNM_SL_FACE;
for (int i=0; i<mesh.numf; i++) {
if (!useSel || mesh.f[i].GetFlag(MN_SEL)) {
mesh.f[i].material = (MtlID)id;
}
}
polyOb->UpdateValidity(TOPO_CHAN_NUM,valid);
}
else // If it's a TriObject, process it
if(os->obj->IsSubClassOf(triObjectClassID)) {
TriObject *triOb = (TriObject *)os->obj;
DoMaterialSet(triOb, id);
triOb->UpdateValidity(TOPO_CHAN_NUM,valid);
}
else // Fallback position: If it can convert to a TriObject, do it!
if(os->obj->CanConvertToType(triObjectClassID)) {
TriObject *triOb = (TriObject *)os->obj->ConvertToType(t, triObjectClassID);
// Now stuff this into the pipeline!
os->obj = triOb;
DoMaterialSet(triOb, id);
triOb->UpdateValidity(TOPO_CHAN_NUM,valid);
}
else
return; // Do nothing if it can't convert to triObject
}
示例4: 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);
}
}
}
示例5: md
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;
}
示例6: Class_ID
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;
}
示例7: IReadyRepNodes
BOOL plDistributor::IReadyRepNodes(plMeshCacheTab& cache) const
{
int i;
for( i = 0; i < fRepNodes.Count(); i++ )
{
Mesh* mesh = nil;
TriObject* obj = nil;
if( IGetMesh(fRepNodes[i], obj, mesh) )
{
plMaxNode* repNode = (plMaxNode*)fRepNodes[i];
int iCache = cache.Count();
cache.SetCount(iCache + 1);
cache[iCache].fMesh = new Mesh(*mesh);
cache[iCache].fFlex = repNode->GetFlexibility();
if( obj )
obj->DeleteThis();
BOOL hasXImp = nil != repNode->GetXImposterComp();
ISetupNormals(repNode, cache[iCache].fMesh, hasXImp);
ISetupSkinWeights(repNode, cache[iCache].fMesh, cache[iCache].fFlex);
}
else
{
fRepNodes.Delete(i, 1);
i--;
}
}
return fRepNodes.Count() > 0;
}
示例8: DbgAssert
int XTCSample::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags, Object *pObj)
{
if ( ! vpt || ! vpt->IsAlive() )
{
// why are we here
DbgAssert(!_T("Doing Display() on invalid viewport!"));
return FALSE;
}
if(pObj->ClassID() == XGSPHERE_CLASS_ID || pObj->IsSubClassOf(triObjectClassID))
{
return DisplayMesh(t, inode, vpt, flags, GetMesh(pObj));
}
#ifndef NO_PATCHES
else if( pObj->IsSubClassOf(patchObjectClassID) )
{
return DisplayPatch(t, inode, vpt, flags, (PatchObject *) pObj);
}
#endif
else if(pObj->CanConvertToType(triObjectClassID))
{
TriObject *pTri = (TriObject *) pObj->ConvertToType(t,triObjectClassID);
DisplayMesh(t, inode, vpt, flags, &pTri->mesh);
if(pTri != pObj)
pTri->DeleteThis();
}
return 0;
}
示例9: EvalWorldState
float plMaxNodeBase::RegionPriority()
{
TimeValue currTime = 0;//hsConverterUtils::Instance().GetTime(GetInterface());
Object *obj = EvalWorldState(currTime).obj;
if( !obj )
return 0;
Matrix3 l2w = GetObjectTM(currTime);
if( obj->ClassID() == Class_ID(DUMMY_CLASS_ID,0) )
{
DummyObject* dummy = (DummyObject*)obj;
Box3 bnd = dummy->GetBox();
return BoxVolume(bnd, l2w);
}
if( obj->CanConvertToType(triObjectClassID) )
{
TriObject *meshObj = (TriObject *)obj->ConvertToType(currTime, triObjectClassID);
if( !meshObj )
return 0;
Mesh& mesh = meshObj->mesh;
Box3 bnd = mesh.getBoundingBox();
if( meshObj != obj )
meshObj->DeleteThis();
return BoxVolume(bnd, l2w);
}
// Don't know how to interpret other, it's not contained.
return 0;
}
示例10: DebugPrint
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;
}
示例11: 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);
}
}
示例12: 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);
}
示例13: CreateNewTriObject
Object *TriObject::MakeShallowCopy(ChannelMask channels) {
TriObject* newob = CreateNewTriObject();
#ifdef TRIPIPE_DEBUG
DebugPrint ("TriObject(%08x)::MakeShallowCopy (%08x): %08x\n", this, channels, newob);
#endif
newob->ShallowCopy(this,channels);
/* Redundant code NS:03-15-00
newob->mesh.ShallowCopy(&mesh,channels);
newob->CopyValidity(this,channels);
newob->mDispApprox = mDispApprox;
newob->mSubDivideDisplacement = mSubDivideDisplacement;
newob->mSplitMesh = mSplitMesh;
newob->mDisableDisplacement = mDisableDisplacement;
*/
return newob;
}
示例14: CreateNewTriObject
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;
}
示例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;
}