Esempio n. 1
0
GLuint GLWidget::makeObject()
{
    GLuint list = glGenLists(1);
    glNewList(list, GL_COMPILE);

    glBegin(GL_QUADS);

    GLdouble x1 = +0.06;
    GLdouble y1 = -0.14;
    GLdouble x2 = +0.14;
    GLdouble y2 = -0.06;
    GLdouble x3 = +0.08;
    GLdouble y3 = +0.00;
    GLdouble x4 = +0.30;
    GLdouble y4 = +0.22;

    quad(x1, y1, x2, y2, y2, x2, y1, x1);
    quad(x3, y3, x4, y4, y4, x4, y3, x3);

    extrude(x1, y1, x2, y2);
    extrude(x2, y2, y2, x2);
    extrude(y2, x2, y1, x1);
    extrude(y1, x1, x1, y1);
    extrude(x3, y3, x4, y4);
    extrude(x4, y4, y4, x4);
    extrude(y4, x4, y3, x3);

    const double Pi = 3.14159265358979323846;
    const int NumSectors = 200;

    for (int i = 0; i < NumSectors; ++i) {
        double angle1 = (i * 2 * Pi) / NumSectors;
        GLdouble x5 = 0.30 * sin(angle1);
        GLdouble y5 = 0.30 * cos(angle1);
        GLdouble x6 = 0.20 * sin(angle1);
        GLdouble y6 = 0.20 * cos(angle1);

        double angle2 = ((i + 1) * 2 * Pi) / NumSectors;
        GLdouble x7 = 0.20 * sin(angle2);
        GLdouble y7 = 0.20 * cos(angle2);
        GLdouble x8 = 0.30 * sin(angle2);
        GLdouble y8 = 0.30 * cos(angle2);

        quad(x5, y5, x6, y6, x7, y7, x8, y8);

        extrude(x6, y6, x7, y7);
        extrude(x8, y8, x5, y5);
    }

    glEnd();

    glEndList();
    return list;
}
Esempio n. 2
0
double quad(double left, double right, double fleft, double fright, double lrarea) {
  double mid, fmid, larea, rarea;
  
  mid = (left + right) / 2;
  fmid = F(mid);
  larea = (fleft + fmid) * (mid - left) / 2;
  rarea = (fmid + fright) * (right - mid) / 2;
  if( fabs((larea + rarea) - lrarea) > EPSILON ) {
    larea = quad(left, mid, fleft, fmid, larea);
    rarea = quad(mid, right, fmid, fright, rarea);
  }
  return (larea + rarea);
}
Esempio n. 3
0
void Renderer::createGeometry()
{
    vertices.clear();
    normals.clear();

    qreal x1 = +0.06f;
    qreal y1 = -0.14f;
    qreal x2 = +0.14f;
    qreal y2 = -0.06f;
    qreal x3 = +0.08f;
    qreal y3 = +0.00f;
    qreal x4 = +0.30f;
    qreal y4 = +0.22f;

    quad(x1, y1, x2, y2, y2, x2, y1, x1);
    quad(x3, y3, x4, y4, y4, x4, y3, x3);

    extrude(x1, y1, x2, y2);
    extrude(x2, y2, y2, x2);
    extrude(y2, x2, y1, x1);
    extrude(y1, x1, x1, y1);
    extrude(x3, y3, x4, y4);
    extrude(x4, y4, y4, x4);
    extrude(y4, x4, y3, x3);

    const qreal Pi = 3.14159f;
    const int NumSectors = 100;

    for (int i = 0; i < NumSectors; ++i) {
        qreal angle1 = (i * 2 * Pi) / NumSectors;
        qreal x5 = 0.30 * sin(angle1);
        qreal y5 = 0.30 * cos(angle1);
        qreal x6 = 0.20 * sin(angle1);
        qreal y6 = 0.20 * cos(angle1);

        qreal angle2 = ((i + 1) * 2 * Pi) / NumSectors;
        qreal x7 = 0.20 * sin(angle2);
        qreal y7 = 0.20 * cos(angle2);
        qreal x8 = 0.30 * sin(angle2);
        qreal y8 = 0.30 * cos(angle2);

        quad(x5, y5, x6, y6, x7, y7, x8, y8);

        extrude(x6, y6, x7, y7);
        extrude(x8, y8, x5, y5);
    }

    for (int i = 0;i < vertices.size();i++)
        vertices[i] *= 2.0f;
}
Esempio n. 4
0
void BaseWalls(trix_mesh *mwhite, trix_mesh *mblack, trix_vertex *v, int x, int y, int w, int h) {
	
	// west
	if (x == 0) {
		quad(mwhite, &v[17], &v[21], &v[18], &v[14]);
		quad(mblack, &v[0], &v[17], &v[14], &v[1]);
	}
	
	// east
	if (x + 1 == w) {
		quad(mwhite, &v[15], &v[19], &v[20], &v[16]);
		quad(mblack, &v[4], &v[15], &v[16], &v[5]);
	}
	
	// north
	if (y == 0) {
		
		tri(mwhite, &v[17], &v[29], &v[21]);
		tri(mwhite, &v[29], &v[20], &v[21]);
		tri(mwhite, &v[16], &v[20], &v[29]);
		
		quad(mblack, &v[0], &v[27], &v[29], &v[17]);
		quad(mblack, &v[27], &v[5], &v[16], &v[29]);
	}
	
	// south
	if (y + 1 == h) {
		tri(mwhite, &v[14], &v[18], &v[28]);
		tri(mwhite, &v[28], &v[18], &v[19]);
		tri(mwhite, &v[15], &v[28], &v[19]);
		
		quad(mblack, &v[1], &v[14], &v[28], &v[26]);
		quad(mblack, &v[28], &v[15], &v[4], &v[26]);
	}
}
Esempio n. 5
0
/**
 * Tranforms points from cartesian to cylindric coordinates
 */
