예제 #1
0
Matrix3 plStaticEnvLayer::IGetViewTM( int i )
{
    Matrix3 m;
    m.IdentityMatrix();
    switch( i ) 
    {
        case kTopFace:
            m.RotateX( -M_PI );   
            break;
        case kBottomFace:
            break;
        case kLeftFace:
            m.RotateX( -.5f * M_PI ); 
            m.RotateY( -.5f * M_PI );
            break;
        case kRightFace:
            m.RotateX( -.5f * M_PI ); 
            m.RotateY( +.5f * M_PI );
            break;
        case kFrontFace:
            m.RotateX( -.5f * M_PI ); 
            m.RotateY( M_PI );
            break;
        case kBackFace:
            m.RotateX( -.5f * M_PI ); 
            break;
    }
    return m;
}
예제 #2
0
파일: stretch.cpp 프로젝트: 2asoft/xray
StretchDeformer::StretchDeformer(TimeValue t, ModContext &mc,
                                 float stretch, float amplify, int naxis, 
                                 float from, float to, int doRegion,
                                 Matrix3& modmat, Matrix3& modinv) 
{
    Matrix3 mat;
    Interval valid;     
//    if (from==to) doRegion = FALSE;
    this->doRegion = doRegion;
    this->from = from;
    this->to   = to;
    time   = t; 

    tm = modmat;
    invtm = modinv;
    mat.IdentityMatrix();
        
    switch ( naxis ) {
    case 0: mat.RotateY( -HALFPI );      break; //X
    case 1: mat.RotateX( HALFPI );  break; //Y
    case 2: break;  //Z
    }
    SetAxis( mat );     
    assert (mc.box);
    bbox = *mc.box;
    CalcBulge(naxis, stretch, amplify);
} 
예제 #3
0
파일: wind.cpp 프로젝트: artemeliy/inf4715
int WindObjCreateCallback::proc(
		ViewExp *vpt,int msg, int point, int flags, IPoint2 m, Matrix3& mat)
{
	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}

	if (msg==MOUSE_POINT||msg==MOUSE_MOVE) 
	{
#ifdef _3D_CREATE
		DWORD snapdim = SNAP_IN_3D;
#else
		DWORD snapdim = SNAP_IN_PLANE;
#endif
		switch(point) 
		{
			case 0:								
				sp0 = m;
				p0  = vpt->SnapPoint(m,m,NULL,snapdim);
				mat.SetTrans(p0);
				break;
			case 1:
				if (ob->ClassID()==Class_ID(GRAVITYOBJECT_CLASS_ID,0)) 
				{
					mat.IdentityMatrix();
					mat.RotateX(PI);
					mat.SetTrans(p0);
				}
				p1  = vpt->GetPointOnCP(m);
				ob->pblock2->SetValue(PB_DISPLENGTH,0,Length(p1-p0)/2.0f);
//				ob->pmapParam->Invalidate();
				wind_param_blk.InvalidateUI();
				if (msg==MOUSE_POINT) 
				{
					if (Length(m-sp0)<3) return CREATE_ABORT;
					else return CREATE_STOP;
				}
				break;
			}
	} 
	else 
	{
		if (msg == MOUSE_ABORT)	
		{
			return CREATE_ABORT;
		}
		else
		if (msg == MOUSE_FREEMOVE) 
		{
			vpt->SnapPreview(m,m);
		}
	}
	
	return TRUE;
}
예제 #4
0
파일: bend.cpp 프로젝트: 2asoft/xray
BendDeformer::BendDeformer(
		TimeValue t, ModContext &mc,
		float angle, float dir, int naxis, 
		float from, float to, int doRegion,
		Matrix3& modmat, Matrix3& modinv) 
	{	
	this->doRegion = doRegion;
	this->from = from;
	this->to   = to;
	Matrix3 mat;
	Interval valid;	
	time   = t;	

	tm = modmat;
	invtm = modinv;
	mat.IdentityMatrix();
	
	switch (naxis) {
		case 0: mat.RotateY( -HALFPI );	 break; //X
		case 1: mat.RotateX( HALFPI );  break; //Y
		case 2: break;  //Z
		}
	mat.RotateZ(DegToRad(dir));	
	SetAxis(mat);	
	assert (mc.box);
	bbox = *mc.box;
	CalcR(naxis,DegToRad(angle));
	
	// Turn this off for a sec.
	this->doRegion = FALSE;
		
	float len  = to-from;
	float rat1, rat2;
	if (len==0.0f) {
		rat1 = rat2 = 1.0f;
	} else {
		rat1 = to/len;
		rat2 = from/len;
		}
	Point3 pt;
	tmAbove.IdentityMatrix();
	tmAbove.Translate(Point3(0.0f,0.0f,-to));
	tmAbove.RotateY(DegToRad(angle * rat1));
	tmAbove.Translate(Point3(0.0f,0.0f,to));
	pt = Point3(0.0f,0.0f,to);
	tmAbove.Translate((Map(0,pt*invtm)*tm)-pt);

	tmBelow.IdentityMatrix();
	tmBelow.Translate(Point3(0.0f,0.0f,-from));
	tmBelow.RotateY(DegToRad(angle * rat2));	
	tmBelow.Translate(Point3(0.0f,0.0f,from));
	pt = Point3(0.0f,0.0f,from);
	tmBelow.Translate((Map(0,pt*invtm)*tm)-pt);	
	
	this->doRegion = doRegion;

	} 
