void C4DefGraphicsPtrBackup::AssignUpdate()
{
	// Update mesh materials for all meshes
	for(C4DefList::Table::iterator iter = Definitions.table.begin(); iter != Definitions.table.end(); ++iter)
		if(iter->second->Graphics.Type == C4DefGraphics::TYPE_Mesh)
			MeshMaterialUpdate.Update(iter->second->Graphics.Mesh);

	// Then, update mesh references in instances, attach bones by name, and update sprite gfx
	for(std::list<C4DefGraphicsPtrBackupEntry*>::iterator iter = Entries.begin(); iter != Entries.end(); ++iter)
		(*iter)->AssignUpdate();

	// Update mesh materials and animations for all mesh instances.
	for (C4Object *pObj : Objects)
	{
		if (pObj && pObj->Status)
		{
			if(pObj->pMeshInstance)
				UpdateMesh(pObj->pMeshInstance);
			for (C4GraphicsOverlay* pGfxOverlay = pObj->pGfxOverlay; pGfxOverlay; pGfxOverlay = pGfxOverlay->GetNext())
				if(pGfxOverlay->pMeshInstance)
					UpdateMesh(pGfxOverlay->pMeshInstance);
		}
	}

	fApplied = true;
}
示例#2
0
void SimpleParticle::Update(TimeValue t,INode *node)
	{
	if (node) {
		if (tvalid!=t || !valid) UpdateParticles(t,node);
		}
	UpdateMesh(t);
	}
示例#3
0
// From BaseObject
int SimpleWSMObject::HitTest(TimeValue t, INode *inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt) 
	{

	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}

	Point2 pt( (float)p[0].x, (float)p[0].y );
	HitRegion hitRegion;
	GraphicsWindow *gw = vpt->getGW();	
	Material *mtl = gw->getMaterial();
		
	UpdateMesh(t);
	gw->setTransform(inode->GetObjectTM(t));
	MakeHitRegion(hitRegion, type, crossing, 4, p);
	DWORD rlim  = gw->getRndLimits();	
	int res;

	gw->setRndLimits((rlim|GW_PICK|GW_WIREFRAME) 
		& ~(GW_ILLUM|GW_BACKCULL|GW_FLAT|GW_SPECULAR));

	res = mesh.select(gw, mtl, &hitRegion, flags & HIT_ABORTONHIT);
	
	gw->setRndLimits(rlim);
	return res;
	}
示例#4
0
int bhkCapsuleObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
{
   Matrix3 m;
   Color color = Color(inode->GetWireColor());
   GraphicsWindow *gw = vpt->getGW();
   Material *mtl = gw->getMaterial();
   m = inode->GetObjectTM(t);
   gw->setTransform(m);
   DWORD rlim = gw->getRndLimits();

   DWORD newrlim = GW_WIREFRAME/*|GW_Z_BUFFER*/;
#if VERSION_3DSMAX >= ((5000<<16)+(15<<8)+0) // Version 5+
   newrlim |= GW_EDGES_ONLY;
#endif
   gw->setRndLimits(newrlim);

   if (inode->Selected()) 
      gw->setColor( LINE_COLOR, GetSelColor());
   else if(!inode->IsFrozen() && !inode->Dependent())
      gw->setColor( LINE_COLOR, color);

   UpdateMesh(t);
   mesh.render( gw, mtl, NULL, COMP_ALL);	
   gw->setRndLimits(rlim);
   return 0;
}
示例#5
0
/*virtual*/ void WBCompEldMesh::Tick(float DeltaTime) {
  XTRACE_FUNCTION;

  UpdateMesh(DeltaTime);

  // Add pseudo root motion. Hack from Couriers.
  if (m_Mesh && m_Mesh->IsAnimated()) {
    Vector AnimationVelocity;
    Angles AnimationRotationalVelocity;
    GetAnimationVelocity(AnimationVelocity, AnimationRotationalVelocity);

    if (AnimationVelocity.LengthSquared() > 0.0f ||
        !AnimationRotationalVelocity.IsZero()) {
      WBCompEldTransform* pTransform =
          GetEntity()->GetTransformComponent<WBCompEldTransform>();
      DEVASSERT(pTransform);

      // Kill velocity in direction of movement.
      if (AnimationVelocity.LengthSquared() > 0.0f) {
        Plane MovementPlane(AnimationVelocity.GetNormalized(), 0.0f);
        pTransform->SetVelocity(
            MovementPlane.ProjectVector(pTransform->GetVelocity()));
      }

      pTransform->ApplyImpulse(AnimationVelocity);
      pTransform->ApplyRotationalImpulse(AnimationRotationalVelocity);
    }
  }
}
示例#6
0
int SimpleWSMObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
	{
	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}

	if (!OKtoDisplay(t)) return 0;
	GraphicsWindow *gw = vpt->getGW();	
	Matrix3 mat = inode->GetObjectTM(t);	 
	UpdateMesh(t);		
	gw->setTransform(mat);

	//mesh.render(gw, inode->Mtls(), 
	DWORD rlim  = gw->getRndLimits();
	
	gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|/*GW_BACKCULL|*/(rlim&GW_Z_BUFFER?GW_Z_BUFFER:0));
	if (inode->Selected()) 
		gw->setColor( LINE_COLOR, GetSelColor());
	else if(!inode->IsFrozen())
		//gw->setColor( LINE_COLOR, wsmMtl.Kd[0], wsmMtl.Kd[1], wsmMtl.Kd[2]);
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_SPACE_WARPS));

	mesh.render(gw, &wsmMtl, 
		(flags&USE_DAMAGE_RECT) ? &vpt->GetDammageRect() : NULL, COMP_ALL);
	
	gw->setRndLimits(rlim);
	return(0);
	}
