Esempio n. 1
0
void GLWidget::draw2D(void)
{
    Vector<double> &X = pObj->GetX(),
                   &Y = pObj->GetY();
    Matrix<int>& FE = pObj->GetFE();
    int NumFE = FE.Size1(),
        SizeFE = (FE.Size2() > 4) ? 3 : FE.Size2(); // Для обработки квадратичных элементов
    double x0 = (maxX + minX) * 0.5,
           y0 = (maxY + minY) * 0.5;
    GLenum Val = (SizeFE == 3) ? GL_TRIANGLES : GL_QUADS;


    makeMaterial(0,1,0,1);
    glBegin(Val);
    glNormal3d(0,0,1);
    for (int i = 0; i < NumFE; i++)
        for (int j = 0; j < SizeFE; j++)
            glVertex2d(X[FE[i][j]] - x0, Y[FE[i][j]] - y0);
    glEnd();

    makeMaterial(0,0,0,1);
    for (int i = 0; i < NumFE; i++)
    {
        glBegin(GL_LINE_LOOP);
        for (int j = 0; j < SizeFE; j++)
            glVertex2d(X[FE[i][j]] - x0, Y[FE[i][j]] - y0);
        glEnd();
    }
}
Esempio n. 2
0
void GLWidget::draw1D(void)
{
    Vector<double> &X = pObj->GetX();
    Matrix<int>& FE = pObj->GetFE();
    int NumFE = FE.Size1(),
        NumVertex = X.Size(),
        SizeFE = (FE.Size2() > 2) ? 2 : FE.Size2(); // Для обработки квадратичных элементов
    double x0 = (maxX + minX) * 0.5,
           R = (maxX - minX) / NumFE / 20;

    makeMaterial(0,1,0,1);
    glBegin(GL_LINE_LOOP);
    glNormal3d(0,0,1);
    for (int i = 0; i < NumFE; i++)
        for (int j = 0; j < SizeFE; j++)
            glVertex2d(X[FE[i][j]] - x0, 0);
    glEnd();


    makeMaterial(1,0,0,1);
    for (int i = 0; i < NumVertex; i++)
    {
        glPushMatrix();
        glTranslatef(X[i] - x0,0,0);
        gluSphere(row,R,10,10);
        glPopMatrix();
    }
}
Esempio n. 3
0
/** Lazily init the material */
CC3Material* CC3MeshNode::getMaterial()
{
	if ( !_material ) 
		setMaterial( makeMaterial() );

	return _material;
}
Esempio n. 4
0
	void MyTexturedBox::init() {
		_physics.setPosition(3,1.01,3);
		_physics.setAngularVelocity(10.0);
		makeMaterial();
		makeTexture();
		makeModel();
	}
Esempio n. 5
0
void DivBoxLevel::generate() {
  this->sceneManager = sceneManager;

//  QSize siteResolution = document.geometry().size();
//  qDebug() << "Whole Page " << webpage->mainFrame()->geometry();
  setPageRendering(QSize(1440, 800));

  QWebElement page = webpage->mainFrame()->documentElement();
  makeOgreImage(&page, "skytex", 1);
  makeMaterial("skydome", "skytex", 0.7);
//  sceneManager->setSkyBox(true, "skyBox");
  sceneManager->setSkyDome(true, "skydome", 50, 2);

  std::vector<QString> tags;
  tags.push_back("div");
  tags.push_back("p");
  tags.push_back("img");
  tags.push_back("h2");
  tags.push_back("h1");
  tags.push_back("h3");
  tags.push_back("table");

  this->generateDoors();
  makeElementBoxes(
      page, .1, tags,
      "Cube.mesh", sceneManager);
}
Esempio n. 6
0
	void Munition::init() {
		
		_physics.setPosition(3,1.01,-3);
		_physics.setAngularVelocity(1000);
		_physics.setLinearVelocity(25);
		makeSphere();
		makeMunitionModel();
		makeMaterial();
	}
