Example #1
0
    void TestCreatePointCloudOtherMethods() throw(Exception)
            {
#if defined(CHASTE_VTK) && ( (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 6) || VTK_MAJOR_VERSION >= 6)

        EXIT_IF_PARALLEL;

        {
            vtkSmartPointer<vtkPolyData> sphere = CreateSphere(50);

            AirwayGenerator generator(sphere);
            vtkSmartPointer<vtkPolyData> point_data = generator.CreatePointCloudUsingTargetPoints(50);

            TS_ASSERT_EQUALS(point_data->GetNumberOfPoints(), 51);

        }

        {
            vtkSmartPointer<vtkPolyData> sphere = CreateSphere(50);

            AirwayGenerator generator(sphere);
            vtkSmartPointer<vtkPolyData> point_data = generator.CreatePointCloudUsingTargetVolume(4*M_PI/3/50);

            TS_ASSERT_EQUALS(point_data->GetNumberOfPoints(), 51);

        }
#endif
            }
Example #2
0
int main() {
   /* Debugging Code */ 
   //double minX = 0.05859357, maxX = 0.44921857;
   //double minY = 2.03125, maxY = 2.421875;
   //int width = 20, height = 20;

   double minX = -10, maxX = 10, minY = -7.5, maxY = 7.5;
   int width = 512, height = 384;
   Canvas canvas;
   InitCanvas(&canvas, minX, maxX, minY, maxY, width, height);

   Point eye = CreatePoint(0.0, 0.0, -14.0);
   Point blueSphere = CreatePoint(1.0, 1.0, 0.0);
   Point redSphere = CreatePoint(0.5, 1.5, -3.0);
   Point lightPoint = CreatePoint(-100.0, 100.0, -100.0);

   Color blue = CreateColor(0.0, 0.0, 1.0);
   Color red = CreateColor(1.0, 0.0, 0.0);
   Color ambient = CreateColor(1.0, 1.0, 1.0);
   Color lightColor = CreateColor(1.5, 1.5, 1.5);
   
   Finish largeFinish = CreateFinish(0.2, 0.4, 0.5, 0.05);
   Finish smallFinish = CreateFinish(0.4, 0.4, 0.5, 0.05);

   Light light = CreateLight(lightPoint, lightColor);
   Sphere spheres[2];
   spheres[0] = CreateSphere(blueSphere, 2.0, blue, largeFinish);
   spheres[1] = CreateSphere(redSphere, 0.5, red, smallFinish);
   
   castAllRays(&canvas, eye, spheres, ambient, light, 2);
   return 0;
}
Example #3
0
ezResult ezRendererTestBasics::InitializeSubTest(ezInt32 iIdentifier)
{
  m_iFrame = -1;

  if (ezGraphicsTest::InitializeSubTest(iIdentifier).Failed())
    return EZ_FAILURE;

  if (iIdentifier == SubTests::ST_ClearScreen)
  {
    return SetupRenderer(320, 240);
  }

  if (SetupRenderer().Failed())
    return EZ_FAILURE;

  m_hSphere = CreateSphere(3, 1.0f);
  m_hSphere2 = CreateSphere(1, 0.75f);
  m_hTorus = CreateTorus(16, 0.5f, 0.75f);
  m_hLongBox = CreateBox(0.4f, 0.2f, 2.0f);
  m_hLineBox = CreateLineBox(0.4f, 0.2f, 2.0f);



  return EZ_SUCCESS;
}
Example #4
0
void Render::Draw(IDirect3DSurface9* renderTarget, D3DXMATRIX* view, D3DXMATRIX* projection)
{
    // Get or create device
    LPDIRECT3DDEVICE9 device = GetDevice();
    if (device == NULL) return;

    // Load shaders if it is required
//    if (!EnsureShaders()) return;

    // Prepare depth surface
    D3DSURFACE_DESC renderTargetDescription;
    renderTarget->GetDesc(&renderTargetDescription);
    D3DSURFACE_DESC depthSurfaceDescription;
    if (depthSurface != NULL) depthSurface->GetDesc(&depthSurfaceDescription);
    if (depthSurface == NULL || depthSurfaceDescription.Width != renderTargetDescription.Width || depthSurfaceDescription.Height != renderTargetDescription.Height)
    {
        if (depthSurface != NULL) depthSurface->Release();
        device->CreateDepthStencilSurface(renderTargetDescription.Width, renderTargetDescription.Height, D3DFMT_D24X8, D3DMULTISAMPLE_NONE, 0, FALSE, &depthSurface, NULL);
        if (depthSurface == NULL) return;
    }

    device->SetRenderTarget(0, renderTarget);
    device->SetDepthStencilSurface(depthSurface);
    device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);

    if (lowPolySphere == NULL)
    {
        // Create spheres
        lowPolySphere = CreateSphere(2);
        middlePolySphere = CreateSphere(3);
        highPolySphere = CreateSphere(5);
        // Create cylinders
        lowPolyCylinder = CreateCylinder(3);
        middlePolyCylinder = CreateCylinder(12);
        highPolyCylinder = CreateCylinder(24);
    }



    // FIXME: light dir must be slightly different!
    D3DVECTOR lightDirection;
    lightDirection.x = view->_13;
    lightDirection.y = view->_23;
    lightDirection.z = view->_33;
    D3DVECTOR viewDirection;
    viewDirection.x = view->_13;
    viewDirection.y = view->_23;
    viewDirection.z = view->_33;
    elementMaterials[0].SetViewLightDirection(&viewDirection, &lightDirection);

    // Rendering
    device->BeginScene();


    DrawAtoms(view, projection);
    DrawBonds(view, projection);
    DrawResidues(view, projection);

    device->EndScene();
}
Example #5
0
//-------------------------------------------------------------------------------
// @ Player::Player()
//-------------------------------------------------------------------------------
// Constructor
//-------------------------------------------------------------------------------
Player::Player()
{
    mRadius = 5.0f;

    mSphereIndices = nullptr;

    mSphereVerts = nullptr;

    mShader = IvRenderer::mRenderer->GetResourceManager()->CreateShaderProgram(
        IvRenderer::mRenderer->GetResourceManager()->CreateVertexShaderFromFile(
        "directionalShader"),
        IvRenderer::mRenderer->GetResourceManager()->CreateFragmentShaderFromFile(
        "directionalShader"));

    IvRenderer::mRenderer->SetShaderProgram(mShader);

    IvVector3 radiance(1.0f, 1.0f, 1.0f);
    mShader->GetUniform("dirLightRadiance")->SetValue(radiance, 0);

    mRotate.Identity();

    mLightDir = IvVector3(1.0f, 0.0f, 0.0f);

    CreateSphere();
}   // End of Player::Player()
Example #6
0
    void TestGrowTerminalLengthApex() throw(Exception)
    {
#if defined(CHASTE_VTK) && ( (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 6) || VTK_MAJOR_VERSION >= 6)
        EXIT_IF_PARALLEL;

        vtkSmartPointer<vtkPolyData> sphere = CreateSphere();

        AirwayGenerator generator(sphere, 2.0); //Long limit stops growth after one generation

        double origin[3] = {0.0, 1.0001, 0.0}; //to avoid bias in the splitting plane
        double direction[3] = {1.0, 0.0, 0.0};
        double parent_direction[3] = {1.0, 0.0, 0.0};

        generator.AddInitialApex(origin, direction, parent_direction, 10.0, 0);
        Apex& apex = generator.GetGenerations()[0].GetApices()[0];
        apex.mPointCloud = generator.CreatePointCloudUsingTargetPoints(50);

        generator.GrowApex(apex);

        //Test that two branches were generated
        TS_ASSERT_EQUALS(generator.GetAirwayTree()->GetNumberOfPoints(), 3);
        TS_ASSERT_EQUALS(generator.GetAirwayTree()->GetNumberOfCells(), 2);

        //Test that no apices were added and that points were invalidated
        TS_ASSERT_EQUALS(generator.GetGenerations()[1].GetApices().size(), 0u);
        TS_ASSERT_EQUALS(generator.GetInvalidIds().size(), 2u);
#endif
    }
