Пример #1
0
ModelLoader::ModelLoader()
{
    _modelFunctions[Sphere] = BuildSphere;
    _modelFunctions[Cube] = BuildCube;
    _modelFunctions[Pyramid] = BuildPyramid;
    _modelFunctions[SquarePyramid] = BuildSquarePyramid;
    _modelFunctions[Icosahedron] = BuildIcosahedron;

    _default = new SimpleBufferObject(BuildSphere());
    _models[Sphere] = std::unique_ptr<SimpleBufferObject>(_default);
}
Пример #2
0
void bhkSphereObject::BuildMesh(TimeValue t)
{
   float radius; int segs; int smooth;
   float startAng = 0.0f;
   if (TestAFlag(A_PLUGIN1)) startAng = HALFPI;

   // Start the validity interval at forever and whittle it down.
   ivalid = FOREVER;
   pblock2->GetValue(PB_RADIUS, t, radius, ivalid);
   pblock2->GetValue(PB_SEGS, t, segs, ivalid);
   pblock2->GetValue(PB_SMOOTH, t, smooth, ivalid);
   BuildSphere(mesh, (radius * 7.0f), segs, smooth, startAng);
}
Пример #3
0
//-----------------------------------------------------------------------------
Ogre::MeshPtr TBuilderShape_Ogre::Build(TShapeItem* pShape)
{
  mMeshPtr.setNull();
  mShape = pShape;
  // выбрать из списка шаблон
  switch(mShape->mPtrGeometry->type)
  {
    case nsParamBuilderShape::Plate:
      BuildPlate();
      break;
    case nsParamBuilderShape::PlateVarGeom:
      BuildPlateVarGeom();
      break;
    case nsParamBuilderShape::Sphere:
      BuildSphere();
      break;
    case nsParamBuilderShape::Cone:
      BuildCone();
      break;
    case nsParamBuilderShape::Trapezium:
      BuildTrapezium();
      break;
    case nsParamBuilderShape::TriangularPyramid:
      BuildTriangularPyramid();
      break;
    case nsParamBuilderShape::QuadrangularPyramid:
      BuildQuadrangularPyramid();
      break;
    case nsParamBuilderShape::Cylinder:
      BuildCylinder();
      break;
    case nsParamBuilderShape::TriangularPrism:
      BuildTriangularPrism();
      break;
  }
  return mMeshPtr;
}
//
//	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;
}