예제 #1
0
void    FloorTri::read_0001     ( Iff & iff )
{
	ConnectedTri::read_0000(iff);

	setNormal( iff.read_floatVector() );

	setCrossable( 0, iff.read_bool8() );
	setCrossable( 1, iff.read_bool8() );
	setCrossable( 2, iff.read_bool8() );

	setFallthrough( iff.read_bool8() );

    setPartTag( iff.read_int32() );

    setPortalId( 0, iff.read_int32() );
    setPortalId( 1, iff.read_int32() );
    setPortalId( 2, iff.read_int32() );
}
예제 #2
0
파일: Surface.cpp 프로젝트: jefferis/rgl
void Surface::renderZSort(RenderContext* renderContext)
{
  std::multimap<float,int> distanceMap;
  for (int ix = 0 ; ix < nx-1 ; ++ix ) {
    for (int iz = 0 ; iz < nz-1 ; ++iz ) {
      float distance = renderContext->getDistance( getCenter(ix, iz) );
      distanceMap.insert( std::pair<float,int>(-distance,iz*nx + ix) );
    }
  }

  material.beginUse(renderContext);
  vertexArray.beginUse();

  bool use_texcoord = material.texture && !(material.texture->is_envmap() );
  bool use_normal   = material.lit || ( (material.texture) && (material.texture->is_envmap() ) );

  if (use_texcoord)
    texCoordArray.beginUse();

  for ( std::multimap<float,int>::iterator iter = distanceMap.begin(); iter != distanceMap.end() ; ++ iter ) {
    glBegin(GL_QUAD_STRIP);
    for (int i = 0 ; i < 2; ++i ) {
      int ix = iter->second % nx + i;
      for (int j = 0 ; j < 2; ++j ) {
        int iz;
        if (orientation)
          iz = iter->second / nx + !j;
        else
          iz = iter->second / nx + j;
        if (use_normal)
          setNormal(ix, iz);
        glArrayElement( iz*nx + ix );       
      }
    }
    glEnd();
  }  

  if (use_texcoord)
    texCoordArray.endUse();

  vertexArray.endUse();

  material.endUse(renderContext);
}
예제 #3
0
ofxPlane::ofxPlane(ofxLine3d line0, ofxLine3d line1){
	if(!line0.isInit() || !line1.isInit()){
		initialized = false;
	}
	else{
		ofPoint pts[4];
		pts[0] = line0.pt;
		pts[1] = line1.pt;
		pts[2] = (line0.pt+line0.dir);
		pts[3] = (line1.pt+line1.dir);
		
		ofxPlane resPlane = bestFitPlaneEquation(4, pts);
		
		setNormal(resPlane.normal);
		setPoint(resPlane.pt);
		computeD();
		initialized = true;
	}
}
예제 #4
0
////////////////////////////////////////////////////////////////
//
// Set the current card count:
//
void CardCount::setCount(int newCount)
{
    // Set the count text:
    mCountText->setString(CCString::createWithFormat("%d", newCount)->getCString());
    
    // Make sure the background matches:
    if (newCount <= 21)
        setNormal();
    else
        setBusted();
    
    mBgSprite2->setOpacity(160);
    mBgSprite2->setScale(1.0);
    mBgSprite2->runAction(CCSpawn::create(
                                   CCScaleTo::create(PingAnimationTime, 2.5),
                                   //Alpha
                                   CCFadeOut::create(PingAnimationTime),
                                   NULL
                                ));
}
예제 #5
0
/// \todo ÜBERARBEITEN!! setZufall & co.
DiaNeuesWst::DiaNeuesWst(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DiaNeuesWst)
{
    ui->setupUi(this);

    //default-Einstellungen des Dialogs
    this->farbe = COL_ROT;
    this->dicke = WSTK_GUT;
    this->bohrung = true;
    this->anzahl = 1;
    this->anzahlZuf = 1;//

    ui->dsbAnteilFehlerhafte->setValue(ANTEIL_AUSSCHUSS);

    connect(this->ui->cbBohrung, SIGNAL(toggled(bool)), this, SLOT(setBohrung(bool)));
    connect(this->ui->rbSchwarz, SIGNAL(clicked()), this, SLOT(setSchwarz()));
    connect(this->ui->rbRot, SIGNAL(clicked()), this, SLOT(setRot()));
    connect(this->ui->rbMetall, SIGNAL(clicked()), this, SLOT(setMetall()));
    connect(this->ui->rb23mm, SIGNAL(clicked()), this, SLOT(setDuenn()));
    connect(this->ui->rb25mm, SIGNAL(clicked()), this, SLOT(setNormal()));
    connect(this->ui->rb27mm, SIGNAL(clicked()), this, SLOT(setDick()));
    connect(this->ui->buErstellen, SIGNAL(clicked()), this, SLOT(accept()));
    connect(this->ui->buVerwerfen, SIGNAL(clicked()), this, SLOT(reject()));

    connect(this->ui->buErstellen_2, SIGNAL(clicked()), this, SLOT(accept()));
    connect(this->ui->buVerwerfen_2, SIGNAL(clicked()), this, SLOT(reject()));

    connect(this->ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(setZufall(int)));
    connect(this->ui->sbAnzahlZuf, SIGNAL(valueChanged(int)), this,SLOT(setAnzahlZuf(int)));
    connect(this->ui->sbAnzahl, SIGNAL(valueChanged(int)), this,SLOT(setAnzahl(int)));

    setZufall(ui->tabWidget->currentIndex());


    connect(ui->cbAutoRefill, SIGNAL(clicked()), this, SLOT(cbAutoRefillClicked()));
    connect(ui->sbBefTimeout, SIGNAL(valueChanged(int)), this, SLOT(setTimeoutRefill(int)));
    cbAutoRefillClicked();
}
예제 #6
0
PolygonalDrawable * AssimpLoader::parseMesh(const aiMesh & mesh) const
{
    auto geometry = std::make_shared<PolygonalGeometry>(m_registry);
    
    const bool usesNormalIndices(mesh.mNormals != NULL);
    
    for (unsigned int i = 0; i < mesh.mNumVertices; i++) {
        glm::vec3 vector(
                         mesh.mVertices[i].x, mesh.mVertices[i].y, mesh.mVertices[i].z
                         );
        geometry->setVertex(i, vector);
    }
    
    if (usesNormalIndices) {
        for (unsigned int i = 0; i < mesh.mNumVertices; i++) {
            glm::vec3 vector(
                             mesh.mNormals[i].x, mesh.mNormals[i].y, mesh.mNormals[i].z
                             );
            geometry->setNormal(i, vector);
        }
    }
    
    unsigned int currentIndex = 0;
    for (unsigned int i = 0; i < mesh.mNumFaces; i++) {
        if (mesh.mFaces[i].mNumIndices != 3)
            qCritical("Ignore polygon with num vertices != 3 (only triangles are supported).");
        else
            for (unsigned int j = 0; j < mesh.mFaces[i].mNumIndices; j++)
                geometry->setIndex(currentIndex++, mesh.mFaces[i].mIndices[j]);
    }
    
    if (!usesNormalIndices)
        geometry->retrieveNormals();
    
    PolygonalDrawable * drawable = new PolygonalDrawable(mesh.mName.C_Str());
    drawable->setGeometry(geometry);
    drawable->setMode(GL_TRIANGLES);
    return drawable;
}
//-----------------------------------------------.
void guiTypeTextDropDown::update(){

	boxHeight = MAX(15, displayText.getTextHeight());
	hitArea.height = boundingBox.height = boxHeight;
	
	int minSize = 0;
	for(int i = 0; i < vecDropList.size(); i++){
		minSize = MAX(minSize, displayText.getTextWidth(vecDropList[i]));
	}
	
	boundingBox.width = MAX(boundingBox.width, minSize + boxHeight + 5);
	hitArea			= boundingBox;
	
	//setShowText(false);
	updateText();
	if(bShowDropDown) {
		hitArea.height = boundingBox.height = boxHeight * vecDropList.size();
	} else {
		hitArea.height = boundingBox.height = boxHeight;
		state = SG_STATE_NORMAL;
		setNormal();
	}
}
bool QuadParticleSystemDrawer::setNormalAndUpSource(UInt32 NormalSource, UInt32 UpSource, Vec3f Normal, Vec3f Up)
{
    // set the values for the static normal and up vectors, since they won't necessarily be used
    setNormal(Normal);
    setUp(Up);

    bool defaultsUsed = false;
    // need to determine if the normal source and up direction source are compatible
    // this checks all possible valid combinations we have decided to allow
    if(    (NormalSource == NORMAL_VELOCITY && 
         (UpSource ==UP_POSITION_CHANGE || UpSource == UP_VELOCITY_CHANGE)) ||

        (UpSource == UP_VELOCITY && 
         (NormalSource ==  NORMAL_POSITION_CHANGE || NormalSource ==
          NORMAL_VELOCITY_CHANGE || NormalSource == NORMAL_VIEW_DIRECTION )) ||

        (UpSource == UP_VIEW_DIRECTION && 
         (NormalSource == NORMAL_VIEW_DIRECTION || NormalSource == NORMAL_VIEW_POSITION )) ||

        (NormalSource == NORMAL_STATIC) || (UpSource == UP_STATIC))
    {
        // this is a valid combination, so use it!
        setNormalSource(NormalSource);
        setUpSource(UpSource);

    }
    else
    {
        // the combination of up and normal sources is incompatible, use defaults
        setNormalSource(NORMAL_STATIC);
        setUpSource(UP_STATIC);
        defaultsUsed = true;
    }

    return !defaultsUsed;
}
예제 #9
0
AnalogLowPass::AnalogLowPass ()
{
  m_numPoles = -1;
  setNormal (0, 1);
}
예제 #10
0
파일: Plane.hpp 프로젝트: hhsaez/crimild
		Plane( const VectorImpl &p0, const VectorImpl &p1, const VectorImpl p2 )
		{
			setNormal( ( p2 - p1 ) ^ ( p0 - p1 ) );
			setConstant( -( _normal * p0 ) );
		}