Esempio n. 7
0
void renInit(S_Renderer *pRenderer)
{
    IZG_ASSERT(pRenderer);

    /* frame buffer prozatim neni */
    pRenderer->frame_buffer = NULL;
    pRenderer->frame_w = 0;
    pRenderer->frame_h = 0;

    /* podobne take depth buffer */
    pRenderer->depth_buffer = NULL;
    pRenderer->max_depth = 1000.0;

    /* nastaveni pozice kamery */
    pRenderer->camera_dist = 1000;

    /* pocatecni nastaveni trackballu (natoceni a zoom sceny) */
    pRenderer->scene_rot_x = 0;
    pRenderer->scene_rot_y = 0;
    pRenderer->scene_move_z = -980;
    pRenderer->scene_move_x = 0;
    pRenderer->scene_move_y = 0;

    /* default material */
    pRenderer->mat_ambient = makeMaterial(0.8, 0.8, 0.8);
    pRenderer->mat_diffuse = makeMaterial(0.8, 0.8, 0.8);
    pRenderer->mat_specular = makeMaterial(0.8, 0.8, 0.8);

    /* default zdroj svetla */
    pRenderer->light_position  = makeCoords(3.0, -3.0, -pRenderer->camera_dist);
    pRenderer->light_ambient   = makeLight(0.2, 0.2, 0.2);
    pRenderer->light_diffuse   = makeLight(0.7, 0.7, 0.7);
    pRenderer->light_specular  = makeLight(0.7, 0.7, 0.7);

    /* nastaveni ukazatelu na fce */
    pRenderer->releaseFunc         = renRelease;
    pRenderer->createBuffersFunc   = renCreateBuffers;
    pRenderer->clearBuffersFunc    = renClearBuffers;
    pRenderer->projectTriangleFunc = renProjectTriangle;
    pRenderer->calcReflectanceFunc = renLambertianReflectance;
}
Esempio n. 8
0
void initScene () {
  pln1=	    makePlain(0.0, 1.0, 0.0, imageWidth/2.0);
  pln1->m = makeMaterial(0.40,0.35,0.42,0.0, 0.7,1.0,1.0,       0.6, 0.0);
  printf("Plain %.1fx + %.1fy + %.1fz + %.1f = 0\n",pln1->A,pln1->B,pln1->C,pln1->D);

  sph0 =    makeSphere(-2.5, -imageWidth/2.0+2.6,     -6.0,     1.4);
  sph0->m = makeMaterial(1.0,1.0,1.0,0.0,   1.0,1.0,1.0,        0.95, 0.0 );
 printf("Sphere at (%.2f,%.2f,%.2f) radius %.2f\n",sph0->c->x,sph0->c->y,sph0->c->z,sph0->r);

  sph2 =    makeSphere(2.0,   -imageWidth/2.0+0.6,    -4.4,     0.65);
  sph2->m = makeMaterial(1.0,0.75,0.0,0.0,   0.25,1.0,1.0,       0.60, 0.0);
 printf("Sphere at (%.2f,%.2f,%.2f) radius %.2f\n",sph2->c->x,sph2->c->y,sph2->c->z,sph2->r);

  cyl0 =    makeCylinder(0.0, -imageWidth/2.0+1.70,   -4.3,    0.8, 0.35, 0.22);
  cyl0->m = makeMaterial(0.7,0.7,0.7,0.0,   0.2,1.0,1.0,       0.0,0.0);
  printf("Cylinder at (%.2f,%.2f,%.2f) a=%.2f, b=%.2f\n",cyl0->c->x,cyl0->c->y,cyl0->c->z,cyl0->a,cyl0->b);

  sph1 =    makeSphere(0.0,   -imageWidth/2.0+1.54,   -3.40,     0.38);
  sph1->m = makeMaterial(0.75,0.2,0.15,0.3,  0.4,1.0,1.0,        0.0,0.0);
 printf("Sphere at (%.2f,%.2f,%.2f) radius %.2f\n",sph1->c->x,sph1->c->y,sph1->c->z,sph1->r);

  hyp0 =    makeHyperbol(0.0, -imageWidth/2.0+0.59 , -4.0,     1.2, 0.25,0.34,0.25);
  hyp0->m = makeMaterial(1.0,0.8,0.2,0.0,   0.5,1.0,1.0,        0.4,0.0);
  printf("Hyperboloid at (%.2f,%.2f,%.2f) a=%.2f, b=%.2f, c=%.2f\n",hyp0->center->x,hyp0->center->y,hyp0->center->z,hyp0->a,hyp0->b,hyp0->c);
}
Esempio n. 9
0
void GLWidget::draw3D(void)
{
    Vector<double> &X = pObj->GetX(),
                   &Y = pObj->GetY(),
                   &Z = pObj->GetZ();
    Matrix<int>& Faces = pObj->GetFaces();
    int NumFaces = Faces.Size1(),
        SizeFaces = (Faces.Size2() > 4) ? 3 : Faces.Size2(); // Для обработки квадратичных элементов
    double x0 = (maxX + minX) * 0.5,
           y0 = (maxY + minY) * 0.5,
           z0 = (maxZ + minZ) * 0.5;
    GLenum Val = (SizeFaces == 3) ? GL_TRIANGLES : GL_QUADS;


    glInitNames(); ///////////////


    makeMaterial(0,1,0,1);
    glBegin(Val);
    for (int i = 0; i < NumFaces; i++)
    {
        glPushName(i); ///////////////
        glNormal3d(Normal[i][0],Normal[i][1],Normal[i][2]);
        for (int j = 0; j < SizeFaces; j++)
            glVertex3d(X[Faces[i][j]] - x0, Y[Faces[i][j]] - y0, Z[Faces[i][j]] - z0);
        glPopName(); /////////////////
    }
    glEnd();

    makeMaterial(0,0,0,1);
    for (int i = 0; i < NumFaces; i++)
    {
        glBegin(GL_LINE_LOOP);
        for (int j = 0; j < SizeFaces; j++)
            glVertex3d(X[Faces[i][j]] - x0, Y[Faces[i][j]] - y0, Z[Faces[i][j]] - z0);
        glEnd();
    }
}
Esempio n. 10
0
RayCloudPlot::RayCloudPlot(QQuickItem *parent)
    : Plot3DBase(parent)
    , m_start(NDArrayTyped<float>({0}))
    , m_end(NDArrayTyped<float>({0}))
    , m_raycloud(new RayCloud())
    , m_linewidthParam(new QParameter("linewidth", 10.0f))
    , m_pixelSize(new QParameter("pixelSize", QVector2D(1.0, 1.0)))
{
    QMap<QString,QString> props;
    props.insert("start", "start");
    props.insert("end", "end");
    registerProperties(props);

//    entity()->addComponent(m_raycloud);
    entity()->addComponent(makeMaterial());

    connect(this, &QQuickItem::widthChanged, this, &RayCloudPlot::updatePixelSize);
    connect(this, &QQuickItem::heightChanged, this, &RayCloudPlot::updatePixelSize);
    updatePixelSize();
}
Esempio n. 11
0
NiTriBasedGeomRef Exporter::makeMesh(NiNodeRef &parent, Mtl *mtl, FaceGroup &grp, bool exportStrips)
{
	NiTriBasedGeomRef shape;
	NiTriBasedGeomDataRef data;

   //if (Exporter::mFixNormals) {
   //   FixNormals(grp.faces, grp.verts, grp.vnorms);
   //}

	if (exportStrips) {
      shape = new NiTriStrips();
      data = new NiTriStripsData(grp.faces, !mUseAlternateStripper);
	} else {
      shape = new NiTriShape();
      data = new NiTriShapeData(grp.faces);
	}

   if ( IsFallout3() || IsSkyrim() )
      shape->SetFlags( 14 );

   data->SetVertices(grp.verts);
   data->SetNormals(grp.vnorms);
   data->SetVertexIndices(grp.vidx);
   data->SetUVSetMap(grp.uvMapping);

   int nUVs = grp.uvs.size();
   if ( IsFallout3() || IsSkyrim() )
      nUVs = min(1, nUVs);
   data->SetUVSetCount(nUVs);
   for (int i =0;i<nUVs; ++i) {
	   data->SetUVSet(i, grp.uvs[i]);
   }

   //if (IsSkyrim() && grp.vcolors.size() == 0)
   //   grp.vcolors.resize(grp.verts.size(), Color4(1.0f,1.0f,1.0f,1.0f));

	if (mVertexColors && grp.vcolors.size() > 0)
	{
		bool allWhite = true;
		Color4 white(1.0f, 1.0f, 1.0f, 1.0f);
		for (int i=0,n=grp.vcolors.size();i<n; ++i) {
			if (white != grp.vcolors[i]) {
				allWhite = false; 
				break;
			}
		}
		if (!allWhite)
			data->SetVertexColors(grp.vcolors);
	}

	data->SetConsistencyFlags(CT_STATIC);
	shape->SetData(data);

   if (Exporter::mTangentAndBinormalExtraData && (Exporter::mNifVersionInt > VER_4_2_2_0))
   {
      // enable traditional tangents and binormals for non-oblivion meshes
      if ( !IsOblivion() && (Exporter::mNifVersionInt >= VER_10_0_1_0) )
         data->SetTspaceFlag( 0x01 );
	   shape->UpdateTangentSpace(Exporter::mTangentAndBinormalMethod);
   }

	parent->AddChild(DynamicCast<NiAVObject>(shape));

   NiAVObjectRef av(DynamicCast<NiAVObject>(shape));
   makeMaterial(av, mtl);
   shape->SetActiveMaterial(0);

	return shape;
}
Esempio n. 12
0
	void MyWorld::init() {
		_n = 100;
		_size.set(10.0,10.0);
		makeModel();
		makeMaterial();
	}
