Exemplo n.º 1
0
	void CloudAtlasControlWindow::initWindow(osgWidget::WindowManager* wm, TemperatureProbeLayer* tLayer, WindowThemeSettings wts)
	{
		setZRange(1.0f);
		_obWM = wm;
		getBackground()->setColor(osgWidget::Color(0, 0, 0, 0));
		getBackground()->setEventMask(osgWidget::EVENT_NONE);
		_wts = wts;
		osgWidget::Table* centerTable = new osgWidget::Table("CenterTable", 2, 1);
		centerTable->getBackground()->setColor(osgWidget::Color(0, 0, 0, 0));
		_centerWidget = new CenterWidget("CloudAtlasCenterWidget", _windowWidth);
		float centerHeight = _centerWidget->buildCenterWidget(tLayer);
		osgWidget::point_type cw = wts._left;
		osgWidget::point_type ch = wts._bottom;
		osgWidget::point_type w = _windowWidth - cw - wts._right;
		osgWidget::point_type h = centerHeight + wts._topTitleHeight;
		osgWidget::Window::EmbeddedWindow* centerEW = new osgWidget::Window::EmbeddedWindow("CenterTableEmbedded", _windowWidth, h);
		centerEW->setCanFill(true);
		centerEW->setLayer(osgWidget::Widget::LAYER_MIDDLE);
		centerEW->setEventMask(osgWidget::EVENT_ALL);
		centerEW->setColor(1, 1, 1, 1);
		centerEW->setImage(wts._bgImage, true);
		addWidget(centerEW, 1, 1);

		osgWidget::Window::EmbeddedWindow* centerWidget = _centerWidget->embed("CenterEmbeddedWindow");
		centerWidget->setEventMask(osgWidget::EVENT_ALL);
		centerWidget->setColor(0, 0, 0, 0);
		centerTable->addWidget(centerWidget, 0, 0);
		_topTitleWidget = new VirtualDataSceneWidget::TopTitleWidget("TopTitle", _windowWidth, wts._topTitleHeight, wts._topTitleImage, wts._topCloseButtonImage);
		osgWidget::Window::EmbeddedWindow* topBorderWidget = _topTitleWidget->embed("TopTitleEmbedded");
		topBorderWidget->setColor(0, 0, 0, 0);
		topBorderWidget->setEventMask(osgWidget::EVENT_ALL);
		centerTable->addWidget(topBorderWidget, 1, 0);
		centerTable->resize(_windowWidth, h);
		setWindow(centerTable);

		//init left bottom right border and corner
		addWidget(new osgWidget::Frame::Corner(osgWidget::Frame::CORNER_LOWER_LEFT, cw, ch), 0, 0);
		addWidget(new osgWidget::Frame::Border(osgWidget::Frame::BORDER_BOTTOM, w, ch), 0, 1);
		addWidget(new osgWidget::Frame::Corner(osgWidget::Frame::CORNER_LOWER_RIGHT, cw, ch), 0, 2);
		addWidget(new osgWidget::Frame::Border(osgWidget::Frame::BORDER_LEFT, cw, h), 1, 0);
		addWidget(new osgWidget::Frame::Border(osgWidget::Frame::BORDER_RIGHT, cw, wts._right), 1, 2);
		addWidget(new osgWidget::Frame::Corner(osgWidget::Frame::CORNER_UPPER_LEFT, cw, wts._top), 2, 0);
		addWidget(new osgWidget::Frame::Border(osgWidget::Frame::BORDER_TOP, w, wts._top), 2, 1);
		addWidget(new osgWidget::Frame::Corner(osgWidget::Frame::CORNER_UPPER_RIGHT, cw, wts._top), 2, 2);

		getCorner(CORNER_UPPER_LEFT)->setImage(wts._leftTopImage, true);
		getBorder(BORDER_TOP)->setImage(wts._topImage, true);
		getCorner(CORNER_UPPER_RIGHT)->setImage(wts._rightTopImage, true);
		getBorder(BORDER_LEFT)->setImage(wts._leftImage, true);
		getBorder(BORDER_RIGHT)->setImage(wts._rightImage, true);
		getCorner(CORNER_LOWER_LEFT)->setImage(wts._leftBottomImage, true);
		getBorder(BORDER_BOTTOM)->setImage(wts._bottomImage, true);
		getCorner(CORNER_LOWER_RIGHT)->setImage(wts._rightBottomImage, true);

		_topTitleWidget->setCloseButtonClickCallback(&CloudAtlasControlWindow::closeButtonClicked, this);
		_topTitleWidget->setDragCallback(&CloudAtlasControlWindow::dragEventCallback, this);
		osgWidget::point_type allHeight = h + ch + wts._top;
		resize(_windowWidth, allHeight);
	}