예제 #11
0
파일: SPK_Plane.cpp 프로젝트: 4ian/GD
	Plane::Plane(const Vector3D& position,const Vector3D& normal) :
		Zone(position)
	{
		setNormal(normal);
	}
예제 #12
0
파일: Point.hpp 프로젝트: Danvil/dasp
		/** Sets normal from gradient */
		void setNormalFromGradient(const Eigen::Vector2f& g) {
			const float gx = g.x();
			const float gy = g.y();
			const float scl = Danvil::MoreMath::FastInverseSqrt(gx*gx + gy*gy + 1.0f);
			setNormal(Eigen::Vector3f(scl*gx, scl*gy, -scl));
		}
예제 #13
0
파일: Plane.hpp 프로젝트: hhsaez/crimild
		Plane( const VectorImpl &normal, const VectorImpl &point, bool forceNormalize = true )
		{
			setNormal( normal, forceNormalize );
			setConstant( -( _normal * point ) );
		}
예제 #14
0
AnalogLowShelf::AnalogLowShelf ()
  : m_numPoles (-1)
{
  setNormal (doublePi, 1);
}
예제 #15
0
/**
Create the vtkStructuredGrid from the provided workspace
@param progressUpdating: Reporting object to pass progress information up the
stack.
@return vtkPolyData glyph.
*/
vtkSmartPointer<vtkPolyData>
vtkPeakMarkerFactory::create(ProgressAction &progressUpdating) const {
  validate();

  int numPeaks = m_workspace->getNumberPeaks();

  // Acquire a scoped read-only lock to the workspace (prevent segfault from
  // algos modifying ws)
  Mantid::Kernel::ReadLock lock(*m_workspace);

  const int resolution = 100;
  double progressFactor = 1.0 / static_cast<double>(numPeaks);

  vtkAppendPolyData *appendFilter = vtkAppendPolyData::New();
  // Go peak-by-peak
  for (int i = 0; i < numPeaks; i++) {
    progressUpdating.eventRaised(double(i) * progressFactor);

    // Point
    vtkNew<vtkPoints> peakPoint;
    peakPoint->Allocate(1);

    // What we'll return
    vtkNew<vtkPolyData> peakDataSet;
    peakDataSet->Allocate(1);
    peakDataSet->SetPoints(peakPoint.GetPointer());

    const IPeak &peak = m_workspace->getPeak(i);

    // Choose the dimensionality of the position to show
    V3D pos = getPosition(peak);
    peakPoint->InsertNextPoint(pos.X(), pos.Y(), pos.Z());

    peakPoint->Squeeze();
    peakDataSet->Squeeze();

    // Add a glyph and append to the appendFilter
    const Mantid::Geometry::PeakShape &shape =
        m_workspace->getPeak(i).getPeakShape();

    // Pick the radius up from the factory if possible, otherwise use the
    // user-provided value.
    if (shape.shapeName() ==
        Mantid::DataObjects::PeakShapeSpherical::sphereShapeName()) {
      double peakRadius =
          shape.radius(Mantid::Geometry::PeakShape::Radius).get();

      vtkNew<vtkRegularPolygonSource> polygonSource;
      polygonSource->GeneratePolygonOff();
      polygonSource->SetNumberOfSides(resolution);
      polygonSource->SetRadius(peakRadius);
      polygonSource->SetCenter(0., 0., 0.);

      for (unsigned axis = 0; axis < 3; ++axis) {
        vtkNew<vtkPVGlyphFilter> glyphFilter;
        setNormal(polygonSource.GetPointer(), axis);
        glyphFilter->SetInputData(peakDataSet.GetPointer());
        glyphFilter->SetSourceConnection(polygonSource->GetOutputPort());
        glyphFilter->Update();
        appendFilter->AddInputData(glyphFilter->GetOutput());
        appendFilter->Update();
      }
    } else if (shape.shapeName() ==
               Mantid::DataObjects::PeakShapeEllipsoid::ellipsoidShapeName()) {
      vtkNew<vtkFloatArray> transformSignal;
      transformSignal->SetNumberOfComponents(9);
      transformSignal->SetNumberOfTuples(1);
      auto tensor = getTransformTensor(
          dynamic_cast<const Mantid::DataObjects::PeakShapeEllipsoid &>(shape),
          peak);
      transformSignal->SetTypedTuple(0, tensor.data());
      peakDataSet->GetPointData()->SetTensors(transformSignal.GetPointer());

      vtkNew<vtkRegularPolygonSource> polygonSource;
      polygonSource->GeneratePolygonOff();
      polygonSource->SetNumberOfSides(resolution);
      polygonSource->SetRadius(1.);
      polygonSource->SetCenter(0., 0., 0.);

      for (unsigned axis = 0; axis < 3; ++axis) {
        vtkNew<vtkTensorGlyph> glyphFilter;
        setNormal(polygonSource.GetPointer(), axis);
        glyphFilter->SetInputData(peakDataSet.GetPointer());
        glyphFilter->SetSourceConnection(polygonSource->GetOutputPort());
        glyphFilter->ExtractEigenvaluesOff();
        glyphFilter->Update();
        appendFilter->AddInputData(glyphFilter->GetOutput());
        appendFilter->Update();
      }
    } else {
      vtkNew<vtkAxes> axis;
      axis->SymmetricOn();
      axis->SetScaleFactor(0.2);

      vtkNew<vtkPVGlyphFilter> glyphFilter;
      glyphFilter->SetInputData(peakDataSet.GetPointer());
      glyphFilter->SetSourceConnection(axis->GetOutputPort());
      glyphFilter->Update();
      appendFilter->AddInputData(glyphFilter->GetOutput());
      appendFilter->Update();
    }

  } // for each peak

  return vtkSmartPointer<vtkPolyData>::Take(appendFilter->GetOutput());
}
예제 #16
0
파일: main.cpp 프로젝트: bcgs/PG-Proj2
 Triangle(Vertex v1, Vertex v2, Vertex v3) : a(v1), b(v2), c(v3) {
     setNormal();
 }
