コード例 #1
0
ファイル: Desenho.cpp プロジェクト: lucasteles/OpenGL_Tests
void Desenho::SquareX3D(double tnAng,double tnX,double tnY,double tnZ,double tnTamX,double tnTamY){
    double nX0 = tnX,nY0 = tnY,Z0 = tnZ;
    double nXT = nX0+tnTamX,nYT = nY0+tnTamY;

    Line3D(tnAng,nX0,nY0,Z0,nX0,nYT,Z0);
    Line3D(tnAng,nX0,nY0,Z0,nXT,nY0,Z0);
    Line3D(tnAng,nX0,nYT,Z0,nXT,nYT,Z0);
    Line3D(tnAng,nXT,nY0,Z0,nXT,nYT,Z0);
}
コード例 #2
0
ファイル: Desenho.cpp プロジェクト: lucasteles/OpenGL_Tests
void Desenho::SquareZ3D(double tnAng,double tnX,double tnY,double tnZ,double tnTamZ,double tnTamY){
    double nX0 = tnX,nY0 = tnY,nZ0 = tnZ;
    double nXT,nYT = nY0+tnTamY,nZT = nZ0+tnTamZ;

    Line3D(tnAng,nX0,nY0,nZ0,nX0,nYT,nZ0);
    Line3D(tnAng,nX0,nY0,nZ0,nX0,nY0,nZT);
    Line3D(tnAng,nX0,nYT,nZ0,nX0,nYT,nZT);
    Line3D(tnAng,nX0,nY0,nZT,nX0,nYT,nZT);
}
コード例 #3
0
ファイル: Desenho.cpp プロジェクト: lucasteles/OpenGL_Tests
void Desenho::Plan(double tnTam,double tnLargura){
    double nX0 = 0 - tnTam,nY0 = 0,nZ0 = tnTam;
    double nI;

    for(nI=nX0;nI<=tnTam;nI=nI+tnLargura)
        Line3D(0,nI,nY0,nZ0,nI,nY0,nZ0-(2*tnTam));

    for(nI=nZ0;nI>=-tnTam;nI=nI-tnLargura)
        Line3D(0,nX0,nY0,nI,nX0+(2*tnTam),nY0,nI);
}
コード例 #4
0
ファイル: spatial.cpp プロジェクト: mauroalberti/geoSurfDEM
Line3D Segment3D::as_line() {

    Point3D start_pt3d = start_pt();
    Vector3D line_vect = as_versor();
    return Line3D(start_pt3d, line_vect);

};
コード例 #5
0
ファイル: geomlib-advanced.cpp プロジェクト: yxrkt/DigiPen
// Determines if 3D ray and triangle have a unique intersection.  
// If true and rpoint is not NULL, returns intersection point.
bool Intersects(const Ray3D& ray, const Triangle3D& tri, Point3D *rpoint)
{
  Vector3D n( Vector3D( ( tri[1] - tri[0] ) ^ ( tri[2] - tri[1] ) ).normalized() );

  // check if coplanar
  if ( abs( n * ray.direction ) < epsilon ) return false;

  // check if ray is facing away from plane
  if ( ( tri[0] - ray.origin ) * ray.direction < 0.f ) return false;

  float d = -( n[0] * tri[0][0] + n[1] * tri[0][1] + n[2] * tri[0][2] );
  Point3D isect;

  // if point intersects plane
  if ( Intersects( Line3D( ray.origin, ray.direction ), Plane3D( n[0], n[1], n[2], d ), &isect ) )
  {
    int count = 0;
    for ( int i = 0; i < 3; ++i )
    {
      int next = (i == 2) ? 0 : i + 1;
      float side = (( isect - tri[i] ) ^ ( tri[next] - isect )) * n;
      count += ( (side < 0.f) ? -1 : 1 );
    }
    // if point is within triangle's boundaries
    if ( abs( count ) == 3 )
    {
      if ( rpoint ) *rpoint = isect;
      return true;
    }
  }

  return false;
}
コード例 #6
0
ファイル: spatial.cpp プロジェクト: mauroalberti/geoSurfDEM
Line3D CartesianPlane::intersect(CartesianPlane another) {

    Vector3D vers = intersect_versor(another);
    Point3D pt3d = intersect_point3d(another);

    return Line3D( pt3d, vers);

};
コード例 #7
0
ファイル: geomlib-advanced.cpp プロジェクト: yxrkt/DigiPen
// Determines if 3D ray and sphere have 0, 1, or 2 intersections.  
// If any exist and rpoint is not NULL, returns intersection point(s).
int Intersects(const Ray3D& ray, const Sphere3D& sphere, std::pair<Point3D, Point3D> *rpoints)
{
  // find pts of intersection of line
  float dist = Distance( sphere.center, Line3D( ray.origin, ray.direction ) );
  Vector3D u = sphere.center - ray.origin;
  float uLen = u.length();
  
  // trivial rejection 1
  if ( dist > sphere.radius + epsilon ) return 0;

  // trivial rejection 2
  if ( ray.direction * u < 0.f && uLen > sphere.radius ) return 0;

  // line has one intersection
  if ( dist >= sphere.radius - epsilon )
  {
    float t = sqrt( dist * dist - sphere.radius * sphere.radius ) / ray.direction.length();

    if ( t <= 1.f )
    {
      if ( rpoints ) rpoints->first = ray.origin + t * ray.direction;
      return 1;
    }

    return 0;
  }

  // line has two intersections (assuming ray origin not in sphere)
  float dist2   = dist * dist;
  float rayLen  = ray.direction.length();
  float m       = sqrt( uLen * uLen - dist2 );
  float h       = sqrt( sphere.radius * sphere.radius - dist2 );
  float t1      = ( m - h ) / rayLen;
  float t2      = ( m + h ) / rayLen;

  if ( t1 <= 1.f )
  {
    if ( rpoints ) rpoints->first = ray.origin + t1 * ray.direction;

    if ( t2 <= 1.f )
    {
      if ( rpoints ) rpoints->second = ray.origin + t2 * ray.direction;
      return 2;
    }

    return 1;
  }

  return 0;
}
コード例 #8
0
//----------------------------------------------------------------------------
void RayTrace::Trace (int spacing)
{
    *mAccum = 0.0f;
    *mRender = (Ergb8)0;

    float w0 = mHBound*mFrame[0][2];
    float w1 = mHBound*mFrame[1][2];
    float w2 = mHBound*mFrame[2][2];
    for (int i1 = -mHBound; i1 < mHBound; i1 += spacing)
    {
        int j1 = i1 + mHBound;
        for (int i0 = -mHBound; i0 < mHBound; i0 += spacing)
        {
            int j0 = i0 + mHBound;

            float a0 = i0*mFrame[0][0] + i1*mFrame[0][1];
            float a1 = i0*mFrame[1][0] + i1*mFrame[1][1];
            float a2 = i0*mFrame[2][0] + i1*mFrame[2][1];

            float fx0 = a0 - w0, fy0 = a1 - w1, fz0 = a2 - w2;
            float fx1 = a0 + w0, fy1 = a1 + w1, fz1 = a2 + w2;

            if (Clip3D(fx0, fy0, fz0, fx1, fy1, fz1))
            {
                int x0 = (int)(fx0 + mXCenter);
                int y0 = (int)(fy0 + mYCenter);
                int z0 = (int)(fz0 + mZCenter);
                int x1 = (int)(fx1 + mXCenter);
                int y1 = (int)(fy1 + mYCenter);
                int z1 = (int)(fz1 + mZCenter);
                Line3D(j0, j1, x0, y0, z0, x1, y1, z1);
                if (spacing > 1)
                {
                    unsigned int value = (*mRender)(j0, j1);
                    for (int y = 0; y < spacing; ++y)
                    {
                        for (int x = 0; x < spacing; ++x)
                        {
                            (*mRender)(j0 + x, j1 + y) = value;
                        }
                    }
                }
            }
        }
    }
}
コード例 #9
0
//----------------------------------------------------------------------------
void RayTrace::Trace (int iSpacing)
{
    int iI0, iI1, iJ0, iJ1;

    *m_pkAccum = 0.0f;
    *m_pkRender = (unsigned short)0;

    float fLw0 = m_iHBound*m_aafFrame[0][2];
    float fLw1 = m_iHBound*m_aafFrame[1][2];
    float fLw2 = m_iHBound*m_aafFrame[2][2];
    for (iI1 = -m_iHBound; iI1 < m_iHBound; iI1 += iSpacing)
    {
        iJ1 = iI1 + m_iHBound;
        for (iI0 = -m_iHBound; iI0 < m_iHBound; iI0 += iSpacing)
        {
            iJ0 = iI0 + m_iHBound;

            float fA0 = iI0*m_aafFrame[0][0] + iI1*m_aafFrame[0][1];
            float fA1 = iI0*m_aafFrame[1][0] + iI1*m_aafFrame[1][1];
            float fA2 = iI0*m_aafFrame[2][0] + iI1*m_aafFrame[2][1];

            float fX0 = fA0-fLw0, fY0 = fA1-fLw1, fZ0 = fA2-fLw2;
            float fX1 = fA0+fLw0, fY1 = fA1+fLw1, fZ1 = fA2+fLw2;

            if ( Clip3D(fX0,fY0,fZ0,fX1,fY1,fZ1) )
            {
                int iX0 = (int)(fX0+m_fXCenter);
                int iY0 = (int)(fY0+m_fYCenter);
                int iZ0 = (int)(fZ0+m_fZCenter);
                int iX1 = (int)(fX1+m_fXCenter);
                int iY1 = (int)(fY1+m_fYCenter);
                int iZ1 = (int)(fZ1+m_fZCenter);
                Line3D(iJ0,iJ1,iX0,iY0,iZ0,iX1,iY1,iZ1);
                if ( iSpacing > 1 )
                {
                    unsigned int uiValue = (*m_pkRender)(iJ0,iJ1);
                    for (int iY = 0; iY < iSpacing; iY++)
                    {
                        for (int iX = 0; iX < iSpacing; iX++)
                            (*m_pkRender)(iJ0+iX,iJ1+iY) = uiValue;
                    }
                }
            }
        }
    }
}
コード例 #10
0
ファイル: roitool.cpp プロジェクト: 151706061/starviewer
ROIData ROITool::computeVoxelValues(const QList<Line3D> &polygonSegments, Point3D sweepLineBeginPoint, Point3D sweepLineEndPoint, double sweepLineEnd, int inputNumber)
{
    // We get the pointer of the pixel data to obtain voxels values from
    VolumePixelData *pixelData = m_2DViewer->getCurrentPixelDataFromInput(inputNumber);
    if (!pixelData)
    {
        return ROIData();
    }
    
    OrthogonalPlane currentView = m_2DViewer->getView();
    int yIndex = currentView.getYIndex();
    double currentZDepth = m_2DViewer->getCurrentDisplayedImageDepthOnInput(inputNumber);
    
    double spacing[3];
    pixelData->getSpacing(spacing);
    double verticalSpacingIncrement = spacing[yIndex];
    
    int phaseIndex = 0;
    if (currentView == OrthogonalPlane::XYPlane && m_2DViewer->doesInputHavePhases(inputNumber))
    {
        phaseIndex = m_2DViewer->getCurrentPhaseOnInput(inputNumber);
    }

    // ROI voxel data to be obtained from the sweep line
    ROIData roiData;
    while (sweepLineBeginPoint.at(yIndex) <= sweepLineEnd)
    {
        // We get the intersections bewteen ROI segments and current sweep line
        QList<double*> intersectionList = getIntersectionPoints(polygonSegments, Line3D(sweepLineBeginPoint, sweepLineEndPoint), currentView);

        // Adding the voxels from the current intersections of the current sweep line to the voxel values list
        addVoxelsFromIntersections(intersectionList, currentZDepth, currentView, pixelData, phaseIndex, roiData);
        
        // Shift the sweep line the corresponding space in vertical direction
        sweepLineBeginPoint[yIndex] += verticalSpacingIncrement;
        sweepLineEndPoint[yIndex] += verticalSpacingIncrement;
    }

    return roiData;
}
コード例 #11
0
ファイル: Desenho.cpp プロジェクト: lucasteles/OpenGL_Tests
void Desenho::CircleZ3D(double tnAng,double tnX,double tnY,double tnZ,double tnRaio){
    double nCX  = tnX;
    double nCZ  = tnZ;
    double nTam = tnRaio;
    Pixel3D oPixel,oAnt;

    for (int nI = 0; nI <= 360; nI++)
    {
        double nRad = nI * (PI / 180);

        oPixel.nX = (double) nCX + (cos(nRad) * nTam);
        oPixel.nZ = (double) nCZ + (sin(nRad) * nTam);
        oPixel.nY = tnY;

        if(nI > 0){
            Line3D(tnAng,oAnt.nX,oAnt.nY,oAnt.nZ,oPixel.nX,oPixel.nY,oPixel.nZ);
        }
        oAnt.nX = oPixel.nX;
        oAnt.nY = oPixel.nY;
        oAnt.nZ = oPixel.nZ;
    }
}
コード例 #12
0
void main (){

int gdriver=0,gmode,opc,opc1,opc2,opc3,opc4,opc5,opc6,opc7,opc8,opc9;


initgraph(&gdriver,&gmode," ");

Box(120,40,520,420,"Acerca de Hackerz.Com");boton(425,375,500,395,8,15,7,3);
conv_text(437,382,"Aceptar",0);
Line3D(140,335,500,335);barra_estado(153,80,200,148);
settextstyle(1,0,6);conv_text(158,69,"H",1);conv_text(173,94,"S",1);
settextstyle(10,0,2);conv_text(219,86,"Hackerz Software",1);
settextstyle(0,0,1);conv_text(186,160,"Copyright (c) 1999-2000 Hackerz Software",0);
conv_text(186,178,"All rights Reserved.",0);conv_text(186,210,"Requerimientos:",0);
conv_text(186,230,"  Windows 95/98/NT",0);conv_text(186,250,"  16 MB de Memoria RAM",0);
conv_text(186,270,"  Procesador 486 100 MHZ",0);conv_text(186,290,"  Tarjeta de Video de 1 MB",0);
conv_text(135,350," WARNING: This App was designed by Mac.",0);
conv_text(140,370,"This Software is Shareware.",0);
if (getch()>=0) press(425,375,500,395,8,15,7,3);
//getch();
closegraph();restorecrtmode();system("cls");exit(0);
}
コード例 #13
0
ファイル: Triangle3D.cpp プロジェクト: Jornason/ofxToxiclibs
toxi::geom::Vec3D toxi::geom::Triangle3D::getClosestPointTo( Vec3D & v )
{
    Line3D edge = Line3D( a, b );
    Vec3D Rab = edge.closestPointTo( v );
    Vec3D Rbc = edge.set( b, c ).closestPointTo( v );
    Vec3D Rca = edge.set( c, a ).closestPointTo( v );

    float dAB = v.sub( Rab ).magSquared();
    float dBC = v.sub( Rbc ).magSquared();
    float dCA = v.sub( Rca ).magSquared();

    float min = dAB;
    Vec3D result = Rab;

    if (dBC < min) {
        min = dBC;
        result = Rbc;
    }
    if (dCA < min) {
        result = Rca;
    }

    return result;
}
コード例 #14
0
ファイル: Untitled1.cpp プロジェクト: aleks311001/Other
int main()
    {
     _txWindowStyle &= ~ WS_CAPTION;

    txCreateWindow (XWindow, YWindow);

    int sz = 15;

    CBall  Ball [15] = {};

    Mass1 (Ball, sz);
    //double x = 0, y = 0, z = 0;
    //double vx = 0.06, vy = 0.04, vz = 0.02, dt = 1;
    while (!GetAsyncKeyState (VK_ESCAPE))
        {
        txSetFillColor (TX_WHITE);
        txBegin();
        txClear ();

        txSetColor (TX_BLUE, 5);
        Line3D ( 1,  1,  1, -1,  1,  1);
        Line3D (-1,  1, -1,  1,  1, -1);
        Line3D (-1,  1, -1, -1,  1,  1);
        Line3D ( 1,  1,  1,  1,  1, -1);

        txSetColor (TX_BROWN, 5);
        Line3D (-1, -1,  1, -1, -1, -1);
        Line3D ( 1, -1,  1, -1, -1,  1);
        Line3D ( 1, -1, -1,  1, -1,  1);
        Line3D ( 1, -1, -1, -1, -1, -1);

        txSetColor (TX_GREEN, 5);
        Line3D (-1,  1,  1, -1, -1,  1);
        Line3D (-1,  1, -1, -1, -1, -1);
        Line3D ( 1,  1, -1,  1, -1, -1);
        Line3D ( 1,  1,  1,  1, -1,  1);

        printf ("%lf, %lf,\n",ZoomZ, zGlob);

        /*txSetColor (TX_ORANGE, 5);
        Line3D (0, 3, 0,  1, 1, -1);
        Line3D (0, 3, 0, -1, 1,  1);
        Line3D (0, 3, 0, -1, 1, -1);
        Line3D (0, 3, 0,  1, 1,  1);*/
        /*
        for (int K = 0; K < sz; K++)
            {
            Dvig (&Ball [K], 1, 1, 1);
            txSetColor (RGB(random (50, 250), random (50, 250), random (50, 250))
            , 5);
            txSetFillColor (RGB(random (50, 250), random (50, 250), random (50, 250)));
            Circle3D (Ball[K].x, Ball[K].y, Ball[K].z, Ball[K].rad);
            }
        */
        /*Line3D (0, 0, 0, 10, 0, 0);
        Line3D (0, 0, 0, 0, 10, 0);
        Line3D (0, 0, 0, 0, 0, 10);*/

        Skale3D ();
        Translete3D ();
        Rotate ();
        txEnd ();
        }
    return 0;
    }
