/*
 * getCorner
 *
 * parameter which - int
 * return corner - float *
 */
float * BoundingBox::getCorner(int which) {
	float * point = new float[3];
	point[0]=data[corner(which,0)];
	point[1]=data[corner(which,1)];
	point[2]=data[corner(which,2)];
	return point;
} // end getCorner()
Beispiel #2
0
	namespace Numerics
	{
		UnitTest::Suite MatrixProjectionsTestSuite {
			"Euclid::Numerics::Matrix",

			{"Clip Space Orthographic Projection",
				[](UnitTest::Examiner & examiner) {
					// This is the natural clip space box:
					auto unit_box = Geometry::AlignedBox3::from_origin_and_size(Vec3{-1, -1, 0}, Vec3{2, 2, 1});
					
					auto projection = orthographic_projection_matrix(unit_box);
					
					examiner << "The unit projection should be the identity" << std::endl;
					examiner.expect(projection) == Mat44(IDENTITY);
				}
			},
			
			{"Unit Space Orthographic Projection",
				[](UnitTest::Examiner & examiner) {
					// This is the natural clip space box:
					auto unit_box = Geometry::AlignedBox3::from_center_and_size(ZERO, Vec3{2, 2, 2});
					
					auto projection = orthographic_projection_matrix(unit_box);
					
					examiner.expect(projection * unit_box.corner({false, false, false})) == Vec3{-1, -1, 0};
					examiner.expect(projection * unit_box.corner({true, true, true})) == Vec3{1, 1, 1};
				}
			},
		};
	}
Beispiel #3
0
bool peano::geometry::builtin::Tube::
isCompletelyInsideNotInverted( const tarch::la::Vector<DIMENSIONS,double>& x, const tarch::la::Vector<DIMENSIONS,double> &resolution ) {
    tarch::la::Vector<DIMENSIONS,double> coords(0.0);
    tarch::la::Vector<DIMENSIONS,int> corner(0);
    bool isInside = true;

    // loop over the corners
    for (int i = 0; i < TWO_POWER_D; i++) {
        for (int d = 0; d < DIMENSIONS; d++) {
            coords(d) = (2*corner(d)-1)*resolution(d);
        }
        coords = coords + x;
        // let N be the point on the middle line of the tube, such that (x-N) is orthogonal to the middle line.
        // Then N = P1 + lambda*(P2-P1)
        double lambda = tarch::la::dot( (coords-_p1),_middleLine)/(tarch::la::dot(_middleLine,_middleLine));

        tarch::la::Vector<DIMENSIONS,double> N(_p1 + lambda*_middleLine);
        // compute distance from middle line
        double distance = tarch::la::dot(coords-N,coords-N);

        isInside = isInside && (!(distance > _radius*_radius))
                   && (!(lambda<0.0)) && (!(lambda>1.0));

        // go to next corner node
        peano::utils::dInc(corner,2);
    }

    return isInside;
}
Beispiel #4
0
void TeamIndicator::animate(Frame *space)
{
	STACKTRACE;
	if (!*indtoggle)
		return;

	if (mother->isInvisible())
		return;

	Vector2i co1, co2;

	co1 = corner(mother->pos - 0.5 * mother->size).round();
	co2 = corner(mother->pos + 0.5 * mother->size).round();

	if (co2.x < 0) return;
	if (co2.y < 0) return;
	if (co1.x >= space->surface->w) return;
	if (co1.y >= space->surface->h) return;

	int col;
								 // team 0 is black ...
	col = palette_color[mother->get_team() + 1];

	rect(space->surface, co1.x, co1.y, co2.x, co2.y, col);
	space->add_box(co1.x, co1.y, co2.x, co2.y);

}
Beispiel #5
0
    void Ellipse::updateHandles()
    {
        Element::updateHandles();

        m_data->centerHandle.setPos(Point(corner().x() + width() / 2,
                                          corner().y() + height() / 2));
    }