Example #7
0
Object* bouteille(glm::vec3 pos)
{
	Container* c = new Container(pos);
    Mesh* m;

	m = CreateCylinder(1.0,1.0,3.0,20,10);
	c->addObject(m);

	m = CreateSphere(1.0f,20.0,20.0);
	m->setPosition(0.0,0.0,3.0);
	c->addObject(m);

	m = CreateCylinder(0.5,0.4,1.5,20.0,10.0);
	m->setPosition(0.0,0.0,3.7f);
	c->addObject(m);

  /*  glPushMatrix();
    glRotatef(90.0, 1.0, 0.0 ,0.0);
    glTranslatef(0.0,0.0,-2.3);
    glutSolidTorus(0.1,0.35,20.0,20.0);
    glTranslatef(0.0,0.0,-0.2);
    glutSolidTorus(0.1,0.3,20.0,20.0);
    glPopMatrix();*/
	return c;
}
Example #8
0
void DrawMonsterball (tObject *objP, float red, float green, float blue, float alpha)
{
#if !SIMPLE_SPHERE
    if (!gameData.render.monsterball.pSphere) {
        gameData.render.monsterball.nTessDepth = 3;
        gameData.render.monsterball.nFaces = CreateSphere (&gameData.render.monsterball);
    }
    if (gameData.render.monsterball.nFaces > 0)
#endif
    {
        if ((gameOpts->render.bDepthSort > 0) || (gameOpts->render.nPath && !gameOpts->render.bDepthSort))
            RIAddSphere (riMonsterball, red, green, blue, alpha, objP);
        else {
            static tOOF_vector p = {0,0,0};
            float r = f2fl (objP->size);
            gameStates.ogl.bUseTransform = 1;
            OglSetupTransform (0);
            G3StartInstanceMatrix (&objP->position.vPos, &objP->position.mOrient);
            RenderSphere (&gameData.render.monsterball, &p,
                          r, r, r, red, green, blue, gameData.hoard.monsterball.bm.bmTexBuf ? 1.0f : alpha,
                          &gameData.hoard.monsterball.bm, 4);
            G3DoneInstance ();
            OglResetTransform (1);
            gameStates.ogl.bUseTransform = 0;
        }
    }
}
Example #9
0
	//初期化
	void GameStage::Create(){
		try{
			//リソースの作成
			CreateResourses();
			//ビュー類を作成する
			CreateViews();
			//プレートの作成
			CreatePlate();
			//追いかけるオブジェクトの作成
			CreateSeekObject();
			//固定のボックスの作成
			CreateFixedBox();
			//上下移動しているボックスの作成
			CreateMoveBox();
			//カプセル作成
			CreateCapsule();
			//球体作成
			CreateSphere();
			//衝突するスクエアの作成
			CreateHitTestSquare();
			//プレーヤーの作成
			CreatePlayer();
		}
		catch (...){
			throw;
		}
	}