void transformCylindric(struct system *System)
{
	point tmpPoint; // Temporary point to transform coordinates

	for (uint_fast32_t i = 0; i < System->numPoints; i++)
	{
		tmpPoint = System->points[i];

		tmpPoint.x = sqrt(quad(System->points[i].x) + quad(System->points[i].y));
		tmpPoint.y = atan2(System->points[i].y, System->points[i].x);

		System->points[i] = tmpPoint;
	}
}
Logo::Logo()
    : m_count(0)
{
    m_data.resize(2500 * 6);

    const GLfloat x1 = +0.06f;
    const GLfloat y1 = -0.14f;
    const GLfloat x2 = +0.14f;
    const GLfloat y2 = -0.06f;
    const GLfloat x3 = +0.08f;
    const GLfloat y3 = +0.00f;
    const GLfloat x4 = +0.30f;
    const GLfloat y4 = +0.22f;

    quad(x1, y1, x2, y2, y2, x2, y1, x1);
    quad(x3, y3, x4, y4, y4, x4, y3, x3);

    extrude(x1, y1, x2, y2);
    extrude(x2, y2, y2, x2);
    extrude(y2, x2, y1, x1);
    extrude(y1, x1, x1, y1);
    extrude(x3, y3, x4, y4);
    extrude(x4, y4, y4, x4);
    extrude(y4, x4, y3, x3);

    const int NumSectors = 100;

    for (int i = 0; i < NumSectors; ++i) {
        GLfloat angle = (i * 2 * M_PI) / NumSectors;
        GLfloat angleSin = qSin(angle);
        GLfloat angleCos = qCos(angle);
        const GLfloat x5 = 0.30f * angleSin;
        const GLfloat y5 = 0.30f * angleCos;
        const GLfloat x6 = 0.20f * angleSin;
        const GLfloat y6 = 0.20f * angleCos;

        angle = ((i + 1) * 2 * M_PI) / NumSectors;
        angleSin = qSin(angle);
        angleCos = qCos(angle);
        const GLfloat x7 = 0.20f * angleSin;
        const GLfloat y7 = 0.20f * angleCos;
        const GLfloat x8 = 0.30f * angleSin;
        const GLfloat y8 = 0.30f * angleCos;

        quad(x5, y5, x6, y6, x7, y7, x8, y8);

        extrude(x6, y6, x7, y7);
        extrude(x8, y8, x5, y5);
    }
}
Esempio n. 7
0
double 
mue(double beta, double p) {

  double temp,result;
  double gama;
  
  gama = 1 + 2*quad(beta);
  /* temp = 1 + (p*quad(beta))/gama + (p*(p+2)*qquad(beta))/(2*quad(gama)); */
  temp = 1 + (p*quad(beta))/gama + (p*(p+2)*pow(beta,4))/(2*quad(gama));
  
  result = 1 - pow(gama, -(p/2.0))*temp; 

  return result;
  
}
bool ExternalPopupMenu::showInternal()
{
    // Blink core reuses the PopupMenu of an element.  For simplicity, we do
    // recreate the actual external popup everytime.
    if (m_webExternalPopupMenu) {
        m_webExternalPopupMenu->close();
        m_webExternalPopupMenu = 0;
    }

    WebPopupMenuInfo info;
    getPopupMenuInfo(info, *m_ownerElement);
    if (info.items.isEmpty())
        return false;
    WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(m_localFrame.get());
    m_webExternalPopupMenu = webframe->client()->createExternalPopupMenu(info, this);
    if (m_webExternalPopupMenu) {
        LayoutObject* layoutObject = m_ownerElement->layoutObject();
        if (!layoutObject || !layoutObject->isBox())
            return false;
        FloatQuad quad(toLayoutBox(layoutObject)->localToAbsoluteQuad(FloatQuad(toLayoutBox(layoutObject)->borderBoundingBox())));
        IntRect rect(quad.enclosingBoundingBox());
        IntRect rectInViewport = m_localFrame->view()->soonToBeRemovedContentsToUnscaledViewport(rect);
        // TODO(tkent): If the anchor rectangle is not visible, we should not
        // show a popup.
        m_webExternalPopupMenu->show(rectInViewport);
        m_shownDOMTreeVersion = m_ownerElement->document().domTreeVersion();
        return true;
    } else {
        // The client might refuse to create a popup (when there is already one pending to be shown for example).
        didCancel();
        return false;
    }
}
Esempio n. 9
0
/** 
 * Transforms points back from prolate spheroidal to cylindric coordinates
 */