示例#7
0
int LuminaireObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
{
	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}

	Matrix3 m;
	if (dumFlags&DISABLE_DISPLAY)
		return 0;
	GraphicsWindow *gw = vpt->getGW();
	Material *mtl = gw->getMaterial();
	m = inode->GetObjectTM(t);
	gw->setTransform(m);
	DWORD rlim = gw->getRndLimits();
	gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|GW_BACKCULL| (rlim&GW_Z_BUFFER) );
	if (inode->Selected()) 
		gw->setColor( LINE_COLOR, GetSelColor());
	else if(!inode->IsFrozen() && !inode->Dependent())
		gw->setColor( LINE_COLOR, color.x, color.y, color.z);

	UpdateMesh();
	mesh.render( gw, mtl, NULL, COMP_ALL);	
	gw->setRndLimits(rlim);
	return 0;
}
示例#8
0
void TetrahedronMesh::InitMesh()
{
  UpdateMesh();

  // Find min tet volume
  double minVol = std::numeric_limits<double>::max();
  for(int t=0;t<Tetrahedra->rows();t++)
  {
    Eigen::Vector3d A = InitalVertices->row(Tetrahedra->coeff(t,0)).cast<double>();
    Eigen::Vector3d B = InitalVertices->row(Tetrahedra->coeff(t,1)).cast<double>();
    Eigen::Vector3d C = InitalVertices->row(Tetrahedra->coeff(t,2)).cast<double>();
    Eigen::Vector3d D = InitalVertices->row(Tetrahedra->coeff(t,3)).cast<double>();

    Eigen::Vector3d a = A-D;
    Eigen::Vector3d b = B-D;
    Eigen::Vector3d c = C-D;

    double vol = a.dot(c.cross(b));

    if(vol < minVol)
      minVol = vol;
  }

  EPS1 = 10e-5;
  EPS3 = minVol*EPS1;
}
示例#9
0
void SimpleObject::GetWorldBoundBox(TimeValue t, INode *inode, ViewExp* /*vpt*/, Box3& box )
	{
	Matrix3 mat = inode->GetObjectTM(t);
	UpdateMesh(t);
	box = mesh.getBoundingBox();
	box = box * mat;
	}