Beispiel #6
0
bool peano::geometry::builtin::CuttingPlane::isCompletelyOutside(
  const tarch::la::Vector<DIMENSIONS,double>& x, const tarch::la::Vector<DIMENSIONS,double> &resolution ){
  bool isCompletelyOutside = true;
  bool isOnBoundary = true;

  tarch::la::Vector<DIMENSIONS,int> corner(0);
  tarch::la::Vector<DIMENSIONS,double> coords(0.0);

  //  a point is completely outside, if all corners of the surrounding rectangle/box of size 2*resolution are on the
  // "outer" side of the plane, i.e. the scalar product between normal and corner-_position-distance needs to be
  // bigger than zero for all corners!
  for (int i = 0; i < TWO_POWER_D; i++){
    for (int d = 0; d < DIMENSIONS; d++){
      coords(d) = (2*corner(d)-1)*resolution(d);
    }
    peano::utils::dInc(corner,2);
    coords = x+coords-_position;

    // if the dot-product is bigger/equal zero, the original point might be considered to be completely outside,
    // except for the case that...
    isCompletelyOutside = isCompletelyOutside && (!tarch::la::smaller(_normal*coords,0.0));
    // ... the meshsize is 0.0: we need to check if all points are located on the boundary (which is actually only the
    // current point). If so, this point cannot be completely outside.
    isOnBoundary = isOnBoundary && (tarch::la::equals(_normal*coords,0.0));
  }

  return isCompletelyOutside && (!isOnBoundary);
}
/*
 * getCenter
 *
 * return - float *
 */
float * BoundingBox::getCenter(void) {
	float * point = new float[3];
	point[0]=data[corner(0,0)] + (data[corner(7,0)] - data[corner(0,0)]) * 0.5f;
	point[1]=data[corner(0,1)] + (data[corner(7,1)] - data[corner(0,1)]) * 0.5f;
	point[2]=data[corner(0,2)] + (data[corner(7,2)] - data[corner(0,2)]) * 0.5f;
	return point;
} // end getCenter()
double MxBlockModel::compute_corner_angle(MxFaceID f, unsigned long i)
{
    unsigned long i_prev = (i==0)?2:i-1;
    unsigned long i_next = (i==2)?0:i+1;

    Vec3 e_prev = corner(f, i_prev) - corner(f, i);
    e_prev.Normalize();
    Vec3 e_next = corner(f, i_next) - corner(f, i);
    e_next.Normalize();

    return acos(e_prev * e_next);
}
 inline Segment3f operator*(Segment3f const& segment, Matrix43f const& matrix) {
     Segment3f transformedSegment = Segment3f::NOTHING;
     for (int i = 0; i < 8; ++i) {
         transformedSegment |= Segment3f(corner(segment, i) * matrix);
     }
     return transformedSegment;
 }
