Example #1
0
OSG_BASE_DLLMAPPING 
void extend(SphereVolume &srcVol, const CylinderVolume &vol)
{
    Pnt3f   min, max, min1, max1, min2, max2, c;
    Real32  r;

    if((!srcVol.isValid   () && !srcVol.isEmpty()) ||
         srcVol.isInfinite()                       ||
         srcVol.isStatic  ()                         )
    {
        return;
    }

    if(!vol.isValid())
        return;

    if(srcVol.isEmpty())
    {
        if(vol.isEmpty())
        {
            return;
        }
        else
        {
            vol.getBounds(min, max);
            vol.getCenter(c);

            r = (min - c).length();

            srcVol.setValue(c, r);

            return;
        }
    }
    else if(vol.isEmpty())
    {
        return;
    }

    srcVol.getBounds(min,  max);
    vol   .getBounds(min1, max1);

    min2 = Pnt3f(osgMin(min.x(), min1.x()), 
                 osgMin(min.y(), min1.y()),
                 osgMin(min.z(), min1.z()));

    max2 = Pnt3f(osgMax(max.x(), max1.x()), 
                 osgMax(max.y(), max1.y()),
                 osgMax(max.z(), max1.z()));

    c = Pnt3f((min2.x() + max2.x()) * 0.5f, 
              (min2.y() + max2.y()) * 0.5f,
              (min2.z() + max2.z()) * 0.5f);

    r = ((max2 - min2).length()) * 0.5f;

    srcVol.setValue(c, r);

    return;
}
Example #2
0
void SkeletonDrawable::adjustVolume(Volume & volume)
{
    Inherited::adjustVolume(volume);

    //Extend the volume by all the Root Joints of Skeleton
    if(getSkeleton() == NULL)
    {
        FWARNING(("SkeletonDrawable::drawPrimitives:: no skeleton!\n"));;
    }
    else
    {
        Pnt3f JointLocation(0.0,0.0,0.0);
        for(UInt32 i(0) ; i<getSkeleton()->getNumJoints() ; ++i)
        {
            JointLocation.setValues(0.0,0.0,0.0);
            if(getDrawPose())
            {
                getSkeleton()->getAbsoluteTransformation(i).mult(Pnt3f(0.0f,0.0f,0.0f),JointLocation);
                volume.extendBy(JointLocation);
            }
            if(getDrawBindPose())
            {
                getSkeleton()->getAbsoluteBindTransformation(i).mult(Pnt3f(0.0f,0.0f,0.0f),JointLocation);
                volume.extendBy(JointLocation);
            }
        }
    }

}
Example #3
0
OSG_USING_NAMESPACE