Exemplo n.º 2
0
void Cloth::printCorners() {
    int p0 = getCorner(0);
    int p1 = getCorner(1);
    int p2 = getCorner(2);
    int p3 = getCorner(3);

    std::cout<<"Corner 0 (R):"<<p0<<",at:"<<getPoint(p0)<<std::endl;
    std::cout<<"Corner 1 (G):"<<p1<<",at:"<<getPoint(p1)<<std::endl;
    std::cout<<"Corner 2 (B):"<<p2<<",at:"<<getPoint(p2)<<std::endl;
    std::cout<<"Corner 3 (W):"<<p3<<",at:"<<getPoint(p3)<<std::endl;
}
/*
 * getMidPoint
 *
 * parameter p0 - int
 * parameter p1 - int
 * return - float *
 */
float * BoundingBox::getMidPoint(int p0, int p1) {
	float * point0;
	float * point1;
	float * point;
	point0 = getCorner(p0);
	point1 = getCorner(p1);
	point = midPoint(point0, point1);
	delete[] point0;
	delete[] point1;
	return point;
} // end getMidPoint()
Exemplo n.º 4
0
//***************************for setup*****************************//
void Cloth::drawCorners(Graphic *g) {
    //RBGW
    g->setColor(Vector3(1,0,0));
    g->transform(&Graphic::drawUnitSphere,getPoint(getCorner(0)),0,
                 Vector3(.1,.1,.1));
    g->setColor(Vector3(0,1,0));
    g->transform(&Graphic::drawUnitSphere,getPoint(getCorner(1)),0,
                 Vector3(.1,.1,.1));
    g->setColor(Vector3(0,0,1));
    g->transform(&Graphic::drawUnitSphere,getPoint(getCorner(2)),0,
                 Vector3(.1,.1,.1));
    g->setColor(Vector3(1,1,1));
    g->transform(&Graphic::drawUnitSphere,getPoint(getCorner(3)),0,
                 Vector3(.1,.1,.1));
}
Exemplo n.º 5
0
void RS_Solid::draw(RS_Painter* painter, RS_GraphicView* view,
        double& /*patternOffset*/) {

    if (painter==NULL || view==NULL) {
        return;
    }

    RS_SolidData d = getData();
    if (isTriangle()) {
        painter->fillTriangle(view->toGui(getCorner(0)),
                              view->toGui(getCorner(1)),
                              view->toGui(getCorner(2)));
    }

}
// testface: given cube at lattice (i, j, k), and four corners of face,
// if surface crosses face, compute other four corners of adjacent cube
// and add new cube to cube stack
void IsoSurfacePolygonizer::testFace(int i, int j, int k, const StackedCube &oldCube, CubeFace face, CubeCorner c1, CubeCorner c2, CubeCorner c3, CubeCorner c4) {
  static int facebit[6] = {2, 2, 1, 1, 0, 0};
  int        bit        = facebit[face];
  bool       c1Positive = oldCube.m_corners[c1]->m_positive;

  // test if no surface crossing, cube out of bounds, or already visited:
  if(oldCube.m_corners[c2]->m_positive == c1Positive
  && oldCube.m_corners[c3]->m_positive == c1Positive
  && oldCube.m_corners[c4]->m_positive == c1Positive) {
    return;
  }

  // create new cube:
  StackedCube newCube(i, j, k,0);
  if(!addToDoneSet(newCube.m_key)) {
    return;
  }
  newCube.m_corners[FLIP(c1, bit)] = oldCube.m_corners[c1];
  newCube.m_corners[FLIP(c2, bit)] = oldCube.m_corners[c2];
  newCube.m_corners[FLIP(c3, bit)] = oldCube.m_corners[c3];
  newCube.m_corners[FLIP(c4, bit)] = oldCube.m_corners[c4];
  for(int n = 0; n < ARRAYSIZE(newCube.m_corners); n++) {
    if(newCube.m_corners[n] == NULL) {
      newCube.m_corners[n] = getCorner(i+BIT(n,2), j+BIT(n,1), k+BIT(n,0));
    }
  }

  if(  !m_boundingBox.contains(*newCube.m_corners[LBN])
    || !m_boundingBox.contains(*newCube.m_corners[RTF])) {
    return;
  }
  pushCube(newCube);
}
Exemplo n.º 7
0
bool Box::culledBy(
    const class Plane*  plane,
    int                 numPlanes,
	int&				cullingPlane,
	const uint32		_inMask,
    uint32&             childMask) const {

	uint32 inMask = _inMask;
	assert(numPlanes < 31);

    childMask = 0;

    // See if there is one plane for which all of the
	// vertices are in the negative half space.
    for (int p = 0; p < numPlanes; p++) {

		// Only test planes that are not masked
		if ((inMask & 1) != 0) {
		
			Vector3 corner;

            int numContained = 0;
            int v = 0;

            // We can early-out only if we have found one point on each
            // side of the plane (i.e. if we are straddling).  That
            // occurs when (numContained < v) && (numContained > 0)
			for (v = 0; (v < 8) && ((numContained == v) || (numContained == 0)); ++v) {
                if (plane[p].halfSpaceContains(getCorner(v))) {
                    ++numContained;
                }
			}

			if (numContained == 0) {
				// Plane p culled the box
				cullingPlane = p;

                // The caller should not recurse into the children,
                // since the parent is culled.  If they do recurse,
                // make them only test against this one plane, which
                // will immediately cull the volume.
                childMask = 1 << p;
				return true;

            } else if (numContained < v) {
                // The bounding volume straddled the plane; we have
                // to keep testing against this plane
                childMask |= (1 << p);
            }
		}

        // Move on to the next bit.
		inMask = inMask >> 1;
    }

    // None of the planes could cull this box
	cullingPlane = -1;
    return false;
}
Exemplo n.º 8
0
Box AABB::toBox()
{
	Box ret;
	for(int i =0;i<CORNERCOUNT;++i)
	{
		ret.vertices[i]= getCorner(static_cast<Corner>(i));
	}
	return ret;
}
Exemplo n.º 9
0
	CornerArray getCorners(const CornerTypeArray &order = Voxel::DEFAULT_ORDER) const {
		assert(order.size() == Corner::N_CORNERS);
		
		CornerArray tmp;
		
		u_int i = 0;
		CornerTypeArray::const_iterator tit;
		for (tit = order.begin(); tit != order.end(); ++tit) {
			tmp[i++] = getCorner(*tit);
		}
		
		return tmp;
	}