//----------------------------------------------------------------------------
void FreeFormDeformation::DoRandomControlPoints ()
{
    // Randomly perturb the control points, but stay near the original
    // control points.
    Vector3f ctrl;
    for (int i0 = 0; i0 < mQuantity; i0++)
    {
        ctrl[0] = mXMin + mDX*i0;
        for (int i1 = 0; i1 < mQuantity; i1++)
        {
            ctrl[1] = mYMin + mDY*i1;
            for (int i2 = 0; i2 < mQuantity; i2++)
            {
                ctrl[2] = mZMin + mDZ*i2;

                Vector3f newCtrl = mVolume->GetControlPoint(i0, i1, i2) +
                    mAmplitude*Vector3f(Mathf::SymmetricRandom(),
                    Mathf::SymmetricRandom(),Mathf::SymmetricRandom());

                Vector3f diff = newCtrl - ctrl;
                float length = diff.Length();
                if (length > mRadius)
                {
                    diff *= mRadius/length;
                }

                mVolume->SetControlPoint(i0, i1, i2, ctrl + diff);
            }
        }
    }

    UpdateMesh();
    UpdatePolysegments();
    UpdateControlBoxes();
}
示例#11
0
void CMeter2DGraphView::valueFrameChanged()
{
   if( model() )
   {
      UpdateValueTitle();
      UpdateMesh();
   }
}
示例#12
0
void CMeter2DGraphView::timeFrameChanged()
{
   if( model() )
   {
      UpdateTimeTitle();
      UpdateMesh();
   }
}
示例#13
0
BOOL 
SimpleObject::PolygonCount(TimeValue t, int& numFaces, int& numVerts) 
{
    UpdateMesh(t);
    numFaces = mesh.getNumFaces();
    numVerts = mesh.getNumVerts();
    return TRUE;
}
示例#14
0
void LuminaireObject::GetWorldBoundBox(TimeValue t, INode *inode, ViewExp* vpt, Box3& abox )
{
	if (dumFlags&DISABLE_DISPLAY)
		return;
	Matrix3 mat = inode->GetObjectTM(t);
	UpdateMesh();
	abox = mesh.getBoundingBox();
	abox = abox * mat;
}
示例#15
0
void Wave::Update(float delta)
{
	m_Time += delta;

	if (m_Material && m_Material->m_DiffuseMap)
		m_Material->m_DiffuseMap->SetPosition(m_Time * 0.005, m_Time * 0.005);

	UpdateMesh();
}
示例#16
0
void FontString::Render()
{
    if(m_MeshNeedsUpdate)
        UpdateMesh();

    m_Material->Bind();
    m_Material->PrepareForRender();
    m_Mesh->Render();
    m_Material->UnBind();
}
示例#17
0
文件: simpobj.cpp 项目: 2asoft/xray
// From BaseObject
int SimpleObject::HitTest(TimeValue t, INode *inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt) 
	{
	Point2 pt( (float)p[0].x, (float)p[0].y );
	HitRegion hitRegion;
	GraphicsWindow *gw = vpt->getGW();	
	UpdateMesh(t);
	gw->setTransform(inode->GetObjectTM(t));
	MakeHitRegion(hitRegion, type, crossing, 4, p);
	return mesh.select(gw, inode->Mtls(), &hitRegion, flags & HIT_ABORTONHIT, inode->NumMtls());
	}
示例#18
0
文件: simpobj.cpp 项目: 2asoft/xray
void SimpleParticle::GetWorldBoundBox(TimeValue t, INode *inode, ViewExp* vpt, Box3& box )
	{
	Box3 pbox;
	Matrix3 mat = inode->GetObjTMBeforeWSM(t);	
	UpdateMesh(t);
	box  = mesh.getBoundingBox();
	box  = box * mat;
	pbox = parts.BoundBox();	
	if (!pbox.IsEmpty()) box += pbox;	
	}
void C4DefGraphicsPtrBackup::UpdateMesh(StdMeshInstance* instance)
{
	MeshMaterialUpdate.Update(instance);
	MeshAnimationUpdate.Update(instance);

	// Recursive for attached meshes not in object list
	for (StdMeshInstance::AttachedMeshIter iter = instance->AttachedMeshesBegin(); iter != instance->AttachedMeshesEnd(); ++iter)
		if ((*iter)->OwnChild)
			UpdateMesh((*iter)->Child);
}
示例#20
0
文件: simpobj.cpp 项目: 2asoft/xray
void SimpleWSMObject::Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt) 
	{
	if(TestAFlag(A_OBJ_CREATING))	// No snap to ourself while creating!
		return;

	Matrix3 tm = inode->GetObjectTM(t);
	GraphicsWindow *gw = vpt->getGW();
	UpdateMesh(t);
	gw->setTransform(tm);
	mesh.snap(gw, snap, p, tm);
	}
示例#21
0
文件: simpobj.cpp 项目: 2asoft/xray
int SimpleObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
	{
	if (!OKtoDisplay(t)) return 0;
	GraphicsWindow *gw = vpt->getGW();
	Matrix3 mat = inode->GetObjectTM(t);	 
	UpdateMesh(t);		
	gw->setTransform(mat);
	mesh.render(gw, inode->Mtls(), 
		(flags&USE_DAMAGE_RECT) ? &vpt->GetDammageRect() : NULL, COMP_ALL, inode->NumMtls());
	return(0);
	}