Beispiel #10
0
// Thanks to http://www.qtcentre.org/threads/3205-Toplevel-widget-with-rounded-corners?p=17492#post17492
QRegion QzTools::roundedRect(const QRect &rect, int radius)
{
    QRegion region;

    // middle and borders
    region += rect.adjusted(radius, 0, -radius, 0);
    region += rect.adjusted(0, radius, 0, -radius);

    // top left
    QRect corner(rect.topLeft(), QSize(radius * 2, radius * 2));
    region += QRegion(corner, QRegion::Ellipse);

    // top right
    corner.moveTopRight(rect.topRight());
    region += QRegion(corner, QRegion::Ellipse);

    // bottom left
    corner.moveBottomLeft(rect.bottomLeft());
    region += QRegion(corner, QRegion::Ellipse);

    // bottom right
    corner.moveBottomRight(rect.bottomRight());
    region += QRegion(corner, QRegion::Ellipse);

    return region;
}
Beispiel #11
0
void BasiliskAreaHurt::animate(Frame *space)
{
	STACKTRACE;
	if (state == 0)
		return;
	int i, j;
	double t = 1 - life_counter/(double)lifetime;
	double  x0, y0, dx, dy;
	int xi, yi;
	Vector2 p0;
	drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
	for (i=0; i<num; i++) {
		p0 = corner(xp[i]);
		x0 = p0.x;
		y0 = p0.y;
		p0 = unit_vector(xv[i]) * 3 * space_zoom;
		dx = p0.x;
		dy = p0.y;
		for (j=3; j>=0; j--) {
			if (space_zoom <= 1)
				set_trans_blender(0, 0, 0, iround(space_zoom * 255 * t * (4-j) / 4.0));
			else
				set_trans_blender(0, 0, 0, iround(1 * 255 * t * (4-j) / 4.0));
			xi = iround(x0 - dx * j);
			yi = iround(y0 - dy * j);
			putpixel(space->surface, xi, yi, color);
			space->add_pixel(xi, yi);
		}
	}
	drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
}
Beispiel #12
0
QRegion BusyDialog::roundedRect(const QRect &rect, int round)
{
    QRegion region;

    // middle and borders
    region += rect.adjusted(round, 0, -round, 0);
    region += rect.adjusted(0, round, 0, -round);

    // top left
    QRect corner(rect.topLeft(), QSize(round*2, round*2));
    region += QRegion(corner, QRegion::Ellipse);

    // top right
    corner.moveTopRight(rect.topRight());
    region += QRegion(corner, QRegion::Ellipse);

    // bottom left
    corner.moveBottomLeft(rect.bottomLeft());
    region += QRegion(corner, QRegion::Ellipse);

    // bottom right
    corner.moveBottomRight(rect.bottomRight());
    region += QRegion(corner, QRegion::Ellipse);

    return region;
}
Beispiel #13
0
void RainbowRift::animate( Frame *frame )
{
	STACKTRACE;
	if (spawn_counter > 0) return;
	Vector2 s;
	s = corner(pos, Vector2(300,300));
	if ((s.x < -500) || (s.x > space_view_size.x + 500) ||
		(s.y < -500) || (s.y > space_view_size.y + 500))
		return;
	int b[n*6+2];
	int i;
	for (i = 0; i < n*6+2; i += 2) {
		b[i] = iround(s.x + p[i] * space_zoom);
		b[i+1] = iround(s.y + p[i+1] * space_zoom);
	}
	for (i = 0; i < n; i += 1) {
		RGB tc = c[n-i-1];
		int a = tw_color(tc.r, tc.g, tc.b);
		spline ( frame->surface, &b[i*6], a );
	}
	frame->add_box (
		iround(s.x - 2), iround(s.y -2),
		iround(300 * space_zoom+5), iround(300 * space_zoom+5)
		);
	return;
}
void ossimTiledElevationDatabase::getBoundingRect(
   ossimRefPtr<ossimImageGeometry> geom, ossimGrect& boundingRect) const
{
   if ( geom.valid() )
   {
      std::vector<ossimGpt> corner(4);
      if ( geom->getCornerGpts(corner[0], corner[1], corner[2], corner[3]) )
      {
         ossimGpt ulGpt(corner[0]);
         ossimGpt lrGpt(corner[0]);
         for ( ossim_uint32 i = 1; i < 4; ++i )
         {
            if ( corner[i].lon < ulGpt.lon ) ulGpt.lon = corner[i].lon;
            if ( corner[i].lat > ulGpt.lat ) ulGpt.lat = corner[i].lat;
            if ( corner[i].lon > lrGpt.lon ) lrGpt.lon = corner[i].lon;
            if ( corner[i].lat < lrGpt.lat ) lrGpt.lat = corner[i].lat;
         }
         boundingRect = ossimGrect(ulGpt, lrGpt);
      }
      else
      {
         boundingRect.makeNan();
      }
   }
}
Beispiel #15
0
void LLToolBrushLand::determineAffectedRegions(region_list_t& regions,
											   const LLVector3d& spot ) const
{
	LLVector3d corner(spot);
	corner.mdV[VX] -= (mBrushSize / 2);
	corner.mdV[VY] -= (mBrushSize / 2);
	LLViewerRegion* region = NULL;
	region = LLWorld::getInstance()->getRegionFromPosGlobal(corner);
	if(region && regions.find(region) == regions.end())
	{
		regions.insert(region);
	}
	corner.mdV[VY] += mBrushSize;
	region = LLWorld::getInstance()->getRegionFromPosGlobal(corner);
	if(region && regions.find(region) == regions.end())
	{
		regions.insert(region);
	}
	corner.mdV[VX] += mBrushSize;
	region = LLWorld::getInstance()->getRegionFromPosGlobal(corner);
	if(region && regions.find(region) == regions.end())
	{
		regions.insert(region);
	}
	corner.mdV[VY] -= mBrushSize;
	region = LLWorld::getInstance()->getRegionFromPosGlobal(corner);
	if(region && regions.find(region) == regions.end())
	{
		regions.insert(region);
	}
}
// In this example, tool tips were set up to
// pop up when the user moves the mouse
// over this edit control.
// If the mouse is moved to the upper left-hand
// corner, the tool tip would disappear because of
// calling CancelToolTips.
void CMyEdit::OnMouseMove(UINT nFlags, CPoint point) 
{
   CRect corner(0, 0, 10, 10);
   if (corner.PtInRect(point))
      CancelToolTips();
   CEdit::OnMouseMove(nFlags, point);
}
Beispiel #17
0
    bool GetExtent(const Transform &inTransform,Extent2DF &ioExtent, bool)
    {
        /*
        printf("In extent %f,%f ... %f,%f\n",
               ioExtent.mMinX, ioExtent.mMinY,
               ioExtent.mMaxX, ioExtent.mMaxY );
        */

        for(int i=0; i<mTileData.size(); i++)
        {
            TileData &data= mTileData[i];
            for(int c=0; c<4; c++)
            {
                UserPoint corner(data.mPos);
                if (c&1) corner.x += data.mRect.w;
                if (c&2) corner.y += data.mRect.h;
                ioExtent.Add( inTransform.mMatrix->Apply(corner.x,corner.y) );
            }
        }
        /*
        printf("Got extent %f,%f ... %f,%f\n",
               ioExtent.mMinX, ioExtent.mMinY,
               ioExtent.mMaxX, ioExtent.mMaxY );
        */
        return true;
    }