Esempio n. 13
0
	Spike::Spike(int x, int y, float blocksize, std::string id) : Obstacle(x, y, blocksize, id,0.1,0.3,0.3) {
		makeSpike();
		makeMaterial();
	}
Esempio n. 14
0
void DivBoxLevel::makeElementBoxes(
    const QWebElement &document,
    Ogre::Real scale,
    std::vector<QString> tags,
    Ogre::String meshName,
    Ogre::SceneManager * sceneManager) {

  DotSceneLoader* pDotSceneLoader = new DotSceneLoader();
  pDotSceneLoader->parseDotScene("papercraft_man_line_running.scene",
      "General", sceneManager, sceneManager->getRootSceneNode());
  delete pDotSceneLoader;

  Animation::Instance().animationStates.clear();
  Animation::Instance().init(sceneManager, "arm_left");
  Animation::Instance().init(sceneManager, "arm_right");
  Animation::Instance().init(sceneManager, "chest");
  Animation::Instance().init(sceneManager, "leg_left");
  Animation::Instance().init(sceneManager, "leg_right");
  Animation::Instance().init(sceneManager, "pants");

  QWebElementCollection elements;
  foreach(QString tag, tags)
    elements.append(document.findAll(tag));

  Ogre::Vector3 position = Ogre::Vector3(0.0, 1000.0, 0.0);

  int elementCount = 0;
  foreach(QWebElement element, elements) {
      if (fits(&element, 10, 4096)) {
        Ogre::String textureName =
            "PageTex"  + element.tagName().toStdString()
            + Ogre::StringConverter::toString(elementCount);

        Box box;
        box.width = element.geometry().width()*scale;
        box.height = element.geometry().height()*scale;

        box.sceneNode = sceneManager->createSceneNode(textureName);

        element.setStyleProperty("background-color", "white");

        Ogre::Entity* cube = sceneManager->createEntity(meshName);

        makeOgreImage(&element, textureName);
        Ogre::MaterialPtr material =
            makeMaterial("PageMat" + Ogre::StringConverter::toString(position),
            textureName, 1.3);
        cube->getSubEntity(1)->setMaterial(material);
        box.sceneNode->attachObject(cube);
        box.sceneNode->setScale(box.width, box.height, box.width);

        if (box.width > 50)
          bigBoxes.push_back(box);
        else if (box.width > 5)
          smallBoxes.push_back(box);

        elementCount++;
      }
  }

  int smallBoxIndex = 0;

  for (int i = 0; i < bigBoxes.size(); i++) {
    CollisionActor* actor = simulation->terrainFactory->createActor()
       ->addPoint(bigBoxes[i].width, bigBoxes[i].height)
       ->addPoint(-bigBoxes[i].width, -bigBoxes[i].height)
       ->createCollisionShape(CollisionShape2::DEF_AABB);

    if (i == 0) {
// FIRST PLANE-----------------------
      actor->teleport(100.0, 100.0);

      characterSceneNode = simulation->characterFactory->createActor()
          ->addPoint(4.0, 30.0)
          ->addPoint(-4.0, -10.0)
          ->createCollisionShape(CollisionShape2::DEF_CONVEX)
          ->teleport(100.0, bigBoxes[i].height * 2 + 200.0)
          ->sceneNode;

      Ogre::SceneNode* sn = sceneManager->getSceneNode("Armature");
      sceneManager->getRootSceneNode()->removeChild(sn);
      characterSceneNode->addChild(sn);
      sn->scale(0.4, 0.4, 0.4);
      sn->translate(0, 10, 0);
      sn->setOrientation(
          Ogre::Quaternion(Ogre::Degree(90.0), Ogre::Vector3::UNIT_Y));

    } else {
// FURTHER PLANES--------------------
      float lX = bigBoxes[i - 1].sceneNode->_getDerivedPosition().x;
      float lY = bigBoxes[i - 1].sceneNode->_getDerivedPosition().y;
      float lW = bigBoxes[i - 1].width;
      float lH = bigBoxes[i - 1].height;
      float cX = bigBoxes[i].sceneNode->_getDerivedPosition().x;
      float cY = bigBoxes[i].sceneNode->_getDerivedPosition().y;
      float cW = bigBoxes[i].width;
      float cH = bigBoxes[i].height;

      if (cH - lH > 50.0 && smallBoxes.size() - 1 - smallBoxIndex > 1) {
        // current is mutch higher then last
        actor->teleport(lX + lW + cW, 100.0);

        float sX = smallBoxes[smallBoxIndex].sceneNode->_getDerivedPosition().x;
        float sY = smallBoxes[smallBoxIndex].sceneNode->_getDerivedPosition().y;
        float sW = smallBoxes[smallBoxIndex].width;
        float sH = smallBoxes[smallBoxIndex].height;
        CollisionActor* hoverplane = simulation->hoverplaneFactory
            ->createActor()
            ->addPoint(sW, sH)
            ->addPoint(-sW, -sH)
            ->createCollisionShape(CollisionShape2::DEF_AABB);
        static_cast<Hoverplane*>(hoverplane)
                      ->setSpeed(0.2 + static_cast<float>
                  (static_cast<int>(lX * cX * cW) % 5) * 0.1)
            ->setPath(lX + lW - sW - 100.0, lY + lH - sH + 10.0,
                lX + lW - sW - 100.0, lY + lH - sH + cH - lH);
        hoverplane->sceneNode->addChild(smallBoxes[smallBoxIndex].sceneNode);
        smallBoxIndex++;
      } else {
        if (lH - cH > 50.0 && smallBoxes.size() - 1 - smallBoxIndex > 1) {
          actor->teleport(lX + lW + cW, 100.0);

          float sX = smallBoxes[smallBoxIndex].sceneNode->
              _getDerivedPosition().x;
          float sY = smallBoxes[smallBoxIndex].sceneNode->
              _getDerivedPosition().y;
          float sW = smallBoxes[smallBoxIndex].width;
          float sH = smallBoxes[smallBoxIndex].height;

          CollisionActor* hoverplane = simulation->hoverplaneFactory
              ->createActor()
              ->addPoint(sW, sH)
              ->addPoint(-sW, -sH)
              ->createCollisionShape(CollisionShape2::DEF_AABB);
          static_cast<Hoverplane*>(hoverplane)
                      ->setSpeed(0.2 + static_cast<float>
                  (static_cast<int>(lX * cX * cW) % 5) * 0.1)
              ->setPath(cX, cY + cH + sH + 10.0,
                  cX, cY + cH + sH + lH);
          hoverplane->sceneNode->addChild(smallBoxes[smallBoxIndex].sceneNode);
          smallBoxIndex++;
        } else {
          if (i%3 == 2 && smallBoxes.size() - 1 - smallBoxIndex > 3) {
            actor->teleport(lX + lW + cW +
                smallBoxes[smallBoxIndex].sceneNode
                ->_getDerivedPosition().x +
                smallBoxes[smallBoxIndex+1].sceneNode
                ->_getDerivedPosition().x +
                smallBoxes[smallBoxIndex+2].sceneNode
                ->_getDerivedPosition().x
                + 400.0,
                100.0);
            {
              float sX = smallBoxes[smallBoxIndex].sceneNode->
                  _getDerivedPosition().x;
              float sY = smallBoxes[smallBoxIndex].sceneNode->
                  _getDerivedPosition().y;
              float sW = smallBoxes[smallBoxIndex].width;
              float sH = smallBoxes[smallBoxIndex].height;
              CollisionActor* hoverplane = simulation->hoverplaneFactory
                  ->createActor()
                  ->addPoint(sW, sH)
                  ->addPoint(-sW, -sH)
                  ->createCollisionShape(CollisionShape2::DEF_AABB);
              static_cast<Hoverplane*>(hoverplane)
                      ->setSpeed(0.1 + static_cast<float>
                  (static_cast<int>(lX * cX * sW) % 5) * 0.1)
                  ->setPath(lX + lW + 100.0, lY + lH - sH,
                      lX + lW + 100.0, lY + lH + cH + 200.0);
              hoverplane->sceneNode
              ->addChild(smallBoxes[smallBoxIndex].sceneNode);
            }
            {
              float sX = smallBoxes[smallBoxIndex+1].sceneNode->
                  _getDerivedPosition().x;
              float sY = smallBoxes[smallBoxIndex+1].sceneNode->
                  _getDerivedPosition().y;
              float sW = smallBoxes[smallBoxIndex+1].width;
              float sH = smallBoxes[smallBoxIndex+1].height;
              CollisionActor* hoverplane = simulation->hoverplaneFactory
                  ->createActor()
                  ->addPoint(sW, sH)
                  ->addPoint(-sW, -sH)
                  ->createCollisionShape(CollisionShape2::DEF_AABB);
              static_cast<Hoverplane*>(hoverplane)
                      ->setSpeed(0.2 + static_cast<float>
                  (static_cast<int>(lX * cX * sW) % 5) * 0.1)
                  ->setPath(lX + lW + 200.0, lY + lH - sH,
                      lX + lW + 200.0, lY + lH + cH + 200.0);
              hoverplane->sceneNode
              ->addChild(smallBoxes[smallBoxIndex+1].sceneNode);
            }
            {
              float sX = smallBoxes[smallBoxIndex+2].sceneNode->
                  _getDerivedPosition().x;
              float sY = smallBoxes[smallBoxIndex+2].sceneNode->
                  _getDerivedPosition().y;
              float sW = smallBoxes[smallBoxIndex+2].width;
              float sH = smallBoxes[smallBoxIndex+2].height;
              CollisionActor* hoverplane = simulation->hoverplaneFactory
                  ->createActor()
                  ->addPoint(sW, sH)
                  ->addPoint(-sW, -sH)
                  ->createCollisionShape(CollisionShape2::DEF_AABB);
              static_cast<Hoverplane*>(hoverplane)
                  ->setSpeed(0.15 + static_cast<float>
              (static_cast<int>(lX * cX * sW) % 5) * 0.1)
                  ->setPath(lX + lW + 300.0, lY + lH - sH,
                      lX + lW + 300.0, lY + lH + cH + 200.0);
              hoverplane->sceneNode
              ->addChild(smallBoxes[smallBoxIndex+2].sceneNode);
            }

            smallBoxIndex += 3;
          } else {
            actor->teleport(lX + lW + cW + 100.0, 100.0);
          }
        }
      }
    }
    actor->sceneNode->addChild(bigBoxes[i].sceneNode);
    qDebug() << "dooors" << doors.size() << "\n\n";
    if ((i == (bigBoxes.size()-1) / 2 || i == bigBoxes.size()-1)
        && this->doors.size() >= 1) {
      CollisionActor* door;

      if (i == (bigBoxes.size()-1) / 2) {
        door = this->doors[0];
        qDebug() << "dooors0\n\n\n\n\n";
      } else {
        door = this->doors[0];
        qDebug() << "dooors1\n\n\n\n\n";
      }
      door
          ->addPoint(0.0, 0.0)
          ->addPoint(40., 60.)
          ->createCollisionShape(CollisionShape2::DEF_AABB)
          ->teleport(
              bigBoxes[i].sceneNode->_getDerivedPosition().x,
              bigBoxes[i].sceneNode->_getDerivedPosition().y
              + bigBoxes[i].height);

      Ogre::Entity* doorEntity = sceneManager->createEntity("door.mesh");
      door->sceneNode->attachObject(doorEntity);
      door->sceneNode->setScale(20, 30, 20);
      door->sceneNode->setOrientation(
              Ogre::Quaternion(Ogre::Degree(180.0), Ogre::Vector3::UNIT_Y));
    }
  }
}