Example #10
0
void PezInitialize()
{
    PezConfig cfg = PezGetConfig();

    float fovy = 170 * TwoPi / 180;
    float aspect = (float) cfg.Width / cfg.Height;
    float zNear = 65, zFar = 90;
    Globals.Projection = M4MakePerspective(fovy, aspect, zNear, zFar);
    Globals.Theta = 0;

    const float MajorRadius = 11.0f, MinorRadius = 1.5f;
    const float Radius = 5.0f;
    const int Slices = 60, Stacks = 30;

    Globals.LavaProgram = LoadProgram("TheGameMaker.VS", 0, "TheGameMaker.FS");
    Globals.TorusVao = CreateTorus(MajorRadius, MinorRadius, Slices, Stacks);

    Globals.ReflectionProgram = LoadProgram("Reflection.VS", 0, "Reflection.FS");
    Globals.SphereVao = CreateSphere(Radius, Slices, Stacks);

    // Load textures
    Globals.CloudTexture = LoadTexture("cloud.png");
    Globals.LavaTexture = LoadTexture("lavatile.png");

    glClearColor(0.1, 0.1, 0.1, 0);
    glBlendFunc(GL_ONE, GL_ONE);
}
Example #11
0
    void TestAddInitialApex() throw(Exception)
    {
#if defined(CHASTE_VTK) && ( (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 6) || VTK_MAJOR_VERSION >= 6)
        EXIT_IF_PARALLEL;

        vtkSmartPointer<vtkPolyData> sphere = CreateSphere();
        AirwayGenerator generator(sphere);

        double origin[3] = {0.0, 1.0, 0.0};
        double direction[3] = {0.0, 1.0, 0.0};
        double parent_direction[3] = {1.0, 0.0, 0.0};

        generator.AddInitialApex(origin, direction, parent_direction, 10.0, 0);
        generator.AddInitialApex(origin, direction, parent_direction, 10.0, 1);
        generator.AddInitialApex(origin, direction, parent_direction, 10.0, 1);
        generator.AddInitialApex(origin, direction, parent_direction, 10.0, 3);

        TS_ASSERT_EQUALS(generator.GetGenerations().size(), 30u);
        TS_ASSERT_EQUALS(generator.GetGenerations()[0].GetApices().size(), 1u);
        TS_ASSERT_EQUALS(generator.GetGenerations()[1].GetApices().size(), 2u);
        TS_ASSERT_EQUALS(generator.GetGenerations()[2].GetApices().size(), 0u);
        TS_ASSERT_EQUALS(generator.GetGenerations()[3].GetApices().size(), 1u);

        TS_ASSERT_EQUALS(generator.GetAirwayTree()->GetNumberOfPoints(), 4);

        //The generator only supports generations up to 30
        TS_ASSERT_THROWS_THIS(generator.AddInitialApex(origin, direction, parent_direction, 10.0, 35),
                              "Error: Airway generation can only generate up to 30 generations.");
#endif
    }