bool IsoSurfacePolygonizer::putInitialCube() {
  StackedCube cube(0,0,0, 0);
  m_cornerMap.clear();
  // set corners of initial cube:
  for(int i = 0; i < ARRAYSIZE(cube.m_corners); i++) {
    cube.m_corners[i] = getCorner(BIT(i,2), BIT(i,1), BIT(i,0));
  }
  if(cube.intersectSurface()) {
    addToDoneSet(cube.m_key);
    pushCube(cube);
    return true;
  }
  return false;
}
Exemplo n.º 11
0
bool ZIntCuboid::hasOverlap(const ZIntCuboid &box) const
{
  bool overlapped = false;
  for (int i = 0; i < 8; ++i) {
    if (contains(box.getCorner(i))) {
      overlapped = true;
      break;
    }

    if (box.contains(getCorner(i))) {
      overlapped = true;
      break;
    }
  }

  return overlapped;
}
Exemplo n.º 12
0
ZIntPoint ZIntCuboidFace::getCornerCoordinates(int index) const
{
  ZIntPoint pt;
  Corner corner = getCorner(index);
  switch (getAxis()) {
  case NeuTube::X_AXIS:
    pt.set(getPlanePosition(), corner.getX(), corner.getY());
    break;
  case NeuTube::Y_AXIS:
    pt.set(corner.getX(), getPlanePosition(), corner.getY());
    break;
  case NeuTube::Z_AXIS:
    pt.set(corner.getX(), corner.getY(), getPlanePosition());
    break;
  }

  return pt;
}
Exemplo n.º 13
0
bool Box::culledBy(
    const class Plane*  plane,
    int                 numPlanes,
	int&				cullingPlane,
	const uint32		_inMask) const {

	uint32 inMask = _inMask;
	assert(numPlanes < 31);

    // See if there is one plane for which all of the
	// vertices are in the negative half space.
    for (int p = 0; p < numPlanes; p++) {

		// Only test planes that are not masked
		if ((inMask & 1) != 0) {
		
			bool culled = true;

            int v;

			// Assume this plane culls all points.  See if there is a point
			// not culled by the plane... early out when at least one point
            // is in the positive half space.
			for (v = 0; (v < 8) && culled; ++v) {
                culled = ! plane[p].halfSpaceContains(getCorner(v));
			}

			if (culled) {
				// Plane p culled the box
				cullingPlane = p;

				return true;
            }
		}

        // Move on to the next bit.
		inMask = inMask >> 1;
    }

    // None of the planes could cull this box
	cullingPlane = -1;
    return false;
}
Exemplo n.º 14
0
void CAxisAlgnBB::render(int argb)
{
    SVertex verts[kNumCorners];
    WORD indexList[kMaxIndices] = {	0, 2, 3,
                                    3, 1, 0,
                                    7, 6, 4,
                                    4, 5, 7,
                                    4, 6, 2,
                                    2, 0, 4,
                                    1, 3, 7,
                                    7, 5, 1,
                                    4, 0, 1,
                                    1, 5, 4,
                                    2, 6, 7,
                                    7, 3, 2
                                  };

    // Fill in the 8 vertices
    for(int i = 0; i < kNumCorners; ++i)
    {
        CPos pos = getCorner(i);

        verts[i].x = pos.x;
        verts[i].y = pos.y;
        verts[i].z = pos.z;
        verts[i].color = argb;
    }

    // Render the AABB
    g3D->render(verts, kNumCorners, indexList, kMaxIndices);

    // Render lines on the top and bottom of the the front and
    // back sides of the box.  This allow us to see the full dimensions
    // of the AABB better.
    for(int i = 0; i < kNumCorners; ++i)
        verts[i].color = D3DCOLOR_ARGB(255, 255, 255, 255);

    g3D->renderLine(verts, kNumCorners);
}
Exemplo n.º 15
0
template <typename T> vector3d<T> aabbox3d<T>::getClosestPoint(const plane3d<T> &Plane) const
{
    vector3d<T> Result, Corner;
    
    T Distance = math::OMEGA;
    T Temp;
    
    for (s32 i = 0; i < 8; ++i)
    {
        Corner = getCorner(i);
        
        Temp = Plane.getPointDistance(Corner);
        
        if (Temp < Distance)
        {
            Result = Corner;
            Distance = Temp;
        }
    }
    
    return Result;
}
Exemplo n.º 16
0
//Check for cross with Diagonal line-segment defined from the top-L to bottom-R corner of square.
//If it crosses, perform actions with Cross()
bool MakeStackIcon::checkForCross(Vec3 currPoint, Vec3 prevPoint)
{
	Vec3 target[4];

	if (enabled)
	{
		// Create a bounding box where the StackIcon resides
		for (uint i = 0; i < 4; i++)
		{
			target[i] = WorldToClient(getCorner(i + 1));
			target[i].z = 0.0f;

			// Corner Index:
			// 1          2
			//  +--------+
			//  |        |
			//  |  ICON  |
			//  |        |
			//  +--------+
			// 3          0
		}

		// Crossing target is defined as -size/2 to size/2 on the z-axis, centered at 'position'
		if (currPoint.x >= target[3].x && currPoint.x <= target[0].x &&
			currPoint.y <= target[3].y && currPoint.y >= target[1].y)
		{
			// ensure that we're not hitting a straight line
			if (lassoMenu->getCurvatureRatio() > 1.2f)
			{
				return lassoMenu->isTailVectorPointingToStackIcon(20.0f);
			}
		}
	}

	return false;
}
Exemplo n.º 17
0
	Eigen::Vector3d getCorner(Corner::CornerType c) const {
		return getCorner(static_cast<u_char>(c));
	}