void retransformSpheroidal(struct tip *Tip)
{
	point tmpPoint; // Temporary point to transform coordinates

	for (uint_fast32_t i = 0; i < Tip->numPoints; i++)
	{
		tmpPoint = Tip->points[i];

		tmpPoint.x = Tip->a * sqrt((quad(Tip->points[i].x) - 1) *
		                           (1 - quad(Tip->points[i].z)));
		tmpPoint.y = Tip->points[i].y;
		tmpPoint.z = Tip->a * Tip->points[i].x * Tip->points[i].z;

		Tip->points[i] = tmpPoint;
	}
}
Esempio n. 10
0
JQuadPtr WCachedTexture::GetQuad(float offX, float offY, float width, float height, const string& resname)
{
    if (!texture) return JQuadPtr();

    if (width == 0.0f || width > static_cast<float> (texture->mWidth)) width = static_cast<float> (texture->mWidth);
    if (height == 0.0f || height > static_cast<float> (texture->mHeight)) height = static_cast<float> (texture->mHeight);

    // If we're fetching a card resource, but it's not available yet, we'll be attempting to get the Quad from the temporary back image.
    // If that's the case, don't stash a separate tracked quad entry for each card name in the the Back/BackThumbnail's resource
    string resource(resname);
    if (mFilename == kGenericCard || mFilename == kGenericThumbCard)
    {
        // if we're the back or thumb_back file, but we've been asked for a card ID, then assign it
        // a placeholder ID.  Reason being, hotspots on quads are different (ie centered) for card images, so we'll store a separate quad for cards 
        if (resname != kGenericCardID && resname != kGenericCardThumbnailID)
            resource = kPlaceholderID;
    }

	std::map<string, JQuadPtr>::iterator iter = mTrackedQuads.find(resource);
	if (iter != mTrackedQuads.end())
		return iter->second;

	JQuadPtr quad(NEW JQuad(texture, offX, offY, width, height));

    //Update JQ's values to what we called this with.
    quad->SetTextureRect(offX, offY, width, height);
	mTrackedQuads.insert(std::pair<string, JQuadPtr>(resource, quad));
    return quad;

}
Esempio n. 11
0
// -----------------------------------------------------------------
// Name : withHoverGeometry
// -----------------------------------------------------------------
Button * Button::withHoverGeometry(ITexture * pTex, IGeometryQuads * pGeo)
{
    m_pGeometryHover = pGeo;
    QuadData quad(0, m_iWidth, 0, m_iHeight, pTex);
    pGeo->build(&quad);
	return this;
}
TEST_F(GeneratorsBenchmark, benchmarkHyperbolicGeneratorWithSequentialQuadtree) {
	count n = 100000;
	double s = 1.0;
	double alpha = 1;

	vector<double> angles(n);
	vector<double> radii(n);
	HyperbolicSpace::fillPoints(angles, radii, s, alpha);
	double R = s*HyperbolicSpace::hyperbolicAreaToRadius(n);
	double r = HyperbolicSpace::hyperbolicRadiusToEuclidean(R);
	Quadtree<index> quad(r);

	for (index i = 0; i < n; i++) {
		quad.addContent(i, angles[i], radii[i]);
	}

	angles.clear();
	radii.clear();

	quad.trim();
	quad.sortPointsInLeaves();
	quad.reindex();
	quad.extractCoordinates(angles, radii);

	HyperbolicGenerator gen;
	Graph G = gen.generate(angles, radii, quad, R);

	EXPECT_EQ(n, G.numberOfNodes());
}
Esempio n. 13
0
//int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow)
int main(int _argc, char** _argv)
{
	EEDesc desc;
	desc.applicationName = L"Emerald";	//窗口名称
	desc.isFullScreen = false;			//是否全屏
	desc.width = 800;					//窗口宽度
	desc.height = 450;					//窗口高度
	desc.isSSAA = true;					//是开启抗锯齿
	desc.isVsync = false;				//是否垂直同步
	EEInitialize();

	EETexture tex0(L"Texture\\etc\\101087.jpg");
	EETexture tex1(L"Texture\\etc\\xmyrz.jpg");
	//EETexture bgTex(L"Texture\\test3.gif");

	//EETexture bgTex(L"Texture\\Project Diva Freedom\\主界面\\默认主题\\背景.jpg");
	EEQuad2D quad(Rect_Float(0, 0, (float)EEGetWidth(), (float)EEGetHeight()), tex1);
	EEContrastAndBrightC cb(tex1);
	cb.SetContrast(200.f);
	cb.SetBright(0.1f);

	while (EERun())
	{
		EEBeginScene(EEColor::BLACK);

		quad.Process();

		printf("%d ", EEGetFPS());
		EEEndScene();
	}

	EEShutdown();
	return 0;
}
Esempio n. 14
0
int main(void)
{
  InitPeripherals();
//  if (InitBatteryMonitorHardware()) {
//    mBlueON;
//  }
  EnablePWM();
  
  mRedON;
  mGreenOFF;
  mBlueOFF;
  mYellowOFF;
  
  //  hardware devices
  UsbInterface usb;
  ZigbeeInterface zig;
  MPU6050 imu(MPU6050_ADDRESS);
  
  //  initialize IMU
  imu.setCommDelay(50);   //  50usec delay when trying reads
  imu.setCommRetries(3);  //  try at most 3 times before bailing
    
  //  instantiate the main object
  Quadrotor quad(QUAD_ID, &imu, &usb, &zig);
  quad.init();
  mRedOFF;

  //  enter main run loop, blocks forever
  quad.run();
  return 0;
}
Esempio n. 15
0
Nebula::Nebula()
{	
//nebula functionality currently only implemented for windows
//TODO: port for non windows functionality
#ifdef _WIN32	
	const unsigned int num_quads = 12;
	

	std::tr1::mt19937 eng;  
	std::tr1::normal_distribution<float> dist(0, 0.25f);  

	std::vector<Texture> textures;
	std::vector<std::string> nebula_files = Directory::GetFiles( root_assets_path + "/assets/nebula" );
	for( unsigned int i = 0; i < nebula_files.size(); i++ )
		textures.push_back( Texture( nebula_files[i] ) );

	for( unsigned int i = 0; i < num_quads; i++ )
	{
		const float random_angle = (float)(rand() % 360);
		//GeoVector random_rotation_axis( (float)(rand() % 1000), (float)(rand() % 1000), (float)(rand() % 1000) );
		GeoVector random_rotation_axis( 0, 1, 0 );
		random_rotation_axis.Normalize();
		
		RenderableObject quad( textures[rand() % textures.size()], GeometryFactory().GenerateXYUnitSquare() );
		quad.RotateInObjectspace( random_rotation_axis.ToXMFloat3(), random_angle );
		//quad.Scale( 1 + dist(eng), 1 + dist(eng), 1 + dist(eng) );
		quad.Translate( 0, 0, 2 );
		quad.Translate( dist(eng), dist(eng), dist(eng) );
		quad.SetTechnique( "AdditiveParticle" );
		quads.push_back( quad );
	}
#endif
}
Esempio n. 16
0
void MENU_render()
{


	glPushMatrix();	
	glLoadIdentity();
		
	glTranslatef(0.0f,0.0f, -40.0f);

	glPushMatrix();	
	glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
	glTranslatef(-menu_x-board_x*0.125f, 0.0f,  0.0f);
	glScalef(board_x*0.75f, board_y, 1.0f);
	quad();	
	glPopMatrix();
	
	if(game_state == INTRO)
	{
		font_printf_guay(-menu_x-board_x*0.14f - 10.0f,3.3f,-4.f,4.3f,"Cubyshot");
		font_printf_guay(-menu_x-board_x*0.14f - 10.0f,0.8f,-4.f,1.8f,"press fire button to play!");
	}
	else if(game_state == DEAD)
	{
		font_printf_guay(-menu_x-board_x*0.14f - 10.0f,3.3f,-4.f,4.3f,"you are dead");
		font_printf_guay(-menu_x-board_x*0.14f - 10.0f,0.8f,-4.f,1.8f,"press fire button to restart!");
		font_printf_guay(-menu_x-board_x*0.14f - 10.0f,-1.8f,-4.f,1.8f,"your score: %d",pj_score);

		
	}
	else if(game_state == PAUSE)
	{
		font_printf_guay(-menu_x-board_x*0.14f - 10.0f,3.3f,-4.f,4.3f,"Pause");
	}
	else if(game_state == INTER_LEVEL)
	{
		font_printf_guay(-menu_x-board_x*0.14f - 10.0f,3.3f,-4.f,4.3f,"LEVEL");
		font_printf_guay(-menu_x-board_x*0.14f - 10.0f,-1.3f,-4.f,4.3f,"COMPLETED");
		font_printf_guay(-menu_x-board_x*0.14f - 10.0f,-5.8f,-4.f,1.8f,"press enter to next level");
	
	}

	font_printf_guay(-0.5f*board_x,-board_y*.5f,-4.f,2.3f,"score: %d", pj_score);

	if(final_boss != 0)
	{
		//boss life bar
		glPushMatrix();
		float life_max = board_x*0.75f;
		float life = final_boss->life*life_max;
		glTranslatef(life*0.5f - board_x*0.40f, board_y*0.45f,  0.0f);
		glScalef(life*0.5f, 0.2f, 0.2f);
		cube_w();
		glPopMatrix();

	}
	
	glPopMatrix();


}
void FaceSpatializeIndexed<BasicTraits>::CategoryRaw::addData (OpenSGFaceBase<OpenSGTraits>* node, const FaceIterator& face)
{
   GeoPositions3f::StoredFieldType*  p = m_coord->getFieldPtr();
   GeoNormals3f::StoredFieldType*    n = m_normal->getFieldPtr();
   //GeoIndicesUI32::StoredFieldType*  i = m_index->getFieldPtr();

   // find offset of positions and normals in the new geometry
   u32 i, k;
   m_offsetIt = m_offset.find(face.getGeometry());
   if (m_offsetIt == m_offset.end()) {
      // insert new offsets entry into map
      HashMapPair offsetPair = 
	m_offset.insert(HashMap::value_type(face.getGeometry(), quad()));
      m_offsetIt = offsetPair.first;

      m_offsetIt->second.position = m_coord->size();
      GeoPositionsPtr faceP = m_original.getPositions();
      addRefCP(faceP);
      for (k=0; k<faceP->getSize(); ++k) {
	 p->addValue(faceP->getValue(k));
      }
      if (m_hasNormal) {
 	 m_offsetIt->second.normal = m_normal->size();
	 GeoNormalsPtr faceN = m_original.getNormals();
	 addRefCP(faceN);
	 for (k=0; k<faceN->getSize(); ++k) {
	    n->addValue(faceN->getValue(k));
	 }
	 subRefCP(faceN);
      }
      subRefCP(faceP);
   }

   // insert indices
   if (face.getLength() == 3) {
      for (k=0; k<3; ++k) {
	 m_index->insertValue(face.getPositionIndex(k)+m_offsetIt->second.position, m_quadOffset++);
	 i = 1;
	 if (m_hasNormal) {
	    m_index->insertValue(face.getNormalIndex(k)+m_offsetIt->second.normal,     m_quadOffset++);
	    ++i;
	 }
	 for (; i<m_indexStride; ++i) {
	    m_index->insertValue(0, m_quadOffset++);
	 }
      }
   } else {
      for (k=0; k<4; ++k) {
	 m_index->addValue(face.getPositionIndex(k)+m_offsetIt->second.position);
	 i = 1;
	 if (m_hasNormal) {
	    m_index->addValue(face.getNormalIndex(k)+m_offsetIt->second.normal);
	    ++i;
	 }
	 for (; i<m_indexStride; ++i) {
	    m_index->addValue(0);
	 }
      }
   }
}
Esempio n. 18
0
File: Image.cpp Progetto: jotak/jogy
// -----------------------------------------------------------------
// Name : withGeometry
// -----------------------------------------------------------------
Image * Image::withGeometry(ITexture * pTex, IGeometryQuads * pGeo)
{
    m_pGeometry = pGeo;
    QuadData quad(0, m_iWidth, 0, m_iHeight, pTex);
    pGeo->build(&quad);
	return this;
}
Esempio n. 19
0
// -----------------------------------------------------------------
// Name : attachImage
// -----------------------------------------------------------------
void Button::attachImage(ITexture * pTex, IGeometryQuads * pImageGeo)
{
	FREE(m_pGeometryAttachedImage);
	QuadData quad(0, m_iWidth, 0, m_iHeight, pTex);
	m_pGeometryAttachedImage = pImageGeo;
	m_pGeometryAttachedImage->build(&quad);
}
Esempio n. 20
0
int main( int argc, char **argv ) {
    QApplication a( argc, argv );
    OctreeNode n1;
    GLWidget *w = new GLWidget();
    GLData* g = w->addObject();
    
    GLData* rnd = w->addObject();
    RandomSource src( rnd );
    QObject::connect( w->timer, SIGNAL(timeout()), &src, SLOT(timeOutSlot()) );
    
    std::cout << " genVBO()\n";
    /*
    g->setTriangles(); 
    g->setPosition(1,0,-6);
    g->setUsageStaticDraw();
    g->addVertex(-1.0f,-1.0f, 0.0f,  1.0f,0.0f,0.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) ); 
    g->addVertex( 1.0f,-1.0f, 0.0f,  0.0f,1.0f,0.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    g->addVertex( 0.0f, 1.0f, 0.0f,  0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    g->addVertex( 1.0f, 1.0f, 0.0f,  1.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    g->addVertex( -1.0f, 1.0f, 0.0f,  1.0f,1.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    g->addVertex( -2.0f, 0.0f, 0.0f,  1.0f,1.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    std::vector<GLuint> poly(3);
    //poly.resize(3);
    poly[0]=0; poly[1]=1; poly[2]=2;
    g->addPolygon( poly );
    poly[0]=2; poly[1]=1; poly[2]=3;
    g->addPolygon( poly );
    poly[0]=0; poly[1]=2; poly[2]=4;
    g->addPolygon( poly );
    poly[0]=0; poly[1]=5; poly[2]=4;
    g->addPolygon( poly );
    g->print();
    //std::cout << "removePolygon()\n";
    //g.removePolygon(0);
    std::cout << "removeVertex(4)\n";
    g->removeVertex(4);
    g->print();
*/
    // now try a quad.
    OctreeNode n2;
    GLData* q = w->addObject();
    q->setQuads();
    q->setPosition(2,0,-6);
    q->setUsageStaticDraw(); 
    q->addVertex(-3.0f,0.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
    q->addVertex(-3.0f,1.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
    q->addVertex(-4.0f,1.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
    q->addVertex(-4.0f,0.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
    std::vector<GLuint> quad(4);
    quad[0]=0; quad[1]=1; quad[2]=2; quad[3]=3;
    q->addPolygon(quad);
    
    q->print();
    std::cout << "Q removeVertex(3)\n";
    //q->removeVertex(0);
    q->print();
    
    w->show();
    return a.exec();
}
Esempio n. 21
0
void Bezier::constructQuads(float numdiv) {
	bezQuads.clear();
	bezQuads.reserve((numdiv)*(numdiv));
	quadNum = 0;

	int pos1, pos2, pos3, pos4;
	int position;
	for (int u = 0; u < numdiv-1; u++) {
		for (int v = 0; v < numdiv-1; v++) {
			pos1 = u*numdiv + v;
			pos2 = u*numdiv + v + 1; 
			pos3 = (u+1)*numdiv + v + 1;
			pos4 = (u+1)*numdiv + v;  //Points stored c-clockwise position

			Point p1 = bezPoints[pos1]; std::cout << p1.getValues()[0] << " " << p1.getValues()[1] << " " << p1.getValues()[2] << "\n";
			Point p2 = bezPoints[pos2]; std::cout << p2.getValues()[0] << " " << p2.getValues()[1] << " " << p2.getValues()[2] << "\n";
			Point p3 = bezPoints[pos3]; std::cout << p3.getValues()[0] << " " << p3.getValues()[1] << " " << p3.getValues()[2] << "\n";
			Point p4 = bezPoints[pos4]; std::cout << p4.getValues()[0] << " " << p4.getValues()[1] << " " << p4.getValues()[2] << "\n";

			Quad quad(bezPoints[pos1],bezPoints[pos2],bezPoints[pos3],bezPoints[pos4]); std::cout << "ax\n";
			bezQuads.push_back(quad); std::cout << "bx\n";
			quadNum++; std::cout << "cx\n";	
		}
	}
}
Esempio n. 22
0
Console::Position Console::print(float x, float y, const char *text, bool measure) {
	unsigned passes;
	float xstart = x;
	Position ret = std::make_pair(-100.0f, 100.0f);
	if(!measure) {
		effect->SetTexture(textTex2DHandle, fontTex);
		effect->Begin(&passes, 0);
		effect->BeginPass(1);
	}
	while(*text) {
		if(*text >= 32 && *text < 128) {
			stbtt_aligned_quad q;
			stbtt_GetBakedQuad(cdata, BMPSIZE, BMPSIZE, *text - 32, &x, &y, &q, 1); // 1=opengl, 0=old d3d
			if(!measure) {
				quad(q);
			}
			ret.first = max(ret.first, q.x0/width - 1.0f);
			ret.second = min(ret.second, -q.y0/height + 1.0f);
		}
		if(*text == '\n') {
			y += 38.0f;
			x = xstart;
		}
		++text;
	}
	if(!measure) {
		effect->EndPass();
		effect->End();
	}
	return ret;
}
Esempio n. 23
0
  void test_case_lots_of_garbage(entity root)
  {
    auto& a = *application;
    auto sw = a.renderer.screen_width;
    auto sh = a.renderer.screen_height;
    const int size = 32.0f;

    auto root_tsh = a.transform_system.link(root, transform(v2(sw / 2, sh / 2), v2(0.0f), v2(0.5f, 0.5f)));
    a.solid_quads.link(root, quad(v2(64.0f, 64.0f), 0xffffff, v2(0.0f, 0.0f)), root_tsh);
    std::vector<transform_system::handle> children;
    children.push_back(root_tsh);
    std::vector<transform_system::handle> new_children;
    int total_children = 0;
    // 15 2 1.7ms
    // 4 16 = ~69k 2.1ms
    // 1 65000 1.7ms
    // 16 2
    for (int i = 0; i < 4; i++) {
      for (auto& n : children) {
        for (int j = 0; j < 16; j++) {
          total_children++;
          auto t = a.entity_system.make();
          auto t_tsh = a.transform_system.link(
              t
            , transform(
                  random_range(v2(-sw / 2, -sh / 2), v2(sw / 2, sh / 2)) / (i + 1)
                  , v2(random_range(0.0f, 3.1415f))
                  , v2(1.0f, 1.0f) / (float)(sqrt(i + 1.0f)))
            , n);
          a.solid_quads.link(
            t
            , quad(
            random_range(v2(size / 2.0f, size / 2.0f), v2(size, size))
            , 0x00FFFFFF & 0xfdf << (i * 3) | 0x44000000
            , v2(0.5f, 0.5f))
            , t_tsh);
          new_children.push_back(t_tsh);

          //t->color = (uint8_t)(i / 72.0f * 255) << 24 | 0x0000ff | 0xFF << i*3;
        }
      }
      children = new_children;
      new_children.clear();
    }
    children.clear();
    printf("total nodes: %d\n", total_children + 1);
  }
Esempio n. 24
0
void Mesh::setQuad(int quadIndex, int v0, int v1, int v2, int v3)
{
	int *o = quad(quadIndex);
	o[0] = v0;
	o[1] = v1;
	o[2] = v2;
	o[3] = v3;
}
Esempio n. 25
0
File: Gauge.cpp Progetto: jotak/jogy
// -----------------------------------------------------------------
// Name : rebuildGeometries
// -----------------------------------------------------------------
void Gauge::rebuildGeometries()
{
    QuadData quad(0, m_iWidth, 0, m_iHeight, m_pBackgroundGeometry->getTexture());
    m_pBackgroundGeometry->build(&quad);
    int fgw = max(1, m_iWidth * m_iCurValue / m_iRefValue);
    QuadData quad2(0, fgw, 0, m_iHeight, m_pForegroundGeometry->getTexture());
    m_pForegroundGeometry->build(&quad2);
}
Esempio n. 26
0
double
calc_crit_value(double beta, double p, double value) {

  double fac1, fac2;
  double result;
  
  double m = mue (beta, p);
  double s = sigma (beta,p);

  fac1 = m * pow ((1+(quad(s)/quad(m))),-0.5);
  fac2 = exp (value * sqrt (log (1+ (s/m))));

  result = fac1 * fac2;
  
  return result;
  
}
Esempio n. 27
0
    void gameplayhud(int w, int h)
    {
        glPushMatrix();
        glScalef(0.5f, 0.5f, 1);
        draw_textf("using: %s", 636*2, h*2-256+149, selected ? selected->name : "(none)");       // temp     
        glPopMatrix();

        settexture("packages/hud/hud_rpg.png", 3);
        
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        quad(0, h-128, 768, 128);        
        settexture("packages/hud/hbar.png", 3);
        glColor4f(1, 0, 0, 0.5f);
        quad(130, h-128+57, 193*playerobj->s_hp/playerobj->eff_maxhp(), 17);        
        glColor4f(0, 0, 1, 0.5f);
        quad(130, h-128+87, 193*playerobj->s_mana/playerobj->eff_maxmana(), 17);        
    }
  void QuadMesh::interpolate(const RTCInterpolateArguments* const args)
  {
    unsigned int primID = args->primID;
    float u = args->u;
    float v = args->v;
    RTCBufferType bufferType = args->bufferType;
    unsigned int bufferSlot = args->bufferSlot;
    float* P = args->P;
    float* dPdu = args->dPdu;
    float* dPdv = args->dPdv;
    float* ddPdudu = args->ddPdudu;
    float* ddPdvdv = args->ddPdvdv;
    float* ddPdudv = args->ddPdudv;
    unsigned int valueCount = args->valueCount;

    /* calculate base pointer and stride */
    assert((bufferType == RTC_BUFFER_TYPE_VERTEX && bufferSlot < numTimeSteps) ||
           (bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE && bufferSlot <= vertexAttribs.size()));
    const char* src = nullptr; 
    size_t stride = 0;
    if (bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE) {
      src    = vertexAttribs[bufferSlot].getPtr();
      stride = vertexAttribs[bufferSlot].getStride();
    } else {
      src    = vertices[bufferSlot].getPtr();
      stride = vertices[bufferSlot].getStride();
    }

    for (unsigned int i=0; i<valueCount; i+=4)
    {
      const vbool4 valid = vint4((int)i)+vint4(step) < vint4(int(valueCount));
      const size_t ofs = i*sizeof(float);
      const Quad& tri = quad(primID);
      const vfloat4 p0 = vfloat4::loadu(valid,(float*)&src[tri.v[0]*stride+ofs]);
      const vfloat4 p1 = vfloat4::loadu(valid,(float*)&src[tri.v[1]*stride+ofs]);
      const vfloat4 p2 = vfloat4::loadu(valid,(float*)&src[tri.v[2]*stride+ofs]);
      const vfloat4 p3 = vfloat4::loadu(valid,(float*)&src[tri.v[3]*stride+ofs]);      
      const vbool4 left = u+v <= 1.0f;
      const vfloat4 Q0 = select(left,p0,p2);
      const vfloat4 Q1 = select(left,p1,p3);
      const vfloat4 Q2 = select(left,p3,p1);
      const vfloat4 U  = select(left,u,vfloat4(1.0f)-u);
      const vfloat4 V  = select(left,v,vfloat4(1.0f)-v);
      const vfloat4 W  = 1.0f-U-V;
      if (P) {
        vfloat4::storeu(valid,P+i,madd(W,Q0,madd(U,Q1,V*Q2)));
      }
      if (dPdu) { 
        assert(dPdu); vfloat4::storeu(valid,dPdu+i,select(left,Q1-Q0,Q0-Q1));
        assert(dPdv); vfloat4::storeu(valid,dPdv+i,select(left,Q2-Q0,Q0-Q2));
      }
      if (ddPdudu) { 
        assert(ddPdudu); vfloat4::storeu(valid,ddPdudu+i,vfloat4(zero));
        assert(ddPdvdv); vfloat4::storeu(valid,ddPdvdv+i,vfloat4(zero));
        assert(ddPdudv); vfloat4::storeu(valid,ddPdudv+i,vfloat4(zero));
      }
    }
  }
Esempio n. 29
0
	void test01_quad() {
		GaussLobattoIntegrator quad(1024, 0, 1e-5f);
		size_t evals;
		Float result = quad.integrate(boost::bind(
			&TestQuadrature::testF, this, _1), 0, 10, &evals);
		Float ref = 2 * std::pow(std::sin((Float) 5.0f), (Float) 2.0f);
		Log(EInfo, "test01_quad(): used " SIZE_T_FMT " function evaluations", evals);
		assertEqualsEpsilon(result, ref, 1e-5f);
	}
Esempio n. 30
0
static
void * worker(void * arg)
{
    struct quad_args        * quad_args = (struct quad_args *)arg;

    quad_args->lrarea = quad(quad_args->left, quad_args->right, quad_args->fleft, quad_args->fright, quad_args->lrarea);

    return quad_args;
}