Example #12
0
    void TestInvalidateClosestPoint() throw(Exception)
    {
#if defined(CHASTE_VTK) && ( (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 6) || VTK_MAJOR_VERSION >= 6)
        EXIT_IF_PARALLEL;

        vtkSmartPointer<vtkPolyData> sphere = CreateSphere(50);

        AirwayGenerator generator(sphere);
        vtkSmartPointer<vtkPolyData> cloud = generator.CreatePointCloudUsingTargetPoints(100);

        double invalid1[3] = {-1.0, -1.0, -0.3}; //Expect this to be the first point
        double invalid2[3] = {1.0, 1.0, 0.7}; //Expect this to be the last point
        double invalid3[3] = {0.0, 0.0, 0.0}; //Expect this to be roughly the middle inserted point

        generator.InvalidateClosestPoint(invalid1, cloud);
        generator.InvalidateClosestPoint(invalid2, cloud);
        generator.InvalidateClosestPoint(invalid3, cloud);

        TS_ASSERT_EQUALS(cloud->GetNumberOfPoints(), 93);

        //Assert that the correct points were invalidated and that no others were
        std::set<unsigned>& invalid_ids = generator.GetInvalidIds();
        TS_ASSERT_EQUALS(invalid_ids.size(), 3u);

        TS_ASSERT(invalid_ids.count(0));
        TS_ASSERT(invalid_ids.count(92));
        TS_ASSERT(invalid_ids.count(49));

#endif
    }
Example #13
0
void KeyboardUpCallback(unsigned char key, int x, int y)
{
	gKeys[key] = false;

	switch (key)
	{
		case 'p': { bPause = !bPause; 
					if (bPause)
						hud.SetDisplayString(1, "Paused - Hit \"p\" to Unpause", 0.3f, 0.55f);
					else
						hud.SetDisplayString(1, "", 0.0f, 0.0f);	
					getElapsedTime(); 
					break; }
	
		case 'f': { bForceMode = !bForceMode; break; }
	    case 'b': 
			{
				box = CreateBox(NxVec3(2,5-0.75,7), NxVec3(0.75,0.75,0.75), 1);
	  			sphere = CreateSphere(NxVec3(0,4-0.4,1), 0.4, 1);
	  			capsule = CreateCapsule(NxVec3(3,0-(1+0.5),8), 1, 1, 1);
		 		break; 
	  		  }	
		case 27 : { exit(0); break; }
		default : { break; }
	}
}
VisitPointTool::VisitPointTool(VisWindowToolProxy &p) : VisitInteractiveTool(p),
    Interface(p)
{
    window3D = false;
    addedBbox = false;
    addedGuide = false;
    axisTranslate = none;

    HotPoint h;
    h.radius = 1./60.; // See what a good value is.
    h.tool = this;

    //
    // Add the hotpoint
    //
    h.pt = avtVector(0., 0.,  0.);
    h.callback = TranslateCallback;
    hotPoints.push_back(h);

    guideActor = NULL;
    guideMapper = NULL;
    guideData = NULL;

    sphereActor = NULL;
    sphereMapper = NULL;
    sphereData = NULL;

    CreateTextActors();
    CreateGuide();
    CreateSphere();
}
Example #15
0
SphereNode::SphereNode()
:	MeshInstanceNode()
{
    sphereMesh = NULL;
    SetQuality(80);
    
    CreateSphere(1.f, Color(0.f, 0.f, 0.f, 1.f));
}
Example #16
0
void PhysX::CreateSphereFromEye(int radius)
{
	NxVec3 t = m_Eye;
	NxVec3 vel = m_Dir;
	vel.normalize();
	vel *= 200.0f;
	CreateSphere(t, radius, DENSITY , &vel);
}
Example #17
0
void SetupAttachmentScene()
{
    sprintf(gTitleString, "Attachment Demo");

	// Create objects in scene
	groundPlane = CreateGroundPlane();
	NxActor* box1 = CreateBox(NxVec3(-7,12.25,0), NxVec3(2.5,1,1), 0);
	NxActor* box2 = CreateBox(NxVec3(0,12.25,0), NxVec3(2.5,1,1), 0);
	NxActor* box3 = CreateBox(NxVec3(7,12.25,0), NxVec3(2.5,1,1), 0);	

	NxActor* attachedBox = CreateBox(NxVec3(-7.2,4.5,1.6), NxVec3(1.25,1,1), 1);
	NxActor* attachedSphere = CreateSphere(NxVec3(-0.25,4.0,2.0), 1.3, 1);
	NxActor* attachedCapsule = CreateCapsule(NxVec3(9.0,5.5,2.0),2.0, 1, 1); 

	NxReal damping = 0.3;
	attachedBox->setAngularDamping(damping);
	attachedBox->setLinearDamping(damping);
	attachedSphere->setAngularDamping(damping);
	attachedSphere->setLinearDamping(damping);
	attachedCapsule->setAngularDamping(damping);
	attachedCapsule->setLinearDamping(damping);

	NxQuat q;
	q.fromAngleAxis(90,NxVec3(0,0,1));
	attachedCapsule->setGlobalOrientationQuat(q);

	// Cloth
	NxClothDesc clothDesc;
	clothDesc.globalPose.M.rotX(1.3);
	clothDesc.thickness = 0.3;	
	clothDesc.attachmentResponseCoefficient = 1;
	clothDesc.flags |= NX_CLF_BENDING;
	clothDesc.flags |= NX_CLF_BENDING_ORTHO;
	clothDesc.flags |= NX_CLF_DAMPING | NX_CLF_VISUALIZATION;

	if (gHardwareCloth)
		clothDesc.flags |= NX_CLF_HARDWARE;

	// Cloth attaching to sphere
	clothDesc.globalPose.t = NxVec3(0.75,5,2);
	MyCloth* regularCloth1 = new MyCloth(gScene, clothDesc, 2, 8, 0.4);
	regularCloth1->getNxCloth()->attachToCollidingShapes(NX_CLOTH_ATTACHMENT_TWOWAY);
	gCloths.push_back(regularCloth1);

	// Cloth attaching to box
	clothDesc.globalPose.t = NxVec3(-6.2,5,2);
	MyCloth* regularCloth2 = new MyCloth(gScene, clothDesc, 2, 8, 0.4);
	regularCloth2->getNxCloth()->attachToCollidingShapes(NX_CLOTH_ATTACHMENT_TWOWAY);
	gCloths.push_back(regularCloth2);

	// Cloth attaching to capsule
	clothDesc.globalPose.t = NxVec3(8.0,5,2);
	clothDesc.attachmentTearFactor = 2.0;
	MyCloth* regularCloth3 = new MyCloth(gScene, clothDesc, 2, 8, 0.4);
	regularCloth3->getNxCloth()->attachToShape(box3->getShapes()[0], NX_CLOTH_ATTACHMENT_TEARABLE);
	regularCloth3->getNxCloth()->attachToShape(attachedCapsule->getShapes()[0], NX_CLOTH_ATTACHMENT_TWOWAY);
	gCloths.push_back(regularCloth3);
}
Example #18
0
	MeshUtil::MeshUtil()
	{
		m_MeshMap.emplace("quad_mesh", CreateQuad("quad_mesh", Vector4(-1.0f, -1.0f, 0.0f), Vector4(1.0f, 1.0f, 0.0f)));
		m_MeshMap.emplace("cube_mesh", CreateCube("cube_mesh", Vector4(-1.0f), Vector4(1.0f)));
		m_MeshMap.emplace("ico_sphere_mesh", CreateIcoSphere("ico_sphere_mesh", 1.0f, 2));
		m_MeshMap.emplace("sphere_mesh", CreateSphere("sphere_mesh", 1.0f, 20, 20));
		m_MeshMap.emplace("cylinder_mesh", CreateCylinder("cylinder_mesh", 1.0f, 1.0f, 1.0f, 4, 10));
		m_MeshMap.emplace("cone_mesh", CreateCylinder("cone_mesh", 0.0f, 1.0f, 1.0f, 4, 10));
	}