示例#22
0
void C4DefGraphicsPtrBackup::UpdateMeshes()
{
	// Update mesh materials for all meshes
	for(C4DefList::Table::iterator iter = Definitions.table.begin(); iter != Definitions.table.end(); ++iter)
		if(iter->second->Graphics.Type == C4DefGraphics::TYPE_Mesh)
			MeshMaterialUpdate.Update(iter->second->Graphics.Mesh);

	// Update mesh materials for all mesh instances.
	for (C4Object *pObj : Objects)
	{
		if (pObj && pObj->Status)
		{
			if(pObj->pMeshInstance)
				UpdateMesh(pObj->pMeshInstance);
			for (C4GraphicsOverlay* pGfxOverlay = pObj->pGfxOverlay; pGfxOverlay; pGfxOverlay = pGfxOverlay->GetNext())
				if(pGfxOverlay->pMeshInstance)
					UpdateMesh(pGfxOverlay->pMeshInstance);
		}
	}
}
示例#23
0
void LuminaireObject::Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt) 
{
	if (dumFlags&CREATING)	// If creating this one, don't try to snap to it!
		return;

	Matrix3 tm = inode->GetObjectTM(t);	
	GraphicsWindow *gw = vpt->getGW();	
	gw->setTransform(tm);

	UpdateMesh();
	mesh.snap( gw, snap, p, tm );
}
示例#24
0
文件: simpobj.cpp 项目: 2asoft/xray
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;
		}
	else
	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;
		}
	return Object::ConvertToType(t,obtype);
	}
示例#25
0
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;
}
示例#26
0
int LuminaireObject::HitTest(TimeValue t, INode *inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt) 
{
	HitRegion hitRegion;
	Matrix3 m;
	if (dumFlags&DISABLE_DISPLAY)
		return 0;
	GraphicsWindow *gw = vpt->getGW();
	DWORD rlim = gw->getRndLimits();
	gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|GW_BACKCULL);
	Material *mtl = gw->getMaterial();
	MakeHitRegion(hitRegion,type,crossing,4,p);	
	m = inode->GetObjectTM(t);
	gw->setTransform(m);
	UpdateMesh();
	int res =mesh.select( gw,mtl, &hitRegion, flags & HIT_ABORTONHIT );
	gw->setRndLimits(rlim);
	return res;
}
示例#27
0
// From BaseObject
int SimpleObject::HitTest(TimeValue t, INode *inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt) 
	{

	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}

	Point2 pt( (float)p[0].x, (float)p[0].y );
	HitRegion hitRegion;
	GraphicsWindow *gw = vpt->getGW();	
	UpdateMesh(t);
	gw->setTransform(inode->GetObjectTM(t));
	MakeHitRegion(hitRegion, type, crossing, 4, p);
	return mesh.select(gw, inode->Mtls(), &hitRegion, flags & HIT_ABORTONHIT, inode->NumMtls());
	}
示例#28
0
void LuminaireObject::Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt) 
{
	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return;
	}

	if (dumFlags&CREATING)	// If creating this one, don't try to snap to it!
		return;

	Matrix3 tm = inode->GetObjectTM(t);	
	GraphicsWindow *gw = vpt->getGW();	
	gw->setTransform(tm);

	UpdateMesh();
	mesh.snap( gw, snap, p, tm );
}
示例#29
0
void SimpleWSMObject::Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt) 
	{

	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return;
	}

	if(TestAFlag(A_OBJ_CREATING))	// No snap to ourself while creating!
		return;

	Matrix3 tm = inode->GetObjectTM(t);
	GraphicsWindow *gw = vpt->getGW();
	UpdateMesh(t);
	gw->setTransform(tm);
	mesh.snap(gw, snap, p, tm);
	}
示例#30
0
int SimpleObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
	{

	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}

	if (!OKtoDisplay(t)) return 0;
	GraphicsWindow *gw = vpt->getGW();
	Matrix3 mat = inode->GetObjectTM(t);	 
	UpdateMesh(t);		
	gw->setTransform(mat);
	mesh.render(gw, inode->Mtls(), 
		(flags&USE_DAMAGE_RECT) ? &vpt->GetDammageRect() : NULL, COMP_ALL, inode->NumMtls());
	return(0);
	}