Exemplo n.º 18
0
template<> RotBox<3>& RotBox<3>::rotateCorner(const Quaternion& q, int corner)
{
  rotatePoint(q, getCorner(corner)); return *this;
}
Exemplo n.º 19
0
void Cloth::pinCorners() {
    this->createPin(getCorner(0));
    this->createPin(getCorner(1));
    this->createPin(getCorner(2));
    this->createPin(getCorner(3));
}
Exemplo n.º 20
0
Line3d           Triangle3d::getEdgeLine     ( int whichEdge ) const
{
    return Line3d(getCorner(whichEdge),getEdgeDir(whichEdge));
}
Exemplo n.º 21
0
Segment3d        Triangle3d::getEdgeSegment  ( int whichSegment ) const
{
    return Segment3d(getCorner(whichSegment),getCorner(whichSegment+1));
}
Exemplo n.º 22
0
Vector       Triangle3d::getEdgeDir  ( int whichEdge ) const
{
    return getCorner(whichEdge+1) - getCorner(whichEdge);
}
Exemplo n.º 23
0
 //! \brief Constrain a given vertex to a given node.
 //! \param item item Vertex index on patch.
 //! \param comp Component to constrain
 //! \param basis Basis to constrain vertex for.
 //! \param idx Global node to constrain edge to.
 void constrainVertex(int item, int comp, int basis, int idx)
 {
   int gn = bpch->getNodeID(getCorner(item, basis));
   if (gn != idx)
     bpch->add2PC(gn, comp, idx);
 }