Example #19
0
void InitNx()
{
	// Create a memory allocator
    gAllocator = new UserAllocator;

    // Create the physics SDK
	gPhysicsSDK = CreatePhysics();

    // Create the scene
    NxSceneDesc sceneDesc;
    sceneDesc.gravity               = gDefaultGravity;
	sceneDesc.simType				= NX_SIMULATION_HW;
    gScene = gPhysicsSDK->createScene(sceneDesc);	
	if(!gScene){ 
		sceneDesc.simType				= NX_SIMULATION_SW; 
		gScene = gPhysicsSDK->createScene(sceneDesc);  
		if(!gScene) return;
	}

	// Create the default material
	NxMaterial* defaultMaterial = gScene->getMaterialFromIndex(0); 
	defaultMaterial->setRestitution(0.5);
	defaultMaterial->setStaticFriction(0.5);
	defaultMaterial->setDynamicFriction(0.5);

    // Set Core Dump directory
	char buff[512];
	FindMediaFile(fnameCD, buff);
#ifdef WIN32
	SetCurrentDirectory(buff);
#elif LINUX
	chdir(buff);
#endif

	// Create the objects in the scene
	NxActor* groundPlane = CreateGroundPlane();

	NxActor* box = CreateBox(NxVec3(5,0,0), NxVec3(0.5,1,0.5), 20);
	NxActor* sphere = CreateSphere(NxVec3(0,0,0), 1, 10);
	NxActor* capsule = CreateCapsule(NxVec3(-5,0,0), 2, 0.5, 10);
//	pyramid = CreatePyramid(NxVec3(0,0,0), NxVec3(1,0.5,1.5), 10);

	AddUserDataToActors(gScene);

	gSelectedActor = capsule;
//	gSelectedActor = pyramid;

	// Initialize HUD
	InitializeHUD();

	// Get the current time
	getElapsedTime();

	// Start the first frame of the simulation
	if (gScene)  StartPhysics();
}
Example #20
0
void init (void) {    
    glEnable(GL_DEPTH_TEST);    
    glEnable( GL_TEXTURE_2D );    
    glDepthFunc(GL_LEQUAL);
    glCullFace(GL_BACK);    
    glFrontFace(GL_CCW);    
    glEnable(GL_CULL_FACE);    
    texture[0] = LoadTextureRAW( "earth.raw" );    
    CreateSphere(70,0,0,0);
}
Example #21
0
void KeyboardUpCallback(unsigned char key, int x, int y)
{
	gKeys[key] = false;

	switch (key)
	{
		case 'p': { bPause = !bPause; 
					if (bPause)
						hud.SetDisplayString(2, "Paused - Hit \"p\" to Unpause", 0.3f, 0.55f);
					else
						hud.SetDisplayString(2, "", 0.0f, 0.0f);	
					break; }
		case 'x': { bShadows = !bShadows; break; }
		case 'b': { bDebugWireframeMode = !bDebugWireframeMode; break; }		
		case 'f': { bForceMode = !bForceMode; break; }

		case 'o': 
		{     
			NxCloth** cloths = gScene->getCloths();
			for (NxU32 i = 0; i < gScene->getNbCloths(); i++) 
			{
				cloths[i]->setFlags(cloths[i]->getFlags() ^ NX_CLF_BENDING_ORTHO);
			}
			break;
		}

		case 'g': 
		{     
			NxCloth** cloths = gScene->getCloths();
			for (NxU32 i = 0; i < gScene->getNbCloths(); i++) 
			{
				cloths[i]->setFlags(cloths[i]->getFlags() ^ NX_CLF_GRAVITY);
			}
			break;
		}

		case 'y': 
		{
			NxCloth** cloths = gScene->getCloths();
			for (NxU32 i = 0; i < gScene->getNbCloths(); i++) 
			{
				cloths[i]->setFlags(cloths[i]->getFlags() ^ NX_CLF_BENDING);
			}	            
			break;
		}
		case ' ': 
		{
			NxActor* sphere = CreateSphere(gCameraPos, 1, 1);
			sphere->setLinearVelocity(gCameraForward * 20);
			break; 
		}
		case 27 : { exit(0); break; }
		default : { break; }
	}
}
Example #22
0
Object* porte(glm::vec3 pos)
{
	Container* c = new Container(pos);
	Mesh* m;
	Texture* t = TextureMgr::getTextureMgr()->getTexture("../../src/img/interieur.bmp");
	m = CreateBox(5.0, 0.8, 10.0);
	m->setPosition(0.0,0.0,5.0);
	
	c->addObject(m);

	m = CreateCylinder(0.1,0.1,1.2,20.0,1.0);
	m->rotate(-90,glm::vec3(1,0,0));
	m->setPosition(2.0,-0.6,5.0);
	c->addObject(m);

	//glScalef(1.0,1.0,0.5);
	m = CreateSphere(0.2,20.0,20.0);
	m->setPosition(2.0,0.6,5.0);
	c->addObject(m);

	//glScalef(1.0,1.0,0.5);
	m = CreateSphere(0.2,20.0,20.0);
	m->setPosition(2.0,-0.6,5.0);
	c->addObject(m);

	m = CreateBox(1.0, 1.0, 25.0);
	m->setPosition(-3.0,0.0,12.5);
	m->setTexture(t);
	c->addObject(m);

	m = CreateBox(1.0, 1.0, 25.0);
	m->setPosition(3.0,0.0,12.5);
	m->setTexture(t);
	c->addObject(m);

	m = CreateBox(6.0, 1.0, 15.0);
	m->setPosition(0.0,0.0,17.5);
	m->setTexture(t);
	c->addObject(m);

	return c;
}
Example #23
0
    void TestEndBranchDistanceLimit() throw(Exception)
    {
    #if defined(CHASTE_VTK) && ( (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 6) || VTK_MAJOR_VERSION >= 6)
        EXIT_IF_PARALLEL;
        vtkSmartPointer<vtkPolyData> sphere = CreateSphere(100, 100.0); //lung sized sphere to test distance limit

        double min_branch_length = 0.1;
        unsigned point_limit = 1;
        double angle_limit = 180.0;
        double branching_fraction = 0.4;
        bool applyPointReassignmentLimit = true;

        AirwayGenerator generator(sphere, min_branch_length, point_limit, angle_limit, branching_fraction, applyPointReassignmentLimit);

        std::deque<AirwayGeneration>& generations = generator.GetGenerations();

        //The bounding box of the sphere is (-100,-100,-100) and (100,100,100), the diagonal of the bounding box is of size
        //sqrt(dx^2 + dy^2 + dz^2) where dx = dy = dz = 200.0
        double lobe_bound_size = sqrt(120000);

        for(unsigned generation_number = 0; generation_number < generations.size(); ++generation_number)
        {
            double scale_distance_limit = lobe_bound_size/30; //30 is the expected total number of generations
            TS_ASSERT_DELTA(generations[generation_number].GetDistributionRadius(), std::max(lobe_bound_size - scale_distance_limit*generation_number, 5.0), 1e-1);

        }

        double origin[3] = {0.0, 1.0, 0.0};
        double direction[3] = {1.0, 0.0, 0.0};
        double parent_direction[3] = {1.0, 0.0, 0.0};

        //Check that all points are distributed to an apex in generation 0
        generator.AddInitialApex(origin, direction, parent_direction, 10.0, 0);

        vtkSmartPointer<vtkPolyData> cloud = generator.CreatePointCloudUsingTargetPoints(1000);
        std::set<unsigned> invalid_ids;
        generations[0].DistributeGrowthPoints(cloud, invalid_ids);
        unsigned assigned_points = generations[0].GetApices()[0].mPointCloud->GetNumberOfPoints();
        unsigned total_points = cloud->GetNumberOfPoints();
        TS_ASSERT_EQUALS(assigned_points, total_points);

        //Check that the number of distributed points becomes less with each generation
        unsigned previous_assigned_points = assigned_points;
        for(unsigned generation_number = 1; generation_number < generations.size(); ++generation_number)
        {
            generator.AddInitialApex(origin, direction, parent_direction, 10.0, generation_number);

            generations[generation_number].DistributeGrowthPoints(cloud, invalid_ids);
            assigned_points = generations[generation_number].GetApices()[0].mPointCloud->GetNumberOfPoints();
            TS_ASSERT_LESS_THAN_EQUALS(assigned_points, previous_assigned_points);
            previous_assigned_points = assigned_points;
        }
    #endif
    }
