Пример #1
0
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;
}
Пример #2
0
void bhkListObject::BuildMesh(TimeValue t)
{
	extern void BuildBox(Mesh&mesh, float l, float w, float h);

	ivalid = FOREVER;	
	BuildBox(mesh, 10.0f, 10.0f, 10.0f);
}
Пример #3
0
void bhkProxyObject::BuildEmpty()
{
	BuildBox(mesh, 10.0f, 10.0f, 10.0f);
	proxyMesh.FreeAll();
	proxyPos = Point3::Origin;
	forceRedraw = true;
}
Пример #4
0
void bhkBoxObject::BuildMesh(TimeValue t)
{
	extern void BuildBox(Mesh&mesh, float l, float w, float h);

	float l, w, h;
	ivalid = FOREVER;	
	pblock2->GetValue(PB_LENGTH,t,l,ivalid);
	pblock2->GetValue(PB_WIDTH,t,w,ivalid);
	pblock2->GetValue(PB_HEIGHT,t,h,ivalid);
	BuildBox(mesh, (l * bhkScaleFactor * 2), (w * bhkScaleFactor * 2), (h * bhkScaleFactor * 2));
}
Пример #5
0
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;
}
Пример #6
0
/** precomputation for fastsum */
void fastsum_precompute(fastsum_plan *ths)
{
  int j,k,t;
  int n_total;
  ticks t0, t1;

  ths->MEASURE_TIME_t[0] = 0.0;
  ths->MEASURE_TIME_t[1] = 0.0;
  ths->MEASURE_TIME_t[2] = 0.0;
  ths->MEASURE_TIME_t[3] = 0.0;

#ifdef MEASURE_TIME
  t0 = getticks();
#endif


  if (ths->flags & NEARFIELD_BOXES)
  {
    BuildBox(ths);
  }
  else
  {
    /** sort source knots */
    BuildTree(ths->d,0,ths->x,ths->alpha,ths->N_total);
  }

#ifdef MEASURE_TIME
  t1 = getticks();
  ths->MEASURE_TIME_t[3] += nfft_elapsed_seconds(t1,t0);
#endif


#ifdef MEASURE_TIME
  t0 = getticks();
#endif
  /** precompute spline values for near field*/
  if (!(ths->flags & EXACT_NEARFIELD))
  {
    if (ths->d==1)
      #pragma omp parallel for default(shared) private(k)
      for (k=-ths->Ad/2-2; k <= ths->Ad/2+2; k++)
        ths->Add[k+ths->Ad/2+2] = regkern1(ths->k, ths->eps_I*(double)k/ths->Ad*2, ths->p, ths->kernel_param, ths->eps_I, ths->eps_B);
    else
      #pragma omp parallel for default(shared) private(k)
      for (k=0; k <= ths->Ad+2; k++)
        ths->Add[k] = regkern3(ths->k, ths->eps_I*(double)k/ths->Ad, ths->p, ths->kernel_param, ths->eps_I, ths->eps_B);
  }
#ifdef MEASURE_TIME
  t1 = getticks();
  ths->MEASURE_TIME_t[0] += nfft_elapsed_seconds(t1,t0);
#endif


#ifdef MEASURE_TIME
  t0 = getticks();
#endif
  /** init NFFT plan for transposed transform in first step*/
  for (k=0; k<ths->mv1.M_total; k++)
    for (t=0; t<ths->mv1.d; t++)
      ths->mv1.x[ths->mv1.d*k+t] = - ths->x[ths->mv1.d*k+t];  /* note the factor -1 for transposed transform instead of adjoint*/

  /** precompute psi, the entries of the matrix B */
  if(ths->mv1.nfft_flags & PRE_LIN_PSI)
    nfft_precompute_lin_psi(&(ths->mv1));

  if(ths->mv1.nfft_flags & PRE_PSI)
    nfft_precompute_psi(&(ths->mv1));

  if(ths->mv1.nfft_flags & PRE_FULL_PSI)
    nfft_precompute_full_psi(&(ths->mv1));
#ifdef MEASURE_TIME
  t1 = getticks();
  ths->MEASURE_TIME_t[1] += nfft_elapsed_seconds(t1,t0);
#endif

  /** init Fourier coefficients */
  for(k=0; k<ths->mv1.M_total;k++)
    ths->mv1.f[k] = ths->alpha[k];

#ifdef MEASURE_TIME
  t0 = getticks();
#endif
  /** init NFFT plan for transform in third step*/
  for (j=0; j<ths->mv2.M_total; j++)
    for (t=0; t<ths->mv2.d; t++)
      ths->mv2.x[ths->mv2.d*j+t] = - ths->y[ths->mv2.d*j+t];  /* note the factor -1 for conjugated transform instead of standard*/

  /** precompute psi, the entries of the matrix B */
  if(ths->mv2.nfft_flags & PRE_LIN_PSI)
    nfft_precompute_lin_psi(&(ths->mv2));

  if(ths->mv2.nfft_flags & PRE_PSI)
    nfft_precompute_psi(&(ths->mv2));

  if(ths->mv2.nfft_flags & PRE_FULL_PSI)
    nfft_precompute_full_psi(&(ths->mv2));
#ifdef MEASURE_TIME
  t1 = getticks();
  ths->MEASURE_TIME_t[2] += nfft_elapsed_seconds(t1,t0);
#endif


#ifdef MEASURE_TIME
  t0 = getticks();
#endif
  /** precompute Fourier coefficients of regularised kernel*/
  n_total = 1;
  for (t=0; t<ths->d; t++)
    n_total *= ths->n;

  #pragma omp parallel for default(shared) private(j,k,t)
  for (j=0; j<n_total; j++)
  {
    if (ths->d==1)
      ths->b[j] = regkern1(ths->k, (double)j / (ths->n) - 0.5, ths->p, ths->kernel_param, ths->eps_I, ths->eps_B)/n_total;
    else
    {
      k=j;
      ths->b[j]=0.0;
      for (t=0; t<ths->d; t++)
      {
        ths->b[j] += ((double)(k % (ths->n)) / (ths->n) - 0.5) * ((double)(k % (ths->n)) / (ths->n) - 0.5);
        k = k / (ths->n);
      }
      ths->b[j] = regkern3(ths->k, sqrt(ths->b[j]), ths->p, ths->kernel_param, ths->eps_I, ths->eps_B)/n_total;
    }
  }

  nfft_fftshift_complex(ths->b, ths->mv1.d, ths->mv1.N);
  fftw_execute(ths->fft_plan);
  nfft_fftshift_complex(ths->b, ths->mv1.d, ths->mv1.N);
#ifdef MEASURE_TIME
  t1 = getticks();
  ths->MEASURE_TIME_t[0] += nfft_elapsed_seconds(t1,t0);
#endif
}
//
//	Override the abstract Create function to make this
//	a real class.
//	Create works its way through the text in the scanner one
//	line at a time. Each line must contain a command and a set
//	of arguments. Create examines the command and then calls
//	on helper functions to do the right things with the arguments.
//
bool CGLAList::Create() {
	if (mScan == NULL) {	// Quit if there is no scanner
		return false;
	}
	// 
	//	Work through the file.
	//	Each line should begin with a command and then be
	//	followed by a set of numeric arguments.
	//
	Lexeme* cLex;
	CSymbol* cSym = NULL;
  bool finished = false;
	Start();
	while ((cLex = mScan->NextLex())->lex != LEof) {
    if (cLex->lex == LNewLine || cLex->lex==LSpace) continue;
		if (cLex->lex == LWord) {	// Hope we have a command
#ifdef DEBUG
eprintf("Word %s ", cLex->sVal);
wxLogMessage(gMsgBuff);
#endif
			cSym = gSymTab->LookUpWord(cLex->sVal);
			//
			//	Now read in the arguments.
			//
			int nArg = GetArgList();
#ifdef DEBUG
      eprintf("Found %d arguments",nArg);
      wxLogMessage(gMsgBuff);
				for (int ii = 0; ii < nArg; ++ii) {
          eprintf(" %f", gArguments[ii]);
          wxLogMessage(gMsgBuff);
				}
      wxLogMessage("\r\n");
#endif
			if (cSym != NULL) {
				//
				//	Found a valid command, dispatch a function
				//	to handle it.
				//
#ifdef DEBUG
        eprintf("matches symbol %d\r\n",cSym->mSym);
        wxLogMessage(gMsgBuff);
#endif
				switch (cSym->mSym) {
					case kGLColor:
						if (nArg >= 3) {
							GLfloat color[4];
							color[0] = gArguments[0];
							color[1] = gArguments[1];
							color[2] = gArguments[2];
							if (nArg > 3) {
								color[3] = gArguments[3];
							} else {
								color[3] = 1.0f;
							}
							glMaterialfv(GL_FRONT, GL_AMBIENT, color);
							glMaterialfv(GL_FRONT, GL_SPECULAR, color);
              glColor3fv(color);
						}
						break;

					case kGLPoint:
						if (nArg >= 3) {
							glBegin(GL_POINTS);
							glVertex3fv(gArguments);
							glEnd();
							mBounds->AddPoint3fv(&gArguments[0]);
						}
						break;

					case kGLTranslate:
						if (nArg >= 3) {
							glTranslatef(gArguments[0],gArguments[1],gArguments[2]);
						}
						break;

					case kGLLine:
						BuildLine(nArg);
						break;

					case kGLPolyLine:
						BuildPolyLine(nArg);
						break;

					case kGLSphere:
						BuildSphere(nArg);
						break;

					case kGLBox:
						BuildBox(nArg);
						break;

					case kGLTriangle:
						BuildTriangle(nArg);
						break;
            
          case kGLCylinder:
            BuildCylinder(nArg);
            break;

          case kGLCap:
            BuildCap(nArg);
            break;
            
          case kGLEnd:
            finished = true;
            break;
            
					default:
            eprintf("CGLAList.Create: Unimplemented GLA verb %s.\r\n", cSym->mName);
						break;
				}
			} else {
        eprintf("CGLAList.Create: %s is an unrecognised GLA verb.\r\n", cLex->sVal);
			}
		} else {	// Did not find a command
			//
			//	Print a message.
			//
      eprintf("CGLAList.Create: Cound not find a command on line %lu.\r\n", mScan->LineNumber());
      eprintf("%s", mScan->GetLine());
		}
    if (finished) break;
		//
		//	Eat tokens til we get to the
		//	end of the line (or a premature EOF)
		//
		while ((cLex = mScan->NextLex())->lex != LNewLine && cLex->lex != LEof);
		} // end while
	End();
	ReleaseScanner();
	return true;
}