Exemplo n.º 24
0
void AABB::render() const
{
// Minimum to avoid trouble when building on pure OpenGL ES systems
// Not sure about ANGLE!
#if !defined(QT_OPENGL_ES_2)
	Vec3f nbl = getCorner(MinMinMin);
	Vec3f nbr = getCorner(MaxMinMin);
	Vec3f ntr = getCorner(MaxMinMax);
	Vec3f ntl = getCorner(MinMinMax);
	Vec3f fbl = getCorner(MinMaxMin);
	Vec3f fbr = getCorner(MaxMaxMin);
	Vec3f ftr = getCorner(MaxMaxMax);
	Vec3f ftl = getCorner(MinMaxMax);

	glExtFuncs->glColor3f(1.0f, 1.0f, 1.0f);
	float oldLineWidth;
	glExtFuncs->glGetFloatv(GL_LINE_WIDTH, &oldLineWidth);
	glExtFuncs->glLineWidth(5);
	glExtFuncs->glBegin(GL_LINE_LOOP);
		//near plane
		glExtFuncs->glVertex3f(ntl.v[0],ntl.v[1],ntl.v[2]);
		glExtFuncs->glVertex3f(ntr.v[0],ntr.v[1],ntr.v[2]);
		glExtFuncs->glVertex3f(nbr.v[0],nbr.v[1],nbr.v[2]);
		glExtFuncs->glVertex3f(nbl.v[0],nbl.v[1],nbl.v[2]);
	glExtFuncs->glEnd();

	glExtFuncs->glBegin(GL_LINE_LOOP);
		//far plane
		glExtFuncs->glVertex3f(ftr.v[0],ftr.v[1],ftr.v[2]);
		glExtFuncs->glVertex3f(ftl.v[0],ftl.v[1],ftl.v[2]);
		glExtFuncs->glVertex3f(fbl.v[0],fbl.v[1],fbl.v[2]);
		glExtFuncs->glVertex3f(fbr.v[0],fbr.v[1],fbr.v[2]);
	glExtFuncs->glEnd();

	glExtFuncs->glBegin(GL_LINE_LOOP);
		//bottom plane
		glExtFuncs->glVertex3f(nbl.v[0],nbl.v[1],nbl.v[2]);
		glExtFuncs->glVertex3f(nbr.v[0],nbr.v[1],nbr.v[2]);
		glExtFuncs->glVertex3f(fbr.v[0],fbr.v[1],fbr.v[2]);
		glExtFuncs->glVertex3f(fbl.v[0],fbl.v[1],fbl.v[2]);
	glExtFuncs->glEnd();

	glExtFuncs->glBegin(GL_LINE_LOOP);
		//top plane
		glExtFuncs->glVertex3f(ntr.v[0],ntr.v[1],ntr.v[2]);
		glExtFuncs->glVertex3f(ntl.v[0],ntl.v[1],ntl.v[2]);
		glExtFuncs->glVertex3f(ftl.v[0],ftl.v[1],ftl.v[2]);
		glExtFuncs->glVertex3f(ftr.v[0],ftr.v[1],ftr.v[2]);
	glExtFuncs->glEnd();

	glExtFuncs->glBegin(GL_LINE_LOOP);
		//left plane
		glExtFuncs->glVertex3f(ntl.v[0],ntl.v[1],ntl.v[2]);
		glExtFuncs->glVertex3f(nbl.v[0],nbl.v[1],nbl.v[2]);
		glExtFuncs->glVertex3f(fbl.v[0],fbl.v[1],fbl.v[2]);
		glExtFuncs->glVertex3f(ftl.v[0],ftl.v[1],ftl.v[2]);
	glExtFuncs->glEnd();

	glExtFuncs->glBegin(GL_LINE_LOOP);
		// right plane
		glExtFuncs->glVertex3f(nbr.v[0],nbr.v[1],nbr.v[2]);
		glExtFuncs->glVertex3f(ntr.v[0],ntr.v[1],ntr.v[2]);
		glExtFuncs->glVertex3f(ftr.v[0],ftr.v[1],ftr.v[2]);
		glExtFuncs->glVertex3f(fbr.v[0],fbr.v[1],fbr.v[2]);
	glExtFuncs->glEnd();
	glExtFuncs->glLineWidth(oldLineWidth);
#endif
}