Example #24
0
    void TestGenerateDecomposedAirways() throw(Exception)
    {
#if defined(CHASTE_VTK) && ( (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 6) || VTK_MAJOR_VERSION >= 6)
        EXIT_IF_PARALLEL;
        vtkSmartPointer<vtkPolyData> sphere = CreateSphere();

        double min_branch_length = 0.1;
        unsigned point_limit = 1;
        double angle_limit = 180.0;
        double branching_fraction = 0.4;

        AirwayGenerator generator(sphere, min_branch_length, point_limit, angle_limit, branching_fraction);

        double origin1[3] = {0.0, 1.0, 0.0};
        double origin2[3] = {1.0, 0.0, 0.0};
        double origin3[3] = {0.0, 0.0, 1.0};
        double direction[3] = {1.0, 0.0, 0.0};
        double parent_direction[3] = {1.0, 0.0, 0.0};

        generator.AddInitialApex(origin1, direction, parent_direction, 10.0, 0);
        generator.AddInitialApex(origin2, direction, parent_direction, 10.0, 0);
        generator.AddInitialApex(origin3, direction, parent_direction, 10.0, 0);
        generator.CreatePointCloudUsingTargetPoints(50);

        generator.Generate();

        generator.CalculateHorsfieldOrder();
        generator.CalculateRadii(1.15);

        generator.WriteDecomposedAirways("TestAirwayGenerator", "decomposed_test");

        //We expect three separate files to be written.
        FileFinder finder_0("TestAirwayGenerator/decomposed_test_0.vtu", RelativeTo::ChasteTestOutput);
        FileFinder finder_1("TestAirwayGenerator/decomposed_test_1.vtu", RelativeTo::ChasteTestOutput);
        FileFinder finder_2("TestAirwayGenerator/decomposed_test_2.vtu", RelativeTo::ChasteTestOutput);
        FileFinder finder_3("TestAirwayGenerator/decomposed_test_0.node", RelativeTo::ChasteTestOutput);
        FileFinder finder_4("TestAirwayGenerator/decomposed_test_1.node", RelativeTo::ChasteTestOutput);
        FileFinder finder_5("TestAirwayGenerator/decomposed_test_2.node", RelativeTo::ChasteTestOutput);
        FileFinder finder_6("TestAirwayGenerator/decomposed_test_0.edge", RelativeTo::ChasteTestOutput);
        FileFinder finder_7("TestAirwayGenerator/decomposed_test_1.edge", RelativeTo::ChasteTestOutput);
        FileFinder finder_8("TestAirwayGenerator/decomposed_test_2.edge", RelativeTo::ChasteTestOutput);

        TS_ASSERT(finder_0.Exists() && !finder_0.IsEmpty());
        TS_ASSERT(finder_1.Exists() && !finder_1.IsEmpty());
        TS_ASSERT(finder_2.Exists() && !finder_2.IsEmpty());
        TS_ASSERT(finder_3.Exists() && !finder_3.IsEmpty());
        TS_ASSERT(finder_4.Exists() && !finder_4.IsEmpty());
        TS_ASSERT(finder_5.Exists() && !finder_5.IsEmpty());
        TS_ASSERT(finder_6.Exists() && !finder_6.IsEmpty());
        TS_ASSERT(finder_7.Exists() && !finder_7.IsEmpty());
        TS_ASSERT(finder_8.Exists() && !finder_8.IsEmpty());
#endif
    }