コード例 #15
0
void OsmAnd::AtlasMapRendererDebugStage_OpenGL::addLine3D(const QVector<glm::vec3>& line, const uint32_t argbColor)
{
    assert(line.size() >= 2);
    _lines3D.push_back(qMove(Line3D(line, argbColor)));
}
コード例 #16
0
ファイル: geomlib-advanced.cpp プロジェクト: yxrkt/DigiPen
// Determines if 3D segment and plane have a unique intersection.  
// If true and rpoint is not NULL, returns intersection point.
bool Intersects(const Segment3D& seg, const Plane3D& plane, Point3D *rpoint)
{
  return vsLine3D( Line3D( seg.point1, seg.point2 - seg.point1 ), plane, rpoint );
}
コード例 #17
0
ファイル: text3d.cpp プロジェクト: Enet4/cryxtels
void Txt (const char * testo, double x, double y, double z,
	  double scala_x, double scala_y, int alfa, int beta)
{
	double fxx=0, fyy=0, pxx=0, pyy=0;
	double lsx=0, lsy=0, lsz=0;
	double sx=0, sy=0, sz=0;

	int t; // char

	int f;
	int l;

	x += ox;
	y += oy;
	z += oz;

	int c = 0;
	int ttl = 0;
	while (testo[c]) c++;
	ttl = c;

	sx = x-cam_x; sy = y-cam_y; sz = z-cam_z;

	double icoeff = sqrt (sx*sx+sy*sy+sz*sz);
	double scala_d = scala_x * mediumwidth;
	int incr = icoeff / (50*scala_d); if (incr<1) incr = 1;
	double avan_x = scala_d * tcos[beta] * (double)incr;
	double avan_z = scala_d * tsin[beta] * (double)incr;

	scala_x *= 0.8;
	scala_y *= 0.8;

	c = 0;
	while (c<ttl) {
		t = testo[c] - 32;
		pxx = 1000;
		f = 1;
		for (l=0; l<symbol[t][0]; l++) {
			fxx = symbol[t][f+0]*scala_x;
			fyy = symbol[t][f+1]*scala_y;
			if (fxx==pxx&&fyy==pyy) {
				sx = lsx;
				sy = lsy;
				sz = lsz;
			}
			else {
				z2 = fyy * tsin[alfa];
				sy = fyy * tcos[alfa] + y;
				sz = z2  * tcos[beta] - fxx * tsin[beta] + z;
				sx = fxx * tcos[beta] + z2  * tsin[beta] + x;
			}
			pxx = symbol[t][f+2]*scala_x;
			pyy = symbol[t][f+3]*scala_y;
			z2  = pyy * tsin[alfa];
			lsy = pyy * tcos[alfa] + y;
			lsz = z2  * tcos[beta] - pxx * tsin[beta] + z;
			lsx = pxx * tcos[beta] + z2  * tsin[beta] + x;
			Line3D (sx, sy, sz, lsx, lsy, lsz);
			f += 4;
		}
		x += avan_x;
		z += avan_z;
		c += incr;
	}
}