Particles::Particles(std::string fileName, bool makeClone)
{
	int i;

	particleSystemInfo.pConfigFile = new char[512];
  	sprintf( (char *)particleSystemInfo.pConfigFile, "%s/effect.xml", fileName.c_str());
	particleSystemInfo.rUpdatesPerSecond = 30;
	particleSystemInfo.iRandomSeed = time( NULL );
	particleSystemInfo.rSynchronisationInterval = 1.0f;
	particleSystemInfo.iForwardThreshold = 50;
	pParticles = pCreateParticleSystem( particleSystemInfo );
//	delete particleSystemInfo.pConfigFile;

	particleNode = Node::create();
	particleModelNode = pParticles != 0 ? pParticles->pGetNodePtr() : Node::create();
// 	particleNode = pParticles != 0 ? pParticles->pGetNodePtr() : Node::create();

	Vec3f boundingBoxSize = pParticles->GetSize();
	
	particleTransNode = Node::create();
	particleTrans = Transform::create();

	particleModelTrans = Transform::create();
	
	Matrix m;
	m.setIdentity();
	beginEditCP(particleTrans, Transform::MatrixFieldMask);
		particleTrans->setMatrix(m);
	endEditCP(particleTrans, Transform::MatrixFieldMask);

	beginEditCP(particleModelTrans, Transform::MatrixFieldMask);
		particleModelTrans->setMatrix(m);
	endEditCP(particleModelTrans, Transform::MatrixFieldMask);

	beginEditCP(particleNode, Node::CoreFieldMask | Node::ChildrenFieldMask);
		particleNode->setCore(particleModelTrans);
		particleNode->addChild(particleModelNode);
	endEditCP(particleNode, Node::CoreFieldMask | Node::ChildrenFieldMask);
	
	beginEditCP(particleTransNode);
		particleTransNode->setCore(particleTrans);
		if (makeClone)
			particleTransNode->addChild(cloneTree(particleNode));
		else
			particleTransNode->addChild(particleNode);

		// set volume static to prevent constant update
		Volume &v = particleTransNode->getVolume( false ).getInstance();
		v.setEmpty();
		v.extendBy( Pnt3f( -boundingBoxSize[0], -boundingBoxSize[1], -boundingBoxSize[2] ) );
		v.extendBy( Pnt3f( boundingBoxSize[0], boundingBoxSize[1], boundingBoxSize[2] ) );
		v.setStatic();
		((DynamicVolume&)particleTransNode->getVolume()).instanceChanged();

	endEditCP(particleTransNode);

	cloned = false;
} // Particles
Example #4
0
/*! Set the position and the orientation at once using a matrix.
*/
void FlyNavigator::set(Matrix new_matrix)
{
    _rFrom= Pnt3f(new_matrix[3]);
    _rAt  = Pnt3f(new_matrix[3] - new_matrix[2]);
    _vUp  = Vec3f(new_matrix[1]);
    set(_rFrom, _rAt, _vUp);
}
Distribution3DRefPtr createSizeDistribution(void)
{
    LineDistribution3DRefPtr TheLineDistribution = LineDistribution3D::create();
      TheLineDistribution->setPoint1(Pnt3f(3.0,3.0,3.0));
      TheLineDistribution->setPoint2(Pnt3f(1.0,1.0,1.0));

	return TheLineDistribution;
}
Distribution3DRefPtr createColorDistribution(void)
{
    LineDistribution3DRefPtr TheLineDistribution = LineDistribution3D::create();
    TheLineDistribution->setPoint1(Pnt3f(0.5,0.5,0.5));
    TheLineDistribution->setPoint2(Pnt3f(1.0,1.0,1.0));

    return TheLineDistribution;
}
Example #7
0
Distribution3DRefPtr createSmokeColorDistribution(void)
{
    //Line Distribution
    LineDistribution3DRefPtr TheLineDistribution = LineDistribution3D::create();
    TheLineDistribution->setPoint1(Pnt3f(0.0,0.0,0.0));
    TheLineDistribution->setPoint2(Pnt3f(0.15,0.15,0.15));

    return TheLineDistribution;
}
Example #8
0
Distribution3DRecPtr createSizeDistribution(void)
{
    //Line Distribution
    LineDistribution3DRefPtr TheLineDistribution = LineDistribution3D::create();
    TheLineDistribution->setPoint1(Pnt3f(1.2,1.2,1.0));
    TheLineDistribution->setPoint2(Pnt3f(1.4,1.4,1.0));

    return TheLineDistribution;
}
Distribution3DRefPtr createAccelerationDistribution(void)
{
    //Line Distribution
    LineDistribution3DRefPtr TheLineDistribution = LineDistribution3D::create();
    TheLineDistribution->setPoint1(Pnt3f(0.0,0.0,0.0));
    TheLineDistribution->setPoint2(Pnt3f(0.0,0.0,0.0));

    return TheLineDistribution;
}
CSMSceneParameterBase::CSMSceneParameterBase(void) :
    Inherited(),
    _sfSceneRef               (NULL),
    _sfDistScale              (Real32(1.f)),
    _sfSceneDiag              (Vec3f(1.f)),
    _sfInitViewPos            (Pnt3f(1.f)),
    _sfSceneCenter            (Pnt3f(1.f))
{
}
Distribution3DRefPtr createSizeDistribution(void)
{
    //Sphere Distribution
    LineDistribution3DRefPtr TheLineDistribution = LineDistribution3D::create();
    TheLineDistribution->setPoint1(Pnt3f(5.0,5.0,1.0));
    TheLineDistribution->setPoint2(Pnt3f(10.0,10.0,1.0));

    return TheLineDistribution;
}
Distribution3DRefPtr createVelocityDistribution(void)
{
    //Line Distribution, no velocity
    LineDistribution3DRefPtr TheLineDistribution = LineDistribution3D::create();
    TheLineDistribution->setPoint1(Pnt3f(0.0,0.0,0.0));
    TheLineDistribution->setPoint2(Pnt3f(0.0,0.0,0.0));

    return TheLineDistribution;
}
Distribution3DRefPtr createSizeDistribution(void)
{
    //Line Distribution
    LineDistribution3DRefPtr TheLineDistribution = LineDistribution3D::create();
    TheLineDistribution->setPoint1(Pnt3f(4.45,4.45,4.45));
    TheLineDistribution->setPoint2(Pnt3f(4.45,4.45,4.45));

    return TheLineDistribution;
}
Distribution3DRefPtr createTrailSizeDistribution(void)
{
    //Line Distribution
    LineDistribution3DRefPtr TheLineDistribution = LineDistribution3D::create();
    TheLineDistribution->setPoint1(Pnt3f(2.0,2.0,2.0));
    TheLineDistribution->setPoint2(Pnt3f(2.5,2.5,2.5));

    return TheLineDistribution;
}
Distribution3DRefPtr createPositionDistribution(void)
{
    LineDistribution3DRefPtr TheLineDistribution = LineDistribution3D::create();
    TheLineDistribution->setPoint1(Pnt3f(0.0f,0.0f,0.0f));
    TheLineDistribution->setPoint2(Pnt3f(0.1f,0.0f,0.0f));


    return TheLineDistribution;
}
Distribution3DRefPtr createSmokeVelocityDistribution(void)
{
    //Sphere Distribution
    LineDistribution3DRefPtr TheLineDistribution = LineDistribution3D::create();
    TheLineDistribution->setPoint1(Pnt3f(0.0,1.0,1.0));
    TheLineDistribution->setPoint2(Pnt3f(0.0,1.0,3.0));

    return TheLineDistribution;
}
Example #17
0
// Represents a parametric line
Ray::Ray(const Pnt3f& _e, const Vec3f& _d, float _min, float _max)
{
	e = Pnt3f(_e);
	d = Vec3f(_d);
	min = _min;
	max = _max;
	
	// Cache this to optimize bbox calculations
	multInverseDir = Pnt3f(1.0f / d.x, 1.0f / d.y, 1.0f / d.z);
}
Distribution3DRefPtr createPositionDistribution(void)
{
    BoxDistribution3DRefPtr TheBoxDistribution = BoxDistribution3D::create();
    TheBoxDistribution->setMinPoint(Pnt3f(-10.0f,-10.0f,-10.0f));
    TheBoxDistribution->setMaxPoint(Pnt3f(10.0f,10.0f,10.0f));
    TheBoxDistribution->setSurfaceOrVolume(BoxDistribution3D::VOLUME);


    return TheBoxDistribution;
}
Example #19
0
OSG_BASE_DLLMAPPING 
void extend(CylinderVolume &srcVol, const CylinderVolume &vol)
{
    Pnt3f  min, max, min1, max1, min2, max2, apos;
    Vec2f  p;
    Vec3f  adir;
    Real32 r;

    if((!srcVol.isValid   () && !srcVol.isEmpty()) ||
         srcVol.isInfinite()                       ||
         srcVol.isStatic  ()                         )
    {
        return;
    }

    if(!vol.isValid())
        return;

    if(srcVol.isEmpty())
    {
        if(vol.isEmpty())
        {
            return;
        }
        else
        {
            srcVol = vol;
            return;
        }
    }
    else if(vol.isEmpty())
    {
        return;
    }

    srcVol.getBounds(min,  max);
    vol   .getBounds(min1, max1);

    min2 = Pnt3f(osgMin(min.x(), min1.x()), 
                 osgMin(min.y(), min1.y()),
                 osgMin(min.z(), min1.z()));
    max2 = Pnt3f(osgMax(max.x(), max1.x()), 
                 osgMax(max.y(), max1.y()),
                 osgMax(max.z(), max1.z()));

    p = Vec2f(max2.x() - min2.x(), max2.y() - min2.y());
    r = (p.length()) * 0.5f;

    adir = Vec3f(0.f, 0.f, max2.z() - min2.z());
    apos = Pnt3f(p.x(), p.y(), min2.z());

    srcVol.setValue(apos, adir, r);

    return;
}
Example #20
0
// provide a default set of points
void World::resetPoints()
{
	points.clear();
	points.push_back(ControlPoint(Pnt3f(50,5,0)));
	points.push_back(ControlPoint(Pnt3f(0,5,50)));
	points.push_back(ControlPoint(Pnt3f(-50,5,0)));
	points.push_back(ControlPoint(Pnt3f(0,5,-50)));

	// we had better put the train back at the start of the track...
	trainU = 0.0;
}
bool Camera::calcViewRay(      Line    &line, 
                               Int32     x, 
                               Int32     y, 
                         const Viewport &port,
                               Real32   *t   )
{
    if(port.getPixelWidth() <= 0 || port.getPixelHeight() <= 0)
    {
        return false;
    }

    Matrix proj, projtrans, view;

    getProjection(proj,
                  port.getPixelWidth(),
                  port.getPixelHeight());

    getProjectionTranslation(projtrans,
                             port.getPixelWidth(),
                             port.getPixelHeight());

    getViewing(view,
               port.getPixelWidth(),
               port.getPixelHeight());

    Matrix wctocc = proj;

    wctocc.mult(projtrans);
    wctocc.mult(view);

    Matrix cctowc;

    cctowc.invertFrom(wctocc);

    Real32 rx(0.f), ry(0.f);
    port.getNormalizedCoordinates(rx, ry, x, y);

    Pnt3f from, at;

    cctowc.multFull(Pnt3f(rx, ry, -1), from);
    cctowc.multFull(Pnt3f(rx, ry,  1), at  );

	Vec3f dir = at - from;
	
	if(t != NULL)
	{
		*t = dir.length();
	}

    line.setValue(from, dir);

    return true;
}
Example #22
0
void SpaceNavigatorSSM::showAll(void)
{
	if(_root == NullFC)
	    return;
	
	_root->updateVolume();
	
	Vec3f min,max;
	_root->getVolume().getBounds( min, max );
	Vec3f d = max - min;
	
	if(d.length() < Eps) // Nothing loaded? Use a unity box
	{
	    min.setValues(-1.f,-1.f,-1.f);
	    max.setValues( 1.f, 1.f, 1.f);
	    d = max - min;
	}

	SpaceNavigatorOSGClient::Instance()->setTranslationFactorToSceneSize(_root);

	bool zUpAxis = SpaceNavigatorOSGClient::Instance()->getZUpAxis();
	
	Real32 dist;
	if(zUpAxis)
		dist = osgMax(d[0],d[2]) / (2 * osgtan(_camera->getFov() / 2.f));
	else
		dist = osgMax(d[0],d[1]) / (2 * osgtan(_camera->getFov() / 2.f));
	
	// get the correct up axis
	Vec3f up = getNavigator()->getUp();
	Pnt3f at;
	if(zUpAxis)
		at = Pnt3f((min[0] + max[0]) * .5f,(min[2] + max[2]) * .5f,(min[1] + max[1]) * .5f);
	else
		at = Pnt3f((min[0] + max[0]) * .5f,(min[1] + max[1]) * .5f,(min[2] + max[2]) * .5f);
	Pnt3f from=at;
	if(zUpAxis)
		from[1]+=(dist+fabs(max[1]-min[1])*0.5f); 
	else
		from[2]+=(dist+fabs(max[2]-min[2])*0.5f); 
	
	_navigator.set(from,at,up);
	
	// set the camera to go from 1% of the object to twice its size
	Real32 diag = osgMax(osgMax(d[0], d[1]), d[2]);
	beginEditCP(_camera);
	_camera->setNear (diag / 100.f);
	_camera->setFar  (10 * diag);
	endEditCP(_camera);
}
Example #23
0
Particles::Particles(Particles* src)
{
	int i;

	particleSystemInfo = src->particleSystemInfo;
	pParticles = src->pParticles;

// 	particleNode = pParticles != 0 ? pParticles->pGetNodePtr() : Node::create();
	particleNode = Node::create();
	particleModelNode = pParticles->pGetNodePtr();
	assert(particleModelNode != NullFC);

	Vec3f boundingBoxSize = pParticles->GetSize();
	
	particleTransNode = Node::create();
	particleTrans = Transform::create();

	particleModelTrans = Transform::create();

	Matrix m;
	m.setIdentity();
	beginEditCP(particleTrans, Transform::MatrixFieldMask);
		particleTrans->setMatrix(m);
	endEditCP(particleTrans, Transform::MatrixFieldMask);

	beginEditCP(particleModelTrans, Transform::MatrixFieldMask);
		particleModelTrans->setMatrix(m);
	endEditCP(particleModelTrans, Transform::MatrixFieldMask);

	beginEditCP(particleNode, Node::CoreFieldMask | Node::ChildrenFieldMask);
		particleNode->setCore(particleModelTrans);
		particleNode->addChild(particleModelNode);
	endEditCP(particleNode, Node::CoreFieldMask | Node::ChildrenFieldMask);

	beginEditCP(particleTransNode);
		particleTransNode->setCore(particleTrans);
		particleTransNode->addChild(cloneTree(particleNode));

		// set volume static to prevent constant update
		Volume &v = particleTransNode->getVolume( false ).getInstance();
		v.setEmpty();
		v.extendBy( Pnt3f( -boundingBoxSize[0], -boundingBoxSize[1], -boundingBoxSize[2] ) );
		v.extendBy( Pnt3f( boundingBoxSize[0], boundingBoxSize[1], boundingBoxSize[2] ) );
		v.setStatic();
		((DynamicVolume&)particleTransNode->getVolume()).instanceChanged();

	endEditCP(particleTransNode);
	cloned = true;
} // Particles
Example #24
0
void Sphere::cacheBbox()
{	
	float minX = cntr.x-rad;
	float minY = cntr.y-rad;
	float minZ = cntr.z-rad;
	
	float maxX = cntr.x+rad;
	float maxY = cntr.y+rad;
	float maxZ = cntr.z+rad;

	Pnt3f minPnt = Pnt3f(minX, minY, minZ);
	Pnt3f maxPnt = Pnt3f(maxX, maxY, maxZ);

	this->bbox = new BoundingBox(minPnt, maxPnt);
}
Example #25
0
void
createRays(UInt32 uiNumRays, std::vector<Line> &rays)
{
    SINFO << "Creating " << uiNumRays << " rays...";

    rays.clear  (         );
    rays.reserve(uiNumRays);

    for(UInt32 i = 0; i < uiNumRays; ++i)
    {
        Real32 xPos = (osgrand() - 0.5) * X_SIZE * 2.5;
        Real32 yPos = (osgrand() - 0.5) * Y_SIZE * 2.5;
        Real32 zPos = (osgrand() - 0.5) * Z_SIZE * 2.5;

        Real32 xDir = (osgrand() - 0.5);
        Real32 yDir = (osgrand() - 0.5);
        Real32 zDir = (osgrand() - 0.5);

        if((xPos * xDir) > 0)
            xDir *= -1.0;

        if((yPos * yDir) > 0)
            yDir *= -1.0;

        if((zPos * zDir) > 0)
            zDir *= -1.0;

        rays.push_back(Line(Pnt3f(xPos, yPos, zPos),
                            Vec3f(xDir, yDir, zDir) ));
    }

    PINFO << "done." << endLog;
}
void SoundEmitter::update(EventDetails* const details)
{
    OSG_ASSERT(getParents().size() == 1 && "A Sound Emitter NodeCore MUST have 1 and only 1 parent.");

    Matrix wm;
    dynamic_cast<Node*>(_mfParents[0])->getToWorld(wm);
    Pnt3f Position(0, 0, 0);
    wm.mult(Pnt3f(0.0f,0.0f,0.0f),Position);

    if(getSound() != NULL)
    {
        //Remove all invalid
        for(std::set<UInt32>::iterator Itor(_EmittedSoundChannels.begin()) ; Itor != _EmittedSoundChannels.end() ;)
        {
            if(!getSound()->isValid(*Itor))
            {
                std::set<UInt32>::iterator EraseItor(Itor);
                ++Itor;
                _EmittedSoundChannels.erase(EraseItor);
            }
            else
            {

                //getSound()->setChannelVelocity(_PreviousPosition - Position * (1.0f/dynamic_cast<UpdateEventDetails* const>(details)->getElapsedTime()), *Itor);
                

                getSound()->setChannelPosition(Position, *Itor);
                ++Itor;
            }
        }
    }

    _PreviousPosition = Position;
}
Example #27
0
void runTests(bool write,BinaryDataHandler &pMem)
{
    runTest  (write,pMem, std::string("Hallo") );
    runTest1 (write,pMem, Time(222.22) );
    runTest  (write,pMem, Color3f(1.1,2.2,3.3) );
    runTest  (write,pMem, Color4f(1.1,2.2,3.3,4.4) );
    runTest  (write,pMem, Color3ub(1,2,3) );
    runTest  (write,pMem, Color4ub(1,2,3,4) );
    runTest  (write,pMem, DynamicVolume(DynamicVolume::BOX_VOLUME) );
    runTest  (write,pMem, DynamicVolume(DynamicVolume::SPHERE_VOLUME) );
    runTest1 (write,pMem, BitVector(0xabcd) );
    runTest  (write,pMem, Plane(Vec3f(1.0,0),0.222) );
    runTest  (write,pMem, Matrix(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) );
    runTest  (write,pMem, Quaternion(Vec3f(1,2,3),22) );
    runTest2<bool>(write,pMem, true );
    runTest  (write,pMem, Int8(-22) );
    runTest  (write,pMem, UInt8(11) );
    runTest  (write,pMem, Int16(-10233) );
    runTest  (write,pMem, UInt16(20233) );
    runTest  (write,pMem, Int32(-222320233) );
    runTest  (write,pMem, UInt32(522320233) );
    runTest<Int64>  (write,pMem, Int64(-522323334) );
    runTest  (write,pMem, UInt64(44523423) );
    runTest  (write,pMem, Real32(22.333224) );
    runTest  (write,pMem, Real64(52.334534533224) );
    runTest  (write,pMem, Vec2f(1.1,2.2) );
    runTest  (write,pMem, Vec3f(1.1,2.2,3.3) );
    runTest  (write,pMem, Vec4f(1.1,2.2,3.3,4.4) );
    runTest  (write,pMem, Pnt2f(1.1,2.2) );
    runTest  (write,pMem, Pnt2d(1.1,2.2) );
    runTest  (write,pMem, Pnt3f(1.1,2.2,3.3) );
    runTest  (write,pMem, Pnt3d(1.1,2.2,3.3) );
    runTest  (write,pMem, Pnt4f(1.1,2.2,3.3,4.4) );
    runTest  (write,pMem, Pnt4d(1.1,2.2,3.3,4.4) );
}
Example #28
0
void display(void)
{
    Real32 time = glutGet(GLUT_ELAPSED_TIME);
    updateMesh(time);
    
    // we extract the core out of the root node
    // as we now this is a geometry node
    GeometryPtr geo = GeometryPtr::dcast(scene->getChild(0)->getCore());
    
    //now modify it's content
    
    // first we need a pointer to the position data field
    GeoPositions3fPtr pos = GeoPositions3fPtr::dcast(geo->getPositions());
    
    //get the data field the pointer is pointing at
    GeoPositions3f::StoredFieldType *posfield = pos->getFieldPtr();
    //get some iterators
    GeoPositions3f::StoredFieldType::iterator last, it;

    // set the iterator to the first data
    it = posfield->begin();
    
    beginEditCP(pos, GeoPositions3f::GeoPropDataFieldMask);
    //now simply run over all entires in the array
    for (int x = 0; x < N; x++)
        for (int z = 0; z < N; z++){
            (*it) = Pnt3f(x, wMesh[x][z], z);
            it++;
        }
    endEditCP(pos, GeoPositions3f::GeoPropDataFieldMask);
    
    mgr->redraw();
}
Example #29
0
void init(int argc, char *argv[])
{
    osgInit(argc, argv);

    int winId = setupGLUT(&argc, argv);

    GLUTWindowUnrecPtr gwin = GLUTWindow::create();
    gwin->setGlutId(winId);
    gwin->init     (     );

    cubes  = Cubes::create();
    cubesN = makeNodeFor(cubes);

    cubes->setMaterial(getDefaultMaterial());

    for(UInt32 i = 0; i < 10; ++i)
    {
        cubes->editMFPosition()->push_back(
            Pnt3f  (random(-2.f, 2.f), random(-2.f, 2.f), random(-2.f, 2.f)));
        cubes->editMFLength  ()->push_back(random(0.5f, 2.f));
        cubes->editMFColor   ()->push_back(
            Color3f(random(0.5f, 1.f), random(0.5f, 1.f), random(0.5f, 1.f)));
    }

    mgr = new SimpleSceneManager;
    mgr->setWindow(gwin  );
    mgr->setRoot  (cubesN);

    mgr->showAll();

    commitChanges();
}
Example #30
0
void FrustumVolume::getCenter(Pnt3f &center) const
{
    Pnt3f vertices[8];
    Line  lines   [4];

    _planeVec[5].intersect(_planeVec[3],lines[3]);
    _planeVec[3].intersect(_planeVec[4],lines[2]);
    _planeVec[4].intersect(_planeVec[2],lines[0]);
    _planeVec[2].intersect(_planeVec[5],lines[1]);
    
    for(Int32 i = 0; i < 4; i++)
    {
        _planeVec[0].intersectInfinite(lines[i],vertices[    i]);
        _planeVec[1].intersectInfinite(lines[i],vertices[4 + i]);
    }    
    
    center = Pnt3f(0.f, 0.f ,0.f);

    for(Int32 i = 0; i < 8; i++)
    {        
        center = center + vertices[i].subZero();
    }

    center /= 8.f;
}