Example #25
0
void CreateDrainActors()
{
	// Create the drains in the scene
	box			= CreateBox(NxVec3(5,0,0), NxVec3(1.5,1.5,1.5), 1);
	box->getShapes()[0]->setFlag(NX_SF_FLUID_DRAIN,true);
	sphere		= CreateSphere(NxVec3(0,0.0,0), 1.5, 1);
	sphere->getShapes()[0]->setFlag(NX_SF_FLUID_DRAIN,true);
	capsule		= CreateCapsule(NxVec3(-5,0,0), 1, 1, 1);
	capsule->getShapes()[0]->setFlag(NX_SF_FLUID_DRAIN,true);

	gSelectedActor = sphere;
}
Example #26
0
Object* ampoule(glm::vec3 pos)
{
	Container* c = new Container(pos);
	Mesh* m;

	m = CreateSphere(COEF2*1.5,20,20);
	m->setPosition(0,0,0.5);
	c->addObject(m);

	m = CreateCylinder(COEF2*0.5,COEF2*0.5,COEF2*1.0,20.0,1.0);
	m->setPosition(0,0,-1.60+0.25*COEF2);
	c->addObject(m);

	m = CreateCylinder(COEF2*0.25,COEF2*0.5,COEF2*0.25,20.0,10.0);
	m->setPosition(0,0,-1.60);
	c->addObject(m);

	m = CreateSphere(COEF2*0.25,20.0,20.0);
	m->setPosition(0,0,-1.60);
	c->addObject(m);
	return c;
}
Example #27
0
    void TestCalculateLobeVolume()
    {
    #if defined(CHASTE_VTK) && ( (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 6) || VTK_MAJOR_VERSION >= 6)
       EXIT_IF_PARALLEL;

       vtkSmartPointer<vtkPolyData> sphere = CreateSphere(100);

       AirwayGenerator generator(sphere);

       //The sphere is coarsely meshed, hence relatively large tolerance
       TS_ASSERT_DELTA(generator.CalculateLobeVolume(), 4.0/3.0*M_PI, 1e-2);

    #endif
    }