Beispiel #18
0
void AyronShipPart::animate(Frame *space)
{
	STACKTRACE;
	SpaceSprite *spr;

	if (!hascrew())
		spr = sprite_uncrewed;
	else
		spr = sprite;

	// the aa_stretch_blit scales down too much (dunno why).
	// use the usual stretch_blit instead ?

	Vector2 P, S, W;

	S = spr->size(sprite_index);
	P = corner(pos, S );
	W = S * space_zoom;

	BITMAP *b;
	b = spr->get_bitmap(sprite_index);

	masked_stretch_blit(b, space->surface, 0, 0, b->w, b->h, iround(P.x), iround(P.y), iround(W.x), iround(W.y));
	//aa_stretch_sprite(b, space->surface, iround(P.x), iround(P.y), iround(W.x), iround(W.y));
	space->add_box(P.x, P.y, W.x, W.y);
}
Beispiel #19
0
bool WorldCrop::isChunkCompletelyContained(const mc::ChunkPos& chunk) const {
	mc::BlockPos corner(chunk.x * 16, chunk.z * 16, 0);
	return isBlockContainedXZ(corner)
			&& isBlockContainedXZ(corner + mc::BlockPos(15, 0, 0))
			&& isBlockContainedXZ(corner + mc::BlockPos(0, 15, 0))
			&& isBlockContainedXZ(corner + mc::BlockPos(15, 15, 0));
}
Beispiel #20
0
    Camera::Camera(const vec3& position, const vec3& rot, float fov) :
        m_Position(position), m_Rotation(rot), m_Fov(fov)
    {
        auto x = -((float)FRAME_WIDTH / (float)FRAME_HEIGHT);
        auto y = 1.f;

        vec3 corner(x, y, 1);
        vec3 center(0, 0, 1);

        auto scaling = tan(radians(m_Fov * 0.5f)) / (corner - center).length();

        x *= scaling;
        y *= scaling;

        m_RotationMatrix = CreateRotationMatrix(m_Rotation);
        m_TopLeft = vec3(m_RotationMatrix * vec4(x, y, 1, 1));
        m_TopRight = vec3(m_RotationMatrix * vec4(-x, y, 1, 1));
        m_DownLeft = vec3(m_RotationMatrix * vec4(x, -y, 1, 1));

        m_UpDir = vec3(m_RotationMatrix * vec4(0, 1, 0, 1));
        m_RightDir = vec3(m_RotationMatrix * vec4(1, 0, 0, 1));
        m_FrontDir = vec3(m_RotationMatrix * vec4(0, 0, 1, 1));

        m_TopLeft += m_Position;
        m_TopRight += m_Position;
        m_DownLeft += m_Position;
    }
