Ejemplo n.º 1
0
Shape Shape::createShape(
	ShapeType type,
	float size /* = 1.0f */,
	float texturing /* = 2.0f */,
	int resolution /* = 16 */,
	float width /* = 0.0f */,
	float height /* = 0.0f */,
	float depth /* = 0.0f */)
{
	this->setSize(size);
	this->setResolution(resolution);

	switch (type)
	{
	case SPHERE:
		this->setVertices(createSphere(size, resolution, true));
		break;
	case PYRAMID:
		this->setVertices(createPyramid(size, texturing));
		break;
	case TETRAHEDRON:
		this->setVertices(createTetrahedron(size, texturing));
		break;
	case CUBOID:
		this->setVertices(createCuboid(size, width, height, depth, texturing));
		break;
	default:

		break;
	}

	this->setMesh(Mesh(this->m_vertices, this->m_vertices.size()));

	return *(this);
}
Ejemplo n.º 2
0
void ViewPort::Animate(int i) {
    m_xRotate = i;
    glDeleteLists(m_nPyramid, 1);
    m_nPyramid = createPyramid();

    updateGL();
}
CellBasedPyramidFeatureExtractor::CellBasedPyramidFeatureExtractor(
		int cellSize, int cols, int rows, int minWidth, int maxWidth, int octaveLayerCount) :
				DirectPyramidFeatureExtractor(createPyramid(cols * cellSize, minWidth, maxWidth, octaveLayerCount), cols, rows),
				cellSize(cellSize), realPatchWidth(cols * cellSize) {
	if (cellSize <= 0)
		throw invalid_argument("CellBasedPyramidFeatureExtractor: the cell size must be greater than zero");
	if (cols <= 0 || rows <= 0)
		throw invalid_argument("CellBasedPyramidFeatureExtractor: the amount of columns and rows must be greater than zero");
}
Ejemplo n.º 4
0
void readGeometry(scene_data* scene, const boost::property_tree::ptree& pt)
{
	boost::property_tree::ptree::const_iterator iter = pt.begin();
	for (; iter != pt.end(); ++iter)
	{
		std::string name = iter->first;
		geometry* geom;
		if (name == "cube")
			geom = createBox();
		else if (name == "tetrahedron")
			geom = createTetrahedron();
		else if (name == "pyramid")
			geom = createPyramid();
		else if (name == "disk")
		{
			int slices = iter->second.get_child("slices").get_value<int>();
			geom = createDisk(slices);
		}
		else if (name == "cylinder")
		{
			int slices = iter->second.get_child("slices").get_value<int>();
			int stacks = iter->second.get_child("stacks").get_value<int>();
			geom = createCylinder(stacks, slices);
		}
		else if (name == "sphere")
		{
			int slices = iter->second.get_child("slices").get_value<int>();
			int stacks = iter->second.get_child("stacks").get_value<int>();
			geom = createSphere(stacks, slices);
		}
		else if (name == "torus")
		{
			float radius = iter->second.get_child("radius").get_value<float>();
			int slices = iter->second.get_child("slices").get_value<int>();
			int stacks = iter->second.get_child("stacks").get_value<int>();
			geom = createTorus(radius, stacks, slices);
		}
		else if (name == "plane")
		{
			int width = iter->second.get_child("width").get_value<int>();
			int depth = iter->second.get_child("depth").get_value<int>();
			geom = createPlane(width, depth);
		}
		else if (name == "sierpinski")
		{
			int divisions = iter->second.get_child("divisions").get_value<int>();
			geom = createSierpinski(divisions);
		}
		else
		{
			std::cerr << "Error - Geometry type not recognised: " << name << std::endl;
			exit(EXIT_FAILURE);
		}
		scene->geometry[name] = geom;
	}
}
Ejemplo n.º 5
0
void	BenchmarkDemo::createTest2()
{
	setCameraDistance(btScalar(50.));
	const float cubeSize = 1.0f;

	createPyramid(btVector3(-20.0f,0.0f,0.0f),12,btVector3(cubeSize,cubeSize,cubeSize));
	createWall(btVector3(-2.0f,0.0f,0.0f),12,btVector3(cubeSize,cubeSize,cubeSize));
	createWall(btVector3(4.0f,0.0f,0.0f),12,btVector3(cubeSize,cubeSize,cubeSize));
	createWall(btVector3(10.0f,0.0f,0.0f),12,btVector3(cubeSize,cubeSize,cubeSize));
	createTowerCircle(btVector3(25.0f,0.0f,0.0f),8,24,btVector3(cubeSize,cubeSize,cubeSize));
	
}
Ejemplo n.º 6
0
void ViewPort::initializeGL()
{
    id_timer=startTimer(1);
    qglClearColor(Qt::black);
    glEnable(GL_DEPTH_TEST);
    glShadeModel(GL_SMOOTH);
    //glShadeModel(GL_FLAT);
    m_nPyramid = createPyramid();


    genTexture(); // создать текстуры
    glEnable(GL_TEXTURE_2D);

    // активизируем массив текстурных координат
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}
Ejemplo n.º 7
0
void FeatureGenerator::createVillage(int side, v2di_t cornerIndex, World& world) {
  // WARNING: relative to 0, 0
  int worldX = cornerIndex.x * WORLD_CHUNK_SIDE;
  int worldZ = cornerIndex.y * WORLD_CHUNK_SIDE;

  int width = side * WORLD_CHUNK_SIDE;

  height_info_t heightInfo = FeatureUtil::getHeightInfo(worldX, worldZ, width, width, world);

  //  FeatureUtil::loadWorldRegion( cornerIndex, side, world, false );

  RogueMap rogueMap;
  rogueMap.resize(side, side);

  for (int i = 0; i < 50; i++) {

    int buildingSide = 2;

    v2di_t corner;

    corner = rogueMap.random_room(ID_START + i, buildingSide, buildingSide);

    if (corner.x != 0) {
      corner = v2di_add(corner, cornerIndex);

      printf("feature at (%d, %d)\n", corner.x, corner.y);

      //      createPlain (corner, buildingSide, buildingSide, worldMap);

      createPyramid(buildingSide, corner, world);
      //      createBuilding2x2 (corner, worldMap);
    }
  }

  // roads?

}
Ejemplo n.º 8
0
int main_TestState(int argc, char** argv)
{

   osgViewer::Viewer viewer;

   // Declare a group to act as root node of a scene:
   osg::Group* root = new osg::Group();

   // Declare a box class (derived from shape class) instance
   // This constructor takes an osg::Vec3 to define the center
   //  and a float to define the height, width and depth.
   //  (an overloaded constructor allows you to specify unique
   //   height, width and height values.)
   osg::Box* unitCube = new osg::Box( osg::Vec3(0,0,0), 1.0f);
   unitCube->setDataVariance(osg::Object::DYNAMIC);

   // Declare an instance of the shape drawable class and initialize 
   //  it with the unitCube shape we created above.
   //  This class is derived from 'drawable' so instances of this
   //  class can be added to Geode instances.
   osg::ShapeDrawable* unitCubeDrawable = new osg::ShapeDrawable(unitCube);

   // Declare a instance of the geode class: 
   osg::Geode* basicShapesGeode = new osg::Geode();

   // Add the unit cube drawable to the geode:
   basicShapesGeode->addDrawable(unitCubeDrawable);

   // Add the goede to the scene:
   root->addChild(basicShapesGeode);

   osg::Sphere* unitSphere = new osg::Sphere( osg::Vec3(0,0,0), 1.0);
   osg::ShapeDrawable* unitSphereDrawable = new osg::ShapeDrawable(unitSphere);
   unitSphereDrawable->setColor( osg::Vec4(0.1, 0.1, 0.1, 0.1) );

   osg::PositionAttitudeTransform* unitSphereXForm = 
      new osg::PositionAttitudeTransform();
   unitSphereXForm->setPosition(osg::Vec3(3.0,0,0));

   osg::Geode* unitSphereGeode = new osg::Geode();
   root->addChild(unitSphereXForm);
   unitSphereXForm->addChild(unitSphereGeode);
   unitSphereGeode->addDrawable(unitSphereDrawable);

   osg::Geode* pyramidGeode = createPyramid();
   
   osg::PositionAttitudeTransform* pyramidXForm = 
      new osg::PositionAttitudeTransform();
   pyramidXForm->setPosition(osg::Vec3(0,-3.0,0));
   root->addChild(pyramidXForm);
   pyramidXForm->addChild(pyramidGeode);

   osg::Texture2D* KLN89FaceTexture = new osg::Texture2D;
   // protect from being optimized away as static state:
   KLN89FaceTexture->setDataVariance(osg::Object::DYNAMIC); 
   osg::Image* klnFace = osgDB::readImageFile("../NPS_Data/Textures/KLN89FaceB.tga");
   if (!klnFace)
   {
      std::cout << " couldn't find texture, quitting." << std::endl;
      return -1;
   }
   KLN89FaceTexture->setImage(klnFace);

   // Declare a state set for 'BLEND' texture mode
   osg::StateSet* blendStateSet = new osg::StateSet();

   // Declare a TexEnv instance, set the mode to 'BLEND'
   osg::TexEnv* blendTexEnv = new osg::TexEnv;
   blendTexEnv->setMode(osg::TexEnv::BLEND);

   // Turn the attribute of texture 0 'ON'
   blendStateSet->setTextureAttributeAndModes(0,KLN89FaceTexture,osg::StateAttribute::ON);
   // Set the texture texture environment for texture 0 to the 
   //  texture envirnoment we declared above:
   blendStateSet->setTextureAttribute(0,blendTexEnv);

   osg::StateSet* decalStateSet = new osg::StateSet();
   osg::TexEnv* decalTexEnv = new osg::TexEnv();
   decalTexEnv->setMode(osg::TexEnv::DECAL);

   decalStateSet->setTextureAttributeAndModes(0,KLN89FaceTexture,osg::StateAttribute::ON);
   decalStateSet->setTextureAttribute(0,decalTexEnv);

   root->setStateSet(blendStateSet);
   unitSphereGeode->setStateSet(decalStateSet);

   // OSG1 viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);
   viewer.setSceneData( root );
   viewer.setCameraManipulator(new osgGA::TrackballManipulator());
   viewer.realize();

   while( !viewer.done() )
   {
      viewer.frame();
   } 
   return 0;
}
Ejemplo n.º 9
0
int main(int argc, const char* argv[]){
  if(argc != 2)
    std::cout << "Please supply a starting width for pyramid\n"; 
  else
    createPyramid(argv);
}
Ejemplo n.º 10
0
void OGLPyramid::initializeGL() {
    qglClearColor(Qt::black);
    glEnable(GL_DEPTH_TEST);
    glShadeModel(GL_FLAT);
    m_nPyramid = createPyramid(1.2f);
}
Ejemplo n.º 11
0
void FeatureGenerator::createSetPieces(int xIndex, int zIndex, World& world, LoadScreen* loadScreen) {
  // this is the RogueMap used to place set pieces on the world
  RogueMap worldRogueMap;
  worldRogueMap.resize(ROGUE_W, ROGUE_H);
  worldRogueMap.clear();

  v2di_t mapIndex = v2di_v(xIndex, zIndex);

  loadScreen->draw(0, 6);

  // okay, let's get that WorldMap
  WorldMap &worldMap = *world.getWorldMap();

  for (int i = 0; i < 6; i++) {
    v2di_t corner;

    corner = worldRogueMap.random_room(ID_START + i, 8, 8);

    if (corner.x != 0) {
      corner = v2di_add(corner, mapIndex);
      printf("dungeon at (%d, %d)\n", corner.x, corner.y);
      DungeonFeature::createDungeon(corner, 3, world);
      //      createPlain (corner, 8, 8, worldMap);

      worldMap.swapOutToInactive();
    }
  }

  loadScreen->draw(1, 6);

  for (int i = 0; i < 1; i++) {
    v2di_t corner;

    int side = 8;

    corner = worldRogueMap.random_room(ID_START + i, side, side);

    if (corner.x != 0) {
      corner = v2di_add(corner, mapIndex);
      printf("great pyramid at (%d, %d)\n", corner.x, corner.y);
      FeatureUtil::loadWorldRegion(corner, side, world, false);
      createPyramid(side, corner, world);

      worldMap.swapOutToInactive();
    }
  }

  loadScreen->draw(2, 6);

  for (int i = 0; i < 1; i++) {
    v2di_t corner;

    int side = 16;

    corner = worldRogueMap.random_room(ID_START + i, side, side);

    if (corner.x != 0) {
      corner = v2di_add(corner, mapIndex);
      printf("village at (%d, %d)\n", corner.x, corner.y);
      createVillage(side, corner, world);

      //      createPlain (corner, side, side, worldMap);

      worldMap.swapOutToInactive();
    }
  }

  loadScreen->draw(3, 6);

  // hmmm
  for (int i = 0; i < 6; i++) {
    v2di_t corner;

    int side = 6;

    corner = worldRogueMap.random_room(ID_START + i, side, side);

    if (corner.x != 0) {
      corner = v2di_add(corner, mapIndex);
      printf("spiral garden at (%d, %d)\n", corner.x, corner.y);
      //      createPyramid (side, corner, worldMap);
      //      createPlain (corner, side, side, worldMap);

      FeatureUtil::loadWorldRegion(corner, side, world, false);

      //      height_info_t hI = getHeightInfo (corner.x * WORLD_CHUNK_SIDE, corner.y * WORLD_CHUNK_SIDE,
      //        side * WORLD_CHUNK_SIDE, side * WORLD_CHUNK_SIDE, worldMap);

      growSpiralGarden(corner, side, side, world);


      worldMap.swapOutToInactive();
    }
  }


  // CAVERNS
  for (int i = 0; i < 4; i++) {
    v2di_t corner;

    int side = 6;

    corner = worldRogueMap.random_room(ID_START + i, side, side);

    if (corner.x != 0) {
      corner = v2di_add(corner, mapIndex);
      printf("cavern system at (%d, %d)\n", corner.x, corner.y);

      FeatureUtil::loadWorldRegion(corner, side, world, false);

      drillCavern(corner, side, side, world);

      worldMap.swapOutToInactive();
    }
  }

  loadScreen->draw(4, 6);

  // castle?
  for (int i = 0; i < 1; i++) {
    v2di_t corner;

    int side = 8;

    corner = worldRogueMap.random_room(ID_START + i, side, side);

    if (corner.x != 0) {
      corner = v2di_add(corner, mapIndex);
      printf("castle at (%d, %d)\n", corner.x, corner.y);
      createPlain(corner, side, side, world);

      height_info_t hI = FeatureUtil::getHeightInfo(corner.x * WORLD_CHUNK_SIDE, corner.y * WORLD_CHUNK_SIDE,
        side * WORLD_CHUNK_SIDE, side * WORLD_CHUNK_SIDE, world);

      createCastle8x8(corner, world);

      worldMap.swapOutToInactive();
    }
  }

  loadScreen->draw(5, 6);

  for (int i = 0; i < 50; i++) {
    int side = 1;

    v2di_t corner;

    corner = worldRogueMap.random_room(ID_START + i, side, side);

    if (corner.x != 0) {
      corner = v2di_add(corner, mapIndex);

      height_info_t heightInfo = FeatureUtil::getHeightInfo(
        corner.x * WORLD_CHUNK_SIDE, corner.y * WORLD_CHUNK_SIDE,
        side * WORLD_CHUNK_SIDE, side * WORLD_CHUNK_SIDE, world);

      if (heightInfo.low > 2) {
        printf("house at (%d, %d)\n", corner.x, corner.y);

        createPlain(corner, side, side, world);

        createHouse(corner, world);
        //        createPlain (corner, 1, 1, worldMap);
        //        create1by1Tower (corner, worldMap);

        worldMap.swapOutToInactive();
      }
    }
  }

  loadScreen->draw(6, 6);
}