예제 #17
0
//==============================================================================
void PlaneShape::setNormalAndPoint(const Eigen::Vector3d& _normal,
                                   const Eigen::Vector3d& _point)
{
  setNormal(_normal);
  setOffset(mNormal.dot(_point));
}
예제 #18
0
파일: Plane.cpp 프로젝트: gaelduplessix/lvv
Plane::Plane() : _origin(), _normal(), _d() {
    setNormal(vec3(0.f, 1.f, 0.f));
}
예제 #19
0
UEditorWindow::UEditorWindow(QWidget *parent)
    : QMainWindow(parent),
      ui(new Ui::EditWindowClass),
      _confirmCloseMessageBox(0),
      _redoAction(0),
      _undoAction(0),
      _spaceNoteGeneration(false)
{

    this->setFocusPolicy(Qt::StrongFocus);
_startTime=0;
    _playViolon = false;
    _currentFile = NULL;
    _isPlaying=false;
setAcceptDrops(true);
USetting::Instance.init();

#ifdef QT_MODULE_NETWORK
UCheckUpdate * check = new UCheckUpdate(QUrl(URL_VERSION));
connect(check,SIGNAL(connected()),this,SLOT(onConnected()));
#endif


    setupAudio();
    setupUi();

            _currentFile = new UFile(this);// "songs/arkol - vingt ans/Arkol - vingt ans.txt");

            fileConnect();

            this->showSentenceWidget->setHScroll(0);

        connect(ui->vScroll,SIGNAL(valueChanged(int)),this,SLOT(onUpdateVScrollAndScale(int)));
        connect(ui->vSlider,SIGNAL(valueChanged(int)),this,SLOT(onUpdateVScrollAndScale(int)));
        connect(ui->vScroll,SIGNAL(sliderPressed()),this,SLOT(onUpdateVScrollAndScale()));
        connect(ui->vSlider,SIGNAL(sliderPressed()),this,SLOT(onUpdateVScrollAndScale()));
        //connect(ui->vScroll,SIGNAL(actionTriggered(int)),this,SLOT(changeVScroll(int)));

        connect(_hScroll,SIGNAL(valueChanged(int)),this,SLOT(changeHScroll(int)));
        //connect(ui->hSlider,SIGNAL(valueChanged(int)),this,SLOT(changeHSlider(int)));
        connect(_hScroll,SIGNAL(sliderPressed()),this,SLOT(changeHScroll()));
        //connect(ui->hSlider,SIGNAL(sliderPressed()),this,SLOT(changeHSlider()));
        connect(_hScroll,SIGNAL(pageStepChanged(int)),this,SLOT(changeHSlider(int)));





        connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(openFile()));

        connect(ui->actionEditHeaders,SIGNAL(triggered()),this,SLOT(editHeader()));
        connect(ui->actionApplyOffset,SIGNAL(triggered()),this,SLOT(openTiming()));
        connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
        connect(playAction, SIGNAL(triggered()), this, SLOT(tooglePlay()));
        connect(pauseAction, SIGNAL(triggered()), this, SLOT(tooglePlay()));
        connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecord()));
        connect(showSentenceWidget,SIGNAL(haveToStop()), this, SLOT(tooglePlay()));

        connect(this->ui->offsetSpinBox, SIGNAL(valueChanged(int)), showSentenceWidget, SLOT(setPreviousDisplayed(int)));
        this->ui->offsetSpinBox->setValue(2);
        connect(ui->actionSetNormalNote,SIGNAL(triggered()),showSentenceWidget, SLOT(setNormal()));
        connect(ui->actionSetFreeNote,SIGNAL(triggered()),showSentenceWidget, SLOT(setFree()));
        connect(ui->actionSetGoldNote,SIGNAL(triggered()),showSentenceWidget, SLOT(setGold()));

        connect(ui->actionMergeNotes,SIGNAL(triggered()),showSentenceWidget, SLOT(fusion()));
        connect(ui->actionSplitNote,SIGNAL(triggered()),showSentenceWidget, SLOT(split()));

        connect(ui->actionAddNote,SIGNAL(triggered()),showSentenceWidget, SLOT(nextClickAddNote()));
        connect(ui->actionAddSeparator,SIGNAL(triggered()),showSentenceWidget, SLOT(nextClickAddSeparator()));

        connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(save()));
        connect(ui->actionSaveAs,SIGNAL(triggered()),this,SLOT(saveAs()));
        connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(newSong()));

        connect(ui->actionQuit,SIGNAL(triggered()),this,SLOT(close()));

        connect(&UInputManager::Instance,SIGNAL(spacePressEvent(void)),this,SLOT(tooglePlay()));

        connect(_wydget_timeline, SIGNAL(gapModified(double)),this, SLOT(gapModified(double)));

         connect(ui->actionDeleteNote,SIGNAL(triggered()),showSentenceWidget,SLOT(deleteNotes()));

        connect(ui->actionPreferences,SIGNAL(triggered()),&USetting::Instance,SLOT(showDialog()));

        connect(ui->actionMorphe,SIGNAL(triggered()),showSentenceWidget,SLOT(calquer()));


        connect(ui->actionLockTimings,SIGNAL(toggled(bool)),showSentenceWidget,SLOT(lockTime(bool)));

        connect(ui->actionCenter,SIGNAL(triggered()),this,SLOT(centerView()));

        connect(ui->actionHelp,SIGNAL(triggered()),this,SLOT(displayHelpScreen()));
        connect(ui->actionSendFeedback,SIGNAL(triggered()),this,SLOT(displayFeedback()));




        onUpdateVScrollAndScale();
        changeHScroll(0);


       // _currentFile = new UFile(this);
        this->showSentenceWidget->setLyrics(_currentFile->lyrics);
        _wydget_lyrics->setWidgetWords(showSentenceWidget);


        _undoAction = _currentFile->lyrics->history().createUndoAction(this->ui->menuEdit, tr("Annuler "));
        _undoAction->setShortcut(QKeySequence::Undo);
        _undoAction->setIcon(QIcon(":/images/undo.png"));
        this->ui->menuEdit->addAction(_undoAction);
        this->ui->toolBar->insertAction(this->ui->actionSetNormalNote, _undoAction);

        _redoAction = _currentFile->lyrics->history().createRedoAction(this->ui->menuEdit, tr("Refaire "));
        _redoAction->setShortcut(QKeySequence::Redo);
        _redoAction->setIcon(QIcon(":/images/redo.png"));
        this->ui->menuEdit->addAction(_redoAction);
        this->ui->toolBar->insertAction(this->ui->actionSetNormalNote, _redoAction);


        readLastFile();

        connect(ui->actionRecentFiles,SIGNAL(triggered()),this,SLOT(openLastFile()));



        readSettings();

        _spaceNote = new Recorder(this->showSentenceWidget);

        _autoSaveTimer = new QTimer(this);
          connect(_autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSave()));

          adaptNewFile();


}
예제 #20
0
void renderScreen(void){
	GLfloat x, y, z, angle;
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glPushMatrix();
	glRotatef(xRotAngle, 1.0f, 0.0f, 0.0f);
	glRotatef(yRotAngle, 0.0f, 1.0f, 0.0f);
	if (depthTest)
		glEnable(GL_DEPTH_TEST);
	else
		glDisable(GL_DEPTH_TEST);
	if (cullFace)
		glEnable(GL_CULL_FACE);
	else
		glDisable(GL_CULL_FACE);
	if (outLine)
		glPolygonMode(GL_BACK, GL_LINE);
	else
		glPolygonMode(GL_BACK, GL_FILL);
	x = 0.0f;
	y = 0.0f;
	z = 0.0f;  
	glEnable(GL_LINE_SMOOTH);
	glHint(GL_LINE_SMOOTH, GL_NICEST);
	glColor3f(1.0f, 1.0f, 1.0f);
	glBegin(GL_LINES);
	glVertex3f(-80.0f, 0.0f, 0.0f);
	glVertex3f(80.0f, 0.0f, 0.0f);
	glVertex3f(0.0f, -80.0f, 0.0f);
	glVertex3f(0.0f, 80.0f, 0.0f);
	glVertex3f(0.0f, 0.0f, -80.0f);
	glVertex3f(0.0f, 0.0f, 80.0f);
	glEnd();

	glPushMatrix();
	glTranslatef(80.0f, 0.0f, 0.0f);
	glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
	glutWireCone(3, 6, 10, 10);
	glPopMatrix();

	glPushMatrix();
	glTranslatef(0.0f, 80.0f, 0.0f);
	glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
	glutWireCone(3, 6, 10, 10);
	glPopMatrix();

	glPushMatrix();
	glTranslatef(0.0f, 0.0f, 80.0f);
	glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
	glutWireCone(3, 6, 10, 10);
	glPopMatrix();

	glColor3f(0.0f, 1.0f, 0.0f);
	glPushMatrix();
	glTranslatef(-23, 20.0, 0.0);
	glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
	GLUquadricObj *cylinder_obj_1;
	cylinder_obj_1 = gluNewQuadric();
	glPushMatrix();
	gluCylinder(cylinder_obj_1, 1.5, 1.5, 90.0, 20, 20);
	glPopMatrix();
	glPopMatrix();

	int i;
	const GLfloat x_inc = (MAX_X - MIN_X) / SEGS;
	const GLfloat t_inc = 1.0f / SEGS;
	const GLfloat theta_inc = 2 * PI * CIRCLES / SEGS;
	/*GLuint texid = drawChar_To_Texture("hello, world!");
	GLfloat color[] = { 1.0f, 1.0f, 0.0f, 1.0f };
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
	glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);
	//glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, texid);*/
	glBegin(GL_QUAD_STRIP);
	glColor3f(1.0f, 0.0f, 1.0f);
	for (i = 0; i <= SEGS; ++i){
	const GLfloat z = RANGE * sin(i*theta_inc + theta);
	const GLfloat
	v1[] = { i*x_inc + MIN_X, MAX_Y, z },
	v2[] = { i*x_inc + MIN_X, MIN_Y, z },
	v3[] = {
	(i + 1)*x_inc + MIN_X,
	MAX_Y,
	RANGE * sin((i + 1)*theta_inc + theta) };
	setNormal(v1, v2, v3);
	glTexCoord2f(0, 1.0f);
	glVertex3fv(v1);
	glTexCoord2f(1, 0.0f);
	glVertex3fv(v2);
	}
	glEnd();
	glPopMatrix(); 
	glutSwapBuffers();
}
예제 #21
0
bool MetalineEnemy::renderTetrahedronIntersections(VertexWithFieldStrength v1, VertexWithFieldStrength v2,
												   VertexWithFieldStrength v3, VertexWithFieldStrength v4,
												   int v1Index, int v2Index, int v3Index, int v4Index,
												   Normal *normals)
{	
	int numInsideField = 0;
	
	bool v1InsideField = false;
	bool v2InsideField = false;
	bool v3InsideField = false;
	bool v4InsideField = false;
	
	if (v1.strength > DEFAULT_THRESHOLD)
	{
		numInsideField++;
		v1InsideField = true;
	}
	if (v2.strength > DEFAULT_THRESHOLD)
	{
		numInsideField++;
		v2InsideField = true;
	}
	if (v3.strength > DEFAULT_THRESHOLD)
	{
		numInsideField++;
		v3InsideField = true;
	}
	if (v4.strength > DEFAULT_THRESHOLD)
	{
		numInsideField++;
		v4InsideField = true;
	}
	
	VertexWithFieldStrength vInside1;
	VertexWithFieldStrength vInside2;
	VertexWithFieldStrength vInside3;
	
	VertexWithFieldStrength vOutside1;
	VertexWithFieldStrength vOutside2;
	VertexWithFieldStrength vOutside3;
	
	float vOutside1Ratio = .5f;
	float vOutside2Ratio = .5f;
	float vOutside3Ratio = .5f;
	
	float vOutside11Ratio = .5f;
	float vOutside12Ratio = .5f;
	float vOutside21Ratio = .5f;
	float vOutside22Ratio = .5f;
	
	float vInside1Ratio = .5f;
	float vInside2Ratio = .5f;
	float vInside3Ratio = .5f;
	
	int vInside1Index;
	int vInside2Index;
	int vInside3Index;
	
	int vOutside1Index;
	int vOutside2Index;
	int vOutside3Index;
	
	Vertex renderV1;
	Vertex renderV2;
	Vertex renderV3;
	
	Vertex renderN1;
	Vertex renderN2;
	Vertex renderN3;
	
	switch (numInsideField)
	{
		case 1:
			if (v1InsideField)
			{
				vInside1 = v1;
				vOutside1 = v2;
				vOutside2 = v3;
				vOutside3 = v4;
				
				vInside1Index = v1Index;
				vOutside1Index = v2Index;
				vOutside2Index = v3Index;
				vOutside3Index = v4Index;
			} else if (v2InsideField)
			{
				vInside1 = v2;
				vOutside1 = v1;
				vOutside2 = v3;
				vOutside3 = v4;
				
				vInside1Index = v2Index;
				vOutside1Index = v1Index;
				vOutside2Index = v3Index;
				vOutside3Index = v4Index;
			} else if (v3InsideField)
			{
				vInside1 = v3;
				vOutside1 = v1;
				vOutside2 = v2;
				vOutside3 = v4;
				
				vInside1Index = v3Index;
				vOutside1Index = v1Index;
				vOutside2Index = v2Index;
				vOutside3Index = v4Index;
			} else if (v4InsideField)
			{
				vInside1 = v4;
				vOutside1 = v1;
				vOutside2 = v2;
				vOutside3 = v3;
				
				vInside1Index = v4Index;
				vOutside1Index = v1Index;
				vOutside2Index = v2Index;
				vOutside3Index = v3Index;
			}
			
			if (VERTEX_INTERPOLATION)
			{
				vOutside1Ratio = (vInside1.strength - DEFAULT_THRESHOLD) /
				(vInside1.strength - vOutside1.strength);
				vOutside2Ratio = (vInside1.strength - DEFAULT_THRESHOLD) /
				(vInside1.strength - vOutside2.strength);
				vOutside3Ratio = (vInside1.strength - DEFAULT_THRESHOLD) /
				(vInside1.strength - vOutside3.strength);
			}
			
			renderV1.x = (vOutside1.x - vInside1.x) * vOutside1Ratio + vInside1.x;
			renderV1.y = (vOutside1.y - vInside1.y) * vOutside1Ratio + vInside1.y;
			renderV1.z = (vOutside1.z - vInside1.z) * vOutside1Ratio + vInside1.z;
			
			renderV2.x = (vOutside2.x - vInside1.x) * vOutside2Ratio + vInside1.x;
			renderV2.y = (vOutside2.y - vInside1.y) * vOutside2Ratio + vInside1.y;
			renderV2.z = (vOutside2.z - vInside1.z) * vOutside2Ratio + vInside1.z;
			
			renderV3.x = (vOutside3.x - vInside1.x) * vOutside3Ratio + vInside1.x;
			renderV3.y = (vOutside3.y - vInside1.y) * vOutside3Ratio + vInside1.y;
			renderV3.z = (vOutside3.z - vInside1.z) * vOutside3Ratio + vInside1.z;
			
			if (!normalWasComputed(normals, vInside1Index, vOutside1Index))
			{
				renderN1 = getNormal(renderV1);
				setNormal(normals, renderN1, vInside1Index, vOutside1Index);
			}
			else
			{
				renderN1 = getNormal(normals, vInside1Index, vOutside1Index);
			}
			
			if (!normalWasComputed(normals, vInside1Index, vOutside2Index))
			{
				renderN2 = getNormal(renderV2);
				setNormal(normals, renderN2, vInside1Index, vOutside2Index);
			}
			else
			{
				renderN2 = getNormal(normals, vInside1Index, vOutside2Index);
			}
			
			if (!normalWasComputed(normals, vInside1Index, vOutside3Index))
			{
				renderN3 = getNormal(renderV3);
				setNormal(normals, renderN3, vInside1Index, vOutside3Index);
			}
			else
			{
				renderN3 = getNormal(normals, vInside1Index, vOutside3Index);
			}
			
			/*renderN1 = getNormal(renderV1);
			 renderN2 = getNormal(renderV2);
			 renderN3 = getNormal(renderV3);*/
			
			glNormal3f(renderN1.x, renderN1.y, renderN1.z);
			//glNormal3f(renderV1.x - blobCenter.x, renderV1.y - blobCenter.y, renderV1.z - blobCenter.z);
			glVertex3f(renderV1.x + center.x, renderV1.y + center.y, renderV1.z + center.z);
			
			glNormal3f(renderN2.x, renderN2.y, renderN2.z);
			//glNormal3f(renderV2.x - blobCenter.x, renderV2.y - blobCenter.y, renderV2.z - blobCenter.z);
			glVertex3f(renderV2.x + center.x, renderV2.y + center.y, renderV2.z + center.z);
			
			glNormal3f(renderN3.x, renderN3.y, renderN3.z);
			//glNormal3f(renderV3.x - blobCenter.x, renderV3.y - blobCenter.y, renderV3.z - blobCenter.z);
			glVertex3f(renderV3.x + center.x, renderV3.y + center.y, renderV3.z + center.z);
			
			return true;
			
			break;
			
		case 2:
			if (v1InsideField && v2InsideField)
			{
				vInside1 = v1;
				vInside2 = v2;
				vOutside1 = v3;
				vOutside2 = v4;
				
				vInside1Index = v1Index;
				vInside2Index = v2Index;
				vOutside1Index = v3Index;
				vOutside2Index = v4Index;
			} else if (v1InsideField && v3InsideField)
			{
				vInside1 = v1;
				vInside2 = v3;
				vOutside1 = v2;
				vOutside2 = v4;
				
				vInside1Index = v1Index;
				vInside2Index = v3Index;
				vOutside1Index = v2Index;
				vOutside2Index = v4Index;
			} else if (v1InsideField && v4InsideField)
			{
				vInside1 = v1;
				vInside2 = v4;
				vOutside1 = v2;
				vOutside2 = v3;
				
				vInside1Index = v1Index;
				vInside2Index = v4Index;
				vOutside1Index = v2Index;
				vOutside2Index = v3Index;
			} else if (v2InsideField && v3InsideField)
			{
				vInside1 = v2;
				vInside2 = v3;
				vOutside1 = v1;
				vOutside2 = v4;
				
				vInside1Index = v2Index;
				vInside2Index = v3Index;
				vOutside1Index = v1Index;
				vOutside2Index = v4Index;
			} else if (v2InsideField && v4InsideField)
			{
				vInside1 = v2;
				vInside2 = v4;
				vOutside1 = v1;
				vOutside2 = v3;
				
				vInside1Index = v2Index;
				vInside2Index = v4Index;
				vOutside1Index = v1Index;
				vOutside2Index = v3Index;
			} else
			{
				vInside1 = v3;
				vInside2 = v4;
				vOutside1 = v1;
				vOutside2 = v2;
				
				vInside1Index = v3Index;
				vInside2Index = v4Index;
				vOutside1Index = v1Index;
				vOutside2Index = v2Index;
			}
			
			if (VERTEX_INTERPOLATION)
			{
				vOutside11Ratio = (vInside1.strength - DEFAULT_THRESHOLD) /
				(vInside1.strength - vOutside1.strength);
				vOutside12Ratio = (vInside2.strength - DEFAULT_THRESHOLD) /
				(vInside2.strength - vOutside1.strength);
				vOutside21Ratio = (vInside1.strength - DEFAULT_THRESHOLD) /
				(vInside1.strength - vOutside2.strength);
				vOutside22Ratio = (vInside2.strength - DEFAULT_THRESHOLD) /
				(vInside2.strength - vOutside2.strength);
			}
			
			renderV1.x = (vOutside1.x - vInside1.x) * vOutside11Ratio + vInside1.x;
			renderV1.y = (vOutside1.y - vInside1.y) * vOutside11Ratio + vInside1.y;
			renderV1.z = (vOutside1.z - vInside1.z) * vOutside11Ratio + vInside1.z;
			
			renderV2.x = (vOutside2.x - vInside1.x) * vOutside21Ratio + vInside1.x;
			renderV2.y = (vOutside2.y - vInside1.y) * vOutside21Ratio + vInside1.y;
			renderV2.z = (vOutside2.z - vInside1.z) * vOutside21Ratio + vInside1.z;
			
			renderV3.x = (vOutside1.x - vInside2.x) * vOutside12Ratio + vInside2.x;
			renderV3.y = (vOutside1.y - vInside2.y) * vOutside12Ratio + vInside2.y;
			renderV3.z = (vOutside1.z - vInside2.z) * vOutside12Ratio + vInside2.z;
			
			if (!normalWasComputed(normals, vInside1Index, vOutside1Index))
			{
				renderN1 = getNormal(renderV1);
				setNormal(normals, renderN1, vInside1Index, vOutside1Index);
			}
			else
			{
				renderN1 = getNormal(normals, vInside1Index, vOutside1Index);
			}
			
			if (!normalWasComputed(normals, vInside1Index, vOutside2Index))
			{
				renderN2 = getNormal(renderV2);
				setNormal(normals, renderN2, vInside1Index, vOutside2Index);
			}
			else
			{
				renderN2 = getNormal(normals, vInside1Index, vOutside2Index);
			}
			
			if (!normalWasComputed(normals, vInside2Index, vOutside1Index))
			{
				renderN3 = getNormal(renderV3);
				setNormal(normals, renderN3, vInside2Index, vOutside1Index);
			}
			else
			{
				renderN3 = getNormal(normals, vInside2Index, vOutside1Index);
			}
			
			/*renderN1 = getNormal(renderV1);
			 renderN2 = getNormal(renderV2);
			 renderN3 = getNormal(renderV3);*/
			
			glNormal3f(renderN1.x, renderN1.y, renderN1.z);
			//glNormal3f(renderV1.x - blobCenter.x, renderV1.y - blobCenter.y, renderV1.z - blobCenter.z);
			glVertex3f(renderV1.x + center.x, renderV1.y + center.y, renderV1.z + center.z);
			
			glNormal3f(renderN2.x, renderN2.y, renderN2.z);
			//glNormal3f(renderV2.x - blobCenter.x, renderV2.y - blobCenter.y, renderV2.z - blobCenter.z);
			glVertex3f(renderV2.x + center.x, renderV2.y + center.y, renderV2.z + center.z);
			
			glNormal3f(renderN3.x, renderN3.y, renderN3.z);
			//glNormal3f(renderV3.x - blobCenter.x, renderV3.y - blobCenter.y, renderV3.z - blobCenter.z);
			glVertex3f(renderV3.x + center.x, renderV3.y + center.y, renderV3.z + center.z);
			
			renderV1 = renderV3; //renderV1 is the previous renderV3
			
			//renderV2 is the same as before
			
			renderV3.x = (vOutside2.x - vInside2.x) * vOutside22Ratio + vInside2.x;
			renderV3.y = (vOutside2.y - vInside2.y) * vOutside22Ratio + vInside2.y;
			renderV3.z = (vOutside2.z - vInside2.z) * vOutside22Ratio + vInside2.z;
			
			renderN1 = renderN3; //renderN1 is the previous renderN3
			//renderN2 is the same as before
			
			if (!normalWasComputed(normals, vInside2Index, vOutside2Index))
			{
				renderN3 = getNormal(renderV3);
				setNormal(normals, renderN3, vInside2Index, vOutside2Index);
			}
			else
			{
				renderN3 = getNormal(normals, vInside2Index, vOutside2Index);
			}
			
			//renderN3 = getNormal(renderV3);
			
			glNormal3f(renderN1.x, renderN1.y, renderN1.z);
			//glNormal3f(renderV1.x - blobCenter.x, renderV1.y - blobCenter.y, renderV1.z - blobCenter.z);
			glVertex3f(renderV1.x + center.x, renderV1.y + center.y, renderV1.z + center.z);
			
			glNormal3f(renderN2.x, renderN2.y, renderN2.z);
			//glNormal3f(renderV2.x - blobCenter.x, renderV2.y - blobCenter.y, renderV2.z - blobCenter.z);
			glVertex3f(renderV2.x + center.x, renderV2.y + center.y, renderV2.z + center.z);
			
			glNormal3f(renderN3.x, renderN3.y, renderN3.z);
			//glNormal3f(renderV3.x - blobCenter.x, renderV3.y - blobCenter.y, renderV3.z - blobCenter.z);
			glVertex3f(renderV3.x + center.x, renderV3.y + center.y, renderV3.z + center.z);
			
			return true;
			
			break;
			
		case 3:
			if (!v1InsideField)
			{
				vOutside1 = v1;
				vInside1 = v2;
				vInside2 = v3;
				vInside3 = v4;
				
				vOutside1Index = v1Index;
				vInside1Index = v2Index;
				vInside2Index = v3Index;
				vInside3Index = v4Index;
			} else if (!v2InsideField)
			{
				vOutside1 = v2;
				vInside1 = v1;
				vInside2 = v3;
				vInside3 = v4;
				
				vOutside1Index = v2Index;
				vInside1Index = v1Index;
				vInside2Index = v3Index;
				vInside3Index = v4Index;
			} else if (!v3InsideField)
			{
				vOutside1 = v3;
				vInside1 = v1;
				vInside2 = v2;
				vInside3 = v4;
				
				vOutside1Index = v3Index;
				vInside1Index = v1Index;
				vInside2Index = v2Index;
				vInside3Index = v4Index;
			} else
			{
				vOutside1 = v4;
				vInside1 = v1;
				vInside2 = v2;
				vInside3 = v3;
				
				vOutside1Index = v4Index;
				vInside1Index = v1Index;
				vInside2Index = v2Index;
				vInside3Index = v3Index;
			}
			
			if (VERTEX_INTERPOLATION)
			{
				vInside1Ratio = (DEFAULT_THRESHOLD - vOutside1.strength) /
				(vInside1.strength - vOutside1.strength);
				vInside2Ratio = (DEFAULT_THRESHOLD - vOutside1.strength) /
				(vInside2.strength - vOutside1.strength);
				vInside3Ratio = (DEFAULT_THRESHOLD - vOutside1.strength) /
				(vInside3.strength - vOutside1.strength);
			}
			
			renderV1.x = (vInside1.x - vOutside1.x) * vInside1Ratio + vOutside1.x;
			renderV1.y = (vInside1.y - vOutside1.y) * vInside1Ratio + vOutside1.y;
			renderV1.z = (vInside1.z - vOutside1.z) * vInside1Ratio + vOutside1.z;
			
			renderV2.x = (vInside2.x - vOutside1.x) * vInside2Ratio + vOutside1.x;
			renderV2.y = (vInside2.y - vOutside1.y) * vInside2Ratio + vOutside1.y;
			renderV2.z = (vInside2.z - vOutside1.z) * vInside2Ratio + vOutside1.z;
			
			renderV3.x = (vInside3.x - vOutside1.x) * vInside3Ratio + vOutside1.x;
			renderV3.y = (vInside3.y - vOutside1.y) * vInside3Ratio + vOutside1.y;
			renderV3.z = (vInside3.z - vOutside1.z) * vInside3Ratio + vOutside1.z;
			
			if (!normalWasComputed(normals, vOutside1Index, vInside1Index))
			{
				renderN1 = getNormal(renderV1);
				setNormal(normals, renderN1, vOutside1Index, vInside1Index);
			}
			else
			{
				renderN1 = getNormal(normals, vOutside1Index, vInside1Index);
			}
			
			if (!normalWasComputed(normals, vOutside1Index, vInside2Index))
			{
				renderN2 = getNormal(renderV2);
				setNormal(normals, renderN2, vOutside1Index, vInside2Index);
			}
			else
			{
				renderN2 = getNormal(normals, vOutside1Index, vInside2Index);
			}
			
			if (!normalWasComputed(normals, vOutside1Index, vInside3Index))
			{
				renderN3 = getNormal(renderV3);
				setNormal(normals, renderN3, vOutside1Index, vInside3Index);
			}
			else
			{
				renderN3 = getNormal(normals, vOutside1Index, vInside3Index);
			}
			
			/*renderN1 = getNormal(renderV1);
			 renderN2 = getNormal(renderV2);
			 renderN3 = getNormal(renderV3);*/
			
			glNormal3f(renderN1.x, renderN1.y, renderN1.z);
			//glNormal3f(renderV1.x - blobCenter.x, renderV1.y - blobCenter.y, renderV1.z - blobCenter.z);
			glVertex3f(renderV1.x + center.x, renderV1.y + center.y, renderV1.z + center.z);
			
			glNormal3f(renderN2.x, renderN2.y, renderN2.z);
			//glNormal3f(renderV2.x - blobCenter.x, renderV2.y - blobCenter.y, renderV2.z - blobCenter.z);
			glVertex3f(renderV2.x + center.x, renderV2.y + center.y, renderV2.z + center.z);
			
			glNormal3f(renderN3.x, renderN3.y, renderN3.z);
			//glNormal3f(renderV3.x - blobCenter.x, renderV3.y - blobCenter.y, renderV3.z - blobCenter.z);
			glVertex3f(renderV3.x + center.x, renderV3.y + center.y, renderV3.z + center.z);
			
			return true;
			
			break;
	}
	
	return false;
}
예제 #22
0
void CC3PointParticle::pointNormalAt( const CC3Vector& camLoc )
{
	setNormal( camLoc.difference( getLocation() ).normalize() );
}
예제 #23
0
AnalogLowShelf::AnalogLowShelf ()
{
  m_numPoles = -1;
  setNormal (doublePi, 1);
}
예제 #24
0
QList<vtkIdType> StitchHoles::getNextHole()
{
  QList<vtkIdType> loop_nodes;
  EG_VTKDCC(vtkIntArray, cell_code, m_Grid, "cell_code");

  // find the first two nodes of the hole
  //
  vtkIdType id_node1 = -1;
  vtkIdType id_node2 = -1;
  EG_FORALL_CELLS (id_cell, m_Grid) {
    if (isSurface(id_cell, m_Grid) && cell_code->GetValue(id_cell) == m_Bc) {
      for (int i = 0; i < m_Part.c2cGSize(id_cell); ++i) {
        if (m_Part.c2cGG(id_cell, i) == -1) {
          QList<vtkIdType> pts;
          getPointsOfCell(m_Grid, id_cell, pts);
          pts << pts.first();
          id_node1 = pts[i+1];
          id_node2 = pts[i];
          break;
        }
      }
      if (id_node1 != -1) {
        break;
      }
    }
  }
  if (id_node1 == -1) {
    return loop_nodes;
  }

  // create node loop around hole
  //
  vtkIdType id_start = id_node1;
  loop_nodes << id_node1;
  vec3_t x0;
  m_Grid->GetPoint(id_node1, x0.data());
  while (id_node2 != id_start && loop_nodes.size() < m_Grid->GetNumberOfPoints()) {
    loop_nodes << id_node2;
    vec3_t x;
    m_Grid->GetPoint(id_node2, x.data());
    x0 += x;
    bool found = false;
    for (int i = 0; i < m_Part.n2nGSize(id_node2); ++i) {
      vtkIdType id_node3 = m_Part.n2nGG(id_node2, i);
      if (id_node3 != id_node1) {
        QList<vtkIdType> edge_faces;
        m_Part.getEdgeFaces(id_node2, id_node3, edge_faces);
        if (edge_faces.size() == 1) {
          found = true;
          id_node1 = id_node2;
          id_node2 = id_node3;
          break;
        }
      }
    }
    if (!found) {
      loop_nodes.clear();
      return loop_nodes;
    }
  }
  x0 *= 1.0/loop_nodes.size();
  m_Cad->snap(x0);
  vec3_t n = m_Cad->getLastNormal();
  setOrigin(x0);
  setNormal(n);
  setupTransformation();
  return loop_nodes;
}
예제 #25
0
AnalogLowPass::AnalogLowPass ()
  : m_numPoles (-1)
{
  setNormal (0, 1);
}
예제 #26
0
파일: ChebyshevI.cpp 프로젝트: AGenews/GUI
AnalogLowShelf::AnalogLowShelf()
{
    setNormal(doublePi, 1);
}
예제 #27
0
void VertexBuffer::setNormalBulk( Vec3 *v, int num ) {
	for(int i=0;i<num;i++) {
		setNormal( i, v[i] );
	}
}
예제 #28
0
파일: Plane.hpp 프로젝트: hhsaez/crimild
		Plane( const VectorImpl &normal, PRECISION constant, bool forceNormalize = true )
		{
			setNormal( normal, forceNormalize );
			setConstant( constant );
		}
예제 #29
0
//==============================================================================
void PlaneShape::setNormalAndOffset(const Eigen::Vector3d& _normal,
                                    double _offset)
{
  setNormal(_normal);
  setOffset(_offset);
}
예제 #30
0
파일: Vertex.cpp 프로젝트: omochi/gluttest
	Vertex &Vertex::setNormal(float x,float y,float z){
		setNormal(vec3(x,y,z));
		return *this;
	}