Beispiel #21
0
    virtual void onDrawContent(SkCanvas* canvas) {
        SkScalar intervals[8] = { .5f, .3f, .5f, .3f, .5f, .3f, .5f, .3f };
        SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, fPhase));
        SkAutoTUnref<SkCornerPathEffect> corner(SkCornerPathEffect::Create(.25f));
        SkAutoTUnref<SkComposePathEffect> compose(SkComposePathEffect::Create(dash, corner));

        SkPaint outlinePaint;
        outlinePaint.setAntiAlias(true);  // dashed paint for bitmap
        outlinePaint.setStyle(SkPaint::kStroke_Style);
        outlinePaint.setPathEffect(compose);

        canvas->scale(10.0f, 10.0f);  // scales up

        for (int i = 0; i < fNumBits; ++i) {
            canvas->save();
            for (size_t j = 0; j < SK_ARRAY_COUNT(gBitsToPath_fns); ++j) {
                SkPath path;
                gBitsToPath_fns[j](&path, (char*) &gBits[i], fW, fH, fRowBytes);

                //draw skPath and outline
                canvas->drawPath(path, fBmpPaint);
                canvas->translate(1.5f * fW, 0); // translates past previous bitmap
                canvas->drawPath(path, outlinePaint);
                canvas->translate(1.5f * fW, 0); // translates past previous bitmap
            }
            canvas->restore();
            canvas->translate(0, 1.5f * fH); //translate to next row
        }

        // for animated pathEffect
        fPhase += .01f;
        this->inval(NULL);
    }