Example #28
0
File: sphere.c Project: paud/d2x-xl
void DrawMonsterball (tObject *objP, float red, float green, float blue, float alpha)
{
if (!gameData.render.monsterball.pSphere) {
	gameData.render.monsterball.nTessDepth = 3;
	gameData.render.monsterball.nFaces = CreateSphere (&gameData.render.monsterball);
	}
if (gameData.render.monsterball.nFaces > 0) {
	tOOF_vector	p;
	G3StartInstanceMatrix (&objP->pos, &objP->orient);
	RenderSphere (&gameData.render.monsterball, (tOOF_vector *) OOF_VecVms2Oof (&p, &objP->pos), 
					  f2fl (objP->size), red, green, blue, alpha, &gameData.hoard.monsterball.bm);
	G3DoneInstance ();
	}
}
Example #29
0
//-------------------------------------------------------------------------------
// @ Player::Player()
//-------------------------------------------------------------------------------
// Constructor
//-------------------------------------------------------------------------------
Player::Player()
{
    mRotate.Identity();
    mScale = 1.0f;
    mTranslate.Zero();

    mRadius = 3.0f;

    mSphereIndices = nullptr;

    mSphereVerts = nullptr;

    CreateSphere();
}   // End of Player::Player()
Example #30
0
File: sphere.c Project: paud/d2x-xl
int CreateShieldSphere (void)
{
if (!LoadShield ())
	return 0;
#if !SIMPLE_SPHERE
if (gameData.render.shield.nTessDepth != gameOpts->render.textures.nQuality + 2) {
	if (gameData.render.shield.pSphere)
		DestroySphere (&gameData.render.shield);
	gameData.render.shield.nTessDepth = gameOpts->render.textures.nQuality + 2;
	}
if (!gameData.render.shield.pSphere)
	gameData.render.shield.nFaces = CreateSphere (&gameData.render.shield);
#endif
return 1;
}