void VRayCamera::buildMesh(void) {
  if (meshBuilt) return;

  int nverts = 16;
  int nfaces = 24;
  mesh.setNumVerts(nverts);
  mesh.setNumFaces(nfaces);
  float len = (float)5.0;
  float w = (float)8.0;
  float d = w*(float).8;
  float e = d*(float).5;
  float f = d*(float).8;
  float l = w*(float).8;

  mesh.setVert(0, Point3( -d, -d, -len));
  mesh.setVert(1, Point3(  d, -d, -len));
  mesh.setVert(2, Point3( -d,  d, -len));
  mesh.setVert(3, Point3(  d,  d, -len));
  mesh.setVert(4, Point3( -d, -d,  len));
  mesh.setVert(5, Point3(  d, -d,  len));
  mesh.setVert(6, Point3( -d,  d,  len));
  mesh.setVert(7, Point3(  d,  d,  len));
  MakeQuad(&(mesh.faces[ 0]), 0,2,3,1,  1);
  MakeQuad(&(mesh.faces[ 2]), 2,0,4,6,  2);
  MakeQuad(&(mesh.faces[ 4]), 3,2,6,7,  4);
  MakeQuad(&(mesh.faces[ 6]), 1,3,7,5,  8);
  MakeQuad(&(mesh.faces[ 8]), 0,1,5,4, 16);
  MakeQuad(&(mesh.faces[10]), 4,5,7,6, 32);

  mesh.setVert(8+0, Point3( -e, -e, len));
  mesh.setVert(8+1, Point3(  e, -e, len));
  mesh.setVert(8+2, Point3( -e,  e, len));
  mesh.setVert(8+3, Point3(  e,  e, len));
  mesh.setVert(8+4, Point3( -f, -f, len+l));
  mesh.setVert(8+5, Point3(  f, -f, len+l));
  mesh.setVert(8+6, Point3( -f,  f, len+l));
  mesh.setVert(8+7, Point3(  f,  f, len+l));

  Face* fbase = &mesh.faces[12];
  MakeQuad(&fbase[0], 0,2,3,1,  1, 8);
  MakeQuad(&fbase[2], 2,0,4,6,  2, 8);
  MakeQuad(&fbase[4], 3,2,6,7,  4, 8);
  MakeQuad(&fbase[6], 1,3,7,5,  8, 8);
  MakeQuad(&fbase[8], 0,1,5,4, 16, 8);
  MakeQuad(&fbase[10],4,5,7,6, 32, 8);

  // whoops- rotate 180 about x to get it facing the right way
  Matrix3 mat;
  mat.IdentityMatrix();
  mat.RotateX(DegToRad(180.0));
  for (int i=0; i<nverts; i++) mesh.getVert(i)=mat*mesh.getVert(i);
  mesh.buildNormals();
  mesh.EnableEdgeList(1);
  meshBuilt = true;
}
예제 #6
0
void ProtHelpObject::BuildMesh()
{
   if(meshBuilt)
      return;
   int nverts = 7;
   int nfaces = 8;
   mesh.setNumVerts(nverts);
   mesh.setNumFaces(nfaces);

   float d = 5.0f;
   float ds = 0.866f * d;
   float h = 2.0f * 0.866f * 5.0f;

   mesh.setVert(0, Point3(0.0f, 0.0f, 0.0f ));
   mesh.setVert(1, Point3(  -d,  -ds, -h ));
   mesh.setVert(2, Point3(   d,  -ds, -h ));
   mesh.setVert(3, Point3(0.0f,   ds, -h ));
   mesh.setVert(4, Point3(  -d,  -ds,  h ));
   mesh.setVert(5, Point3(   d,  -ds,  h ));
   mesh.setVert(6, Point3(0.0f,   ds,  h ));
   mesh.faces[0].setVerts(0, 1, 2);
   mesh.faces[0].setEdgeVisFlags(1,1,1);
   mesh.faces[1].setVerts(0, 2, 3);
   mesh.faces[1].setEdgeVisFlags(1,1,1);
   mesh.faces[2].setVerts(0, 3, 1);
   mesh.faces[2].setEdgeVisFlags(1,1,1);
   mesh.faces[3].setVerts(3, 2, 1);
   mesh.faces[3].setEdgeVisFlags(1,1,1);
   mesh.faces[4].setVerts(0, 5, 4);
   mesh.faces[4].setEdgeVisFlags(1,1,1);
   mesh.faces[5].setVerts(0, 6, 5);
   mesh.faces[5].setEdgeVisFlags(1,1,1);
   mesh.faces[6].setVerts(0, 4, 6);
   mesh.faces[6].setEdgeVisFlags(1,1,1);
   mesh.faces[7].setVerts(4, 5, 6);
   mesh.faces[7].setEdgeVisFlags(1,1,1);
#if 1
   // whoops- rotate 90 about x to get it facing the right way
   Matrix3 mat;
   mat.IdentityMatrix();
   mat.RotateX(DegToRad(90.0));
   for (int i=0; i<nverts; i++)
      mesh.getVert(i) = mat*mesh.getVert(i);
#endif
// mesh.buildNormals();
   meshBuilt = 1;
}
예제 #7
0
void TapeHelpObject::BuildMesh()
{
    if(meshBuilt)
        return;
    int nverts = 5;
    int nfaces = 6;
    mesh.setNumVerts(nverts);
    mesh.setNumFaces(nfaces);

    float d =  5.0f;
    float h = 10.0f;

    mesh.setVert(0, Point3(  -d, -d, 0.0f ));
    mesh.setVert(1, Point3(   d, -d, 0.0f ));
    mesh.setVert(2, Point3(   d,  d, 0.0f ));
    mesh.setVert(3, Point3(  -d,  d, 0.0f ));
    mesh.setVert(4, Point3(0.0f,0.0f, -h  ));
    mesh.faces[0].setVerts(0, 3, 1);
    mesh.faces[0].setEdgeVisFlags(1,1,0);
    mesh.faces[1].setVerts(3, 2, 1);
    mesh.faces[1].setEdgeVisFlags(1,1,0);
    mesh.faces[2].setVerts(0, 1, 4);
    mesh.faces[2].setEdgeVisFlags(1,1,1);
    mesh.faces[3].setVerts(1, 2, 4);
    mesh.faces[3].setEdgeVisFlags(1,1,1);
    mesh.faces[4].setVerts(2, 3, 4);
    mesh.faces[4].setEdgeVisFlags(1,1,1);
    mesh.faces[5].setVerts(3, 0, 4);
    mesh.faces[5].setEdgeVisFlags(1,1,1);
#if 0
    // whoops- rotate 180 about x to get it facing the right way
    Matrix3 mat;
    mat.IdentityMatrix();
    mat.RotateX(DegToRad(180.0));
    for (int i=0; i<nverts; i++)
        mesh.getVert(i) = mat*mesh.getVert(i);
#endif
    mesh.buildNormals();
    mesh.EnableEdgeList(1);
    meshBuilt = 1;
}
예제 #8
0
파일: twist.cpp 프로젝트: artemeliy/inf4715
TwistDeformer::TwistDeformer(
      TimeValue t, ModContext &mc,
      float angle, int naxis, float bias,
      float from, float to, int doRegion,
      Matrix3& modmat, Matrix3& modinv) 
   {  
   this->doRegion = doRegion;
   this->from = from;
   this->to   = to;
   if (bias!=0.0f) {
      this->bias = 1.0f-(bias+100.0f)/200.0f;
      if (this->bias < 0.00001f) this->bias = 0.00001f;
      if (this->bias > 0.99999f) this->bias = 0.99999f;
      this->bias = float(log(this->bias)/log(0.5));
      doBias = TRUE;
   } else {
      this->bias = 1.0f;
      doBias = FALSE;
      }
   
   Matrix3 mat;
   Interval valid;   
   time   = t; 

   tm = modmat;
   invtm = modinv;
   mat.IdentityMatrix();
   
   switch ( naxis ) {
      case 0: mat.RotateY( -HALFPI );   break; //X
      case 1: mat.RotateX( HALFPI );  break; //Y
      case 2: break;  //Z
      }
   SetAxis( mat );   
   assert (mc.box);
   bbox = *mc.box;
   CalcHeight(naxis,DegToRad(angle));
   }
예제 #9
0
파일: skew.cpp 프로젝트: 2asoft/xray
SkewDeformer::SkewDeformer(
		ModContext &mc,
		float amount, float dir, int naxis, 
		float from, float to, int doRegion,
		Matrix3& modmat, Matrix3& modinv) 
	{	
	this->doRegion = doRegion;
	this->from = from;
	this->to   = to;
	Matrix3 mat;
	
	mat.IdentityMatrix();	
	switch (naxis) {
		case 0: mat.RotateY( -HALFPI );	 break; //X
		case 1: mat.RotateX( HALFPI );  break; //Y
		case 2: break;  //Z
		}
	mat.RotateZ(DegToRad(dir));		
	tm    = modmat * mat;
	invtm = Inverse(mat) * modinv;
	
	assert (mc.box);
	bbox = *mc.box;
	
	float len = 0.0f;
	if (!doRegion) {
		switch (naxis) {
			case 0:  len = bbox.pmax.x - bbox.pmin.x; break;
			case 1:	 len = bbox.pmax.y - bbox.pmin.y; break;
			case 2:  len = bbox.pmax.z - bbox.pmin.z; break;
			}
	} else {
		len = to-from;
		}		
	if (len==0.0f) len = 0.000001f;
	amountOverLength = amount/len;
	}