float SimpleSkeletonGrower::compute_potential_energy(BDLSkeletonNode *root, const SimpleVolumeFloat& space)
{
	float ret = 23418715.0f;
	if(!root || space._box.empty())
		return ret;

	ret = 0.0f; // will it overflow?

	//overview: put negative charges at node and find the total potential energy of the tree
	float v_height = space._sizeX;
	osg::Vec3 corner(-v_height/2.0f, -v_height/2.0f, 0.0f);

	//bfs
	std::queue <BDLSkeletonNode *> Queue;
	Queue.push(root);

	while(!Queue.empty())
	{
		BDLSkeletonNode *front = Queue.front();
		Queue.pop();

		osg::Vec3 cur = Transformer::toVec3(front) - corner;
		ret += space.count(cur.x(), cur.y(), cur.z()); //negative charge

		for(unsigned int i=0; i<front->_children.size(); i++)
			Queue.push(front->_children[i]);
	}

	return ret;
}
Foam::pointField Foam::treeBoundBox::points() const
{
    pointField points(8);
    forAll(points, octant)
    {
        points[octant] = corner(octant);

    }
Beispiel #24
0
std::vector< std::pair<Vector3d, double> > SurfaceCard::getMacrobodyPlaneParams() const {
  
  std::vector< std::pair< Vector3d, double> > ret;
  if( mnemonic == "box" ){
    Vector3d corner( args );
    const Vector3d v[3] = {Vector3d(args,3), Vector3d(args,6), Vector3d(args,9)};

    // face order: v1 -v1 v2 -v2 v3 -v3
    for( int i = 0; i < 3; ++i ){
      Vector3d p = corner + v[i];
      ret.push_back( std::make_pair( v[i].normalize(), v[i].projection( p ).length() ) );
      ret.push_back( std::make_pair( -v[i].normalize(), v[i].projection( p ).length()-v[i].length() ) );
    }

  }
  else if( mnemonic == "rpp" ){
    Vector3d min( args.at(0), args.at(2), args.at(4) );
    Vector3d max( args.at(1), args.at(3), args.at(5) );

    for( int i = 0; i < 3; ++i ){
      Vector3d v; v.v[i] = 1;
      ret.push_back( std::make_pair( v.normalize(), max.v[i] ));
      ret.push_back( std::make_pair(-v.normalize(), min.v[i] ));
    }

  }
  else if( mnemonic == "hex" || mnemonic == "rhp" ){

    Vector3d vertex( args ), height( args,3 ), RV( args, 6 ), SV, TV;
    if( args.size() == 9 ){
      SV = RV.rotate_about(height, 60); TV = RV.rotate_about(height, 120);
    }
    else{
      SV = Vector3d( args, 9 ); TV = Vector3d( args, 12 );
    }
    
    double len = RV.projection( vertex+RV ).length();
    ret.push_back( std::make_pair( RV.normalize(), len ) );
    ret.push_back( std::make_pair(-RV.normalize(), len - 2.0 * RV.length() ));
    
    len = SV.projection( vertex+SV ).length();
    ret.push_back( std::make_pair( SV.normalize(), len ) );
    ret.push_back( std::make_pair(-SV.normalize(), len - 2.0 * SV.length() ));

    len = TV.projection( vertex+TV ).length();
    ret.push_back( std::make_pair( TV.normalize(), len ) );
    ret.push_back( std::make_pair(-TV.normalize(), len - 2.0 * TV.length() ));

    len = height.projection( vertex+height ).length();
    ret.push_back( std::make_pair( height.normalize(), len ) );
    ret.push_back( std::make_pair(-height.normalize(), len - height.length() ));

  }
  else{ 
    throw std::runtime_error("Tried to get macrobody plane normals of unsupported surface!" );
  }
  return ret;
}
Beispiel #25
0
void InternalToolBox::restore(const KConfigGroup &containmentGroup)
{
    KConfigGroup group = KConfigGroup(&containmentGroup, "ToolBox");

    if (!group.hasKey("corner")) {
        return;
    }

    m_userMoved = true;
    setCorner(Corner(group.readEntry("corner", int(corner()))));

    const int offset = group.readEntry("offset", 0);
    const int w = boundingRect().width();
    const int h = boundingRect().height();
    const int maxW = m_containment ? m_containment->geometry().width() - w : offset;
    const int maxH = m_containment ? m_containment->geometry().height() - h : offset;
    switch (corner()) {
        case InternalToolBox::TopLeft:
            setPos(0, 0);
            break;
        case InternalToolBox::Top:
            setPos(qMin(offset, maxW), 0);
            break;
        case InternalToolBox::TopRight:
            setPos(m_containment->size().width() - boundingRect().width(), 0);
            break;
        case InternalToolBox::Right:
            setPos(m_containment->size().width() - boundingRect().width(), qMin(offset, maxH));
            break;
        case InternalToolBox::BottomRight:
            setPos(m_containment->size().width() - boundingRect().width(), m_containment->size().height() - boundingRect().height());
            break;
        case InternalToolBox::Bottom:
            setPos(qMin(offset, maxW), m_containment->size().height() - boundingRect().height());
            break;
        case InternalToolBox::BottomLeft:
            setPos(0, m_containment->size().height() - boundingRect().height());
            break;
        case InternalToolBox::Left:
            setPos(0, qMin(offset, maxH));
            break;
    }
    //kDebug() << "marked as user moved" << pos()
    //         << (m_containment->containmentType() == Containment::PanelContainment);
}
void base_visualizer_client::zoom(const coord<float> &mins, const coord<float> &maxs)
{
    float scale = std::max(maxs.x - mins.x, maxs.y - mins.y);
    coord<float> corner (maxs.x, mins.y);
    pscope_->reset_scope(corner, 1000.0f / scale);

    cout << "Mins: " << mins << endl;
    cout << "Maxs: " << maxs << endl;
}
Beispiel #27
0
void AaVoxelScene::voxelizeScene(XMFLOAT3 orthoHalfSize, XMFLOAT3 offset)
{

	D3D11_VIEWPORT viewport;
	viewport.Width = static_cast<float>(size);
	viewport.Height = static_cast<float>(size);
	viewport.MinDepth = 0.0f;
	viewport.MaxDepth = 1.0f;
	viewport.TopLeftX = 0.0f;
	viewport.TopLeftY = 0.0f;
	mSceneMgr->getRenderSystem()->getContext()->RSSetViewports( 1, &viewport );
	mSceneMgr->getRenderSystem()->setRenderTargets(0,0,false);

	AaMaterial* voxMat = mSceneMgr->getMaterial("VoxelizationMat");
	AaMaterial* lvoxMat = mSceneMgr->getMaterial("LightVoxelizationMat");
	AaMaterial* voxMat2 = mSceneMgr->getMaterial("PartVoxelizationMat");
	AaMaterial* shMat = mSceneMgr->getMaterial("depthWriteAndVoxel");
	AaMaterial* caMat = mSceneMgr->getMaterial("depthWriteAndCaustic");

	XMFLOAT3 corner(offset.x-orthoHalfSize.x,offset.y-orthoHalfSize.y,offset.z-orthoHalfSize.z);
	voxMat->setMaterialConstant("sceneCorner",Shader_type_pixel,&corner.x);
	lvoxMat->setMaterialConstant("sceneCorner",Shader_type_pixel,&corner.x);
	voxMat2->setMaterialConstant("sceneCorner",Shader_type_pixel,&corner.x);
	shMat->setMaterialConstant("sceneCorner",Shader_type_pixel,&corner.x);
	caMat->setMaterialConstant("sceneCorner",Shader_type_pixel,&corner.x);

	float sceneToVoxel = size/(2*orthoHalfSize.x);
	voxMat->setMaterialConstant("voxelSize",Shader_type_pixel,&sceneToVoxel);
	lvoxMat->setMaterialConstant("voxelSize",Shader_type_pixel,&sceneToVoxel);
	voxMat2->setMaterialConstant("voxelSize",Shader_type_pixel,&sceneToVoxel);
	shMat->setMaterialConstant("voxelSize",Shader_type_pixel,&sceneToVoxel);
	caMat->setMaterialConstant("voxelSize",Shader_type_pixel,&sceneToVoxel);
	

	voxelizingLookCamera->setOrthograhicCamera(orthoHalfSize.x*2,orthoHalfSize.y*2,1,1+orthoHalfSize.z*2+200);
	mSceneMgr->setCurrentCamera(voxelizingLookCamera);	

	voxelizingLookCamera->setPosition(XMFLOAT3(offset.x,offset.y,offset.z-orthoHalfSize.z-1));
	voxelizingLookCamera->lookAt(offset);	
	mSceneMgr->renderSceneWithMaterial(voxMat,true,1,5);
	mSceneMgr->renderSceneWithMaterial(lvoxMat,true,0,0);

	voxelizingLookCamera->setPosition(XMFLOAT3(offset.x-orthoHalfSize.x-1,offset.y,offset.z));
	voxelizingLookCamera->lookAt(offset);
	mSceneMgr->renderSceneWithMaterial(voxMat,true,1,5);
	mSceneMgr->renderSceneWithMaterial(lvoxMat,true,0,0);

	voxelizingLookCamera->setPosition(XMFLOAT3(offset.x,offset.y-orthoHalfSize.y*2-1,offset.z));
	voxelizingLookCamera->pitch(3.14/2.0f);
	mSceneMgr->renderSceneWithMaterial(voxMat,true,1,5);
	mSceneMgr->renderSceneWithMaterial(lvoxMat,true,0,0);

	//customMipmapping();
	//mSceneMgr->getRenderSystem()->getContext()->GenerateMips(fVoxelSRV);
	//mSceneMgr->getRenderSystem()->getContext()->GenerateMips(voxelShadowSRV);

}
Beispiel #28
0
TilePoint Tile::drawTile(Point3 p, float edges[4], TileParam& t, int id, int dir) {
	float hEdgeW = t.edgeWidth * .5f;
	float hEdgeH = t.edgeHeight * .5f;
			
	float randomSeed = (float)id * 1.23f + 0.1234f;
	if (dir) {
		edges[0] += t.eH_var ? hEdgeH * (1.f + noise(edges[0], randomSeed) * t.edgeHeightVar) : hEdgeH;
		edges[2] -= t.eH_var ? hEdgeH * (1.f + noise(edges[2], randomSeed) * t.edgeHeightVar) : hEdgeH;
		edges[3] += t.eW_var ? hEdgeW * (1.f + noise(edges[3], randomSeed) * t.edgeWidthVar) : hEdgeW;
		edges[1] -= t.eW_var ? hEdgeW * (1.f + noise(edges[1], randomSeed) * t.edgeWidthVar) : hEdgeW;
	} else {
		edges[0] += t.eW_var ? hEdgeW * (1.f + noise(edges[0], randomSeed) * t.edgeWidthVar) : hEdgeW;
		edges[2] -= t.eW_var ? hEdgeW * (1.f + noise(edges[2], randomSeed) * t.edgeWidthVar) : hEdgeW;
		edges[3] += t.eH_var ? hEdgeH * (1.f + noise(edges[3], randomSeed) * t.edgeHeightVar) : hEdgeH;
		edges[1] -= t.eH_var ? hEdgeH * (1.f + noise(edges[1], randomSeed) * t.edgeHeightVar) : hEdgeH;
	}

	if (p.x < edges[0]) return TilePoint();
	if (p.x > edges[2]) return TilePoint();
	if (p.y < edges[3]) return TilePoint();
	if (p.y > edges[1]) return TilePoint();

	float width = edges[2] - edges[0];
	float height = edges[1] - edges[3];
	if (width < 0 || height < 0) return TilePoint();

	TilePoint tp = corner(p.x - edges[0], p.y - edges[3], width, height, t);	
	if (tp.d < 0) return tp; // On edge

	//if (t.tileID || t.mapUV)
		tp.id = id;

	if (t.center || (t.mapUV && dir))
		tp.center = Point3(edges[0] + (edges[2] - edges[0]) * .5f,
		                   edges[3] + (edges[1] - edges[3]) * .5f, p.z);

	if (dir) {
		offsetEdges(edges, -tp.center.x, -tp.center.y);
		rotate90(edges[0], edges[3]);
		rotate90(edges[2], edges[1]);
		offsetEdges(edges, tp.center.x, tp.center.y);
		p -= tp.center; rotate90(p.x, p.y); p += tp.center;
	}
	
	if (t.mapUV)
		uvMapping(tp, p, edges, t, dir);

	if (dir) {
		offsetEdges(edges, -tp.center.x, -tp.center.y);
		rotate270(edges[0], edges[3]);
		rotate270(edges[2], edges[1]);
		offsetEdges(edges, tp.center.x, tp.center.y);
		p -= tp.center; rotate270(p.x, p.y); p += tp.center;
	}

	return tp;	
}
Beispiel #29
0
void MainWindow::on_cornerButton_released()
{
    DialogCorner corner(this);
    if(corner.exec())
       ui->glwidget->scene.addCorner( corner.getMinX(), corner.getMinY(), corner.getMinZ(),
                                      corner.getMidX(), corner.getMidY(), corner.getMidZ(),
                                      corner.getMaxX(), corner.getMaxY(), corner.getMaxZ() );

    ui->glwidget->updateGL();
}
Beispiel #30
0
/** @brief Transform the rectangle by an affine.
 * The result of the transformation might not be axis-aligned. The return value
 * of this operation will be the smallest axis-aligned rectangle containing
 * all points of the true result. */
Rect &Rect::operator*=(Affine const &m) {
    Point pts[4];
    for (unsigned i=0; i<4; ++i) pts[i] = corner(i) * m;
    Coord minx = std::min(std::min(pts[0][X], pts[1][X]), std::min(pts[2][X], pts[3][X]));
    Coord miny = std::min(std::min(pts[0][Y], pts[1][Y]), std::min(pts[2][Y], pts[3][Y]));
    Coord maxx = std::max(std::max(pts[0][X], pts[1][X]), std::max(pts[2][X], pts[3][X]));
    Coord maxy = std::max(std::max(pts[0][Y], pts[1][Y]), std::max(pts[2][Y], pts[3][Y]));
    f[X].setMin(minx); f[X].setMax(maxx);
    f[Y].setMin(miny); f[Y].setMax(maxy);
    return *this;
}