/*
Makes a sphere.
*/
GameEntity* MyGame::BuildSphereEntity(float radius, const Vector3& position) {
	SceneNode* s = new SceneNode(sphere);

	s->SetRotation(Matrix4::Translation(position));

	s->SetModelScale(Vector3(radius,radius,radius));
	s->SetBoundingRadius(radius);

	GameEntity*g = new GameEntity(s, new SpherePhysicsNode());
	((SpherePhysicsNode&)(g->GetPhysicsNode())).SetRadius(radius);
	g->GetPhysicsNode().SetPosition(position);
	g->GetPhysicsNode().SetGravityFactor(EARTH_GRAVITY_FACTOR);
	float massFactor = radius / SPHERE_INITIAL_SIZE;
	g->GetPhysicsNode().SetInvMass(SPHERE_INITIAL_INVMASS / massFactor);
	g->GetPhysicsNode().ActivateNode();
	g->GetPhysicsNode().BuildInertiaMatrix();
	g->ConnectToSystems();
	return g;
}
Exemple #2
0
    void SetUp() {
        RootWithoutRenderSystemFixture::SetUp();

        mSceneMgr = mRoot->createSceneManager();
        mCamera = mSceneMgr->createCamera("Camera");
        mCameraNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
        mCameraNode->attachObject(mCamera);
        mCameraNode->setPosition(0,0,500);
        mCameraNode->lookAt(Vector3(0, 0, 0), Node::TS_PARENT);

        // Create a set of random balls
        Entity* ent = mSceneMgr->createEntity("501", "sphere.mesh", "General");

        // stick one at the origin so one will always be hit by ray
        mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
        createRandomEntityClones(ent, 500, Vector3(-2500,-2500,-2500), Vector3(2500,2500,2500), mSceneMgr);

        mSceneMgr->_updateSceneGraph(mCamera);
    }
    //-----------------------------------------------------------------------
    const LightList& MovableObject::queryLights(void) const
    {
        // Try listener first
        if (mListener)
        {
            const LightList* lightList =
                mListener->objectQueryLights(this);
            if (lightList)
            {
                return *lightList;
            }
        }

        // Query from parent entity if exists
        if (mParentIsTagPoint)
        {
            TagPoint* tp = static_cast<TagPoint*>(mParentNode);
            return tp->getParentEntity()->queryLights();
        }

        if (mParentNode)
        {
            SceneNode* sn = static_cast<SceneNode*>(mParentNode);

            // Make sure we only update this only if need.
            ulong frame = sn->getCreator()->_getLightsDirtyCounter();
            if (mLightListUpdated != frame)
            {
                mLightListUpdated = frame;

				const Vector3& scl = mParentNode->_getDerivedScale();
				Real factor = std::max(std::max(scl.x, scl.y), scl.z);

                sn->findLights(mLightList, this->getBoundingRadius() * factor, this->getLightMask());
            }
        }
        else
        {
            mLightList.clear();
        }

        return mLightList;
    }
Exemple #4
0
/**
*  @brief
*    Called when the scene node assigned with this visibility container was destroyed
*/
void VisContainer::OnDestroy()
{
	SceneNode *pSceneNode = GetSceneNode();
	if (pSceneNode && pSceneNode->IsContainer()) {
		// Get the parent visibility container
		const VisNode *pParent = GetParent();
		if (pParent && pParent->IsContainer()) {
			VisContainer *pParentVisContainer = const_cast<VisContainer*>(static_cast<const VisContainer*>(pParent));

			// Unregister within the parent container
			VisContainer *pContainer = pParentVisContainer->m_mapContainers.Get(pSceneNode->GetName());
			if (pContainer) {
				pParentVisContainer->m_lstNodes.Remove(pContainer);
				delete pContainer;
				pParentVisContainer->m_mapContainers.Remove(pSceneNode->GetName());
			}
		}
	}
}
/**
*  @brief
*    Constructor
*/
SNMScaleRandomAnimation::SNMScaleRandomAnimation(SceneNode &cSceneNode) : SNMTransform(cSceneNode),
	Speed(this),
	Radius(this),
	FixScale(this),
	EventHandlerUpdate(&SNMScaleRandomAnimation::OnUpdate, this),
	m_fTimer(0.0f)
{
	// Set initial fixed scale
	FixScale.Set(cSceneNode.GetTransform().GetScale());
}
int gr_node_translate_cmd(lua_State* L)
{
  GRLUA_DEBUG_CALL;
  
  gr_node_ud* selfdata = (gr_node_ud*)luaL_checkudata(L, 1, "gr.node");
  luaL_argcheck(L, selfdata != 0, 1, "Node expected");

  SceneNode* self = selfdata->node;

  double values[3];
  
  for (int i = 0; i < 3; i++) {
    values[i] = luaL_checknumber(L, i + 2);
  }

  self->translate(glm::vec3(values[0], values[1], values[2]));

  return 0;
}
int scene_m_rotate_cmd(lua_State *L)
{
	GRLUA_DEBUG_CALL;

	scene_node_ud *me = (scene_node_ud*)luaL_checkudata(L, 1, SCENE_META);
	luaL_argcheck(L, me != 0, 1, "Node expected");

	SceneNode *node = me->node;
	Vector3D trans;
	const char *axis_string = luaL_checkstring(L, 2);
	luaL_argcheck(L, axis_string && std::strlen(axis_string) == 1,
			2, "Single character expected");
	char axis = std::tolower(axis_string[0]);
	luaL_argcheck(L, axis >= 'x' && axis <= 'z', 2, "Axis must be x, y or z");
	double angle = luaL_checknumber(L, 3);

	node->rotate(axis, angle);
	return 0;
}
Exemple #8
0
int main()
{
	SceneManager *smgr = AURORA_NEW SceneManager();
	Scene* scene = AURORA_NEW Scene();
	smgr->setScene(scene);
	SceneNode* m = scene->getRootSceneNode()->createChildSceneNode("IHasANode");
	SceneNode *m2 = m->createChildSceneNode("ChildNode1");
	m2->setTranslation(Vector3D(0.f, 0.f, 1.f));
	m->setRotation(Quaternion(Vector3D(0.f, 1.f, 0.f), Degree(90.f)));
	m->setTranslation(Vector3D(0.f, 1.f, 0.f));

	TestEntity *yvonne = AURORA_NEW TestEntity("Yvonne");
	TestEntity *michael = AURORA_NEW TestEntity("Michael");

	m2->attachEntity(yvonne);
	m->attachEntity(michael);

	puts("***********");
	smgr->update();
	puts("***********");

	m2->detachEntity(yvonne);
	m->attachEntity(yvonne);

	// NASTY!
	scene->getRootSceneNode()->translate(Vector3D(0.f, 1.f, 0.f));

	puts("***********");
	smgr->update();
	puts("***********");

	m->detachEntity(yvonne);
	m->detachEntity(michael);
	m2->attachEntity(michael);

	puts("***********");
	smgr->update();
	puts("***********");
	puts("");

	// Be a good boy and clean up after yourself!
	AURORA_DELETE smgr;
	AURORA_DELETE scene;
	AURORA_DELETE yvonne;
	AURORA_DELETE michael;

	Aurora::MemoryTracker::getSingletonPtr()->report(std::cout);

	{char c;scanf("%c",&c);}

	return 0;
}
Exemple #9
0
void OgreCPP::setup(std::string mResourcePath)
{
	
	// Create a new root object with the correct paths
#ifdef __linux
	mRoot = new Root(mResourcePath + "/plugins_linux.cfg", mResourcePath + "/ogre.cfg",
						   mResourcePath + "/ogre.log");
#else
	mRoot = new Root(mResourcePath + "/Contents/MacOS/plugins.cfg", mResourcePath + "/Contents/MacOS/ogre.cfg",
						   mResourcePath + "/Contents/MacOS/ogre.log");
	mRoot->setRenderSystem(mRoot->getAvailableRenderers().front());
#endif
		
	
	// Show a configure box and exit if user clicked cancel
	if(!mRoot->showConfigDialog())
		return;
	
	// Initialise
	RenderWindow *mWindow = mRoot->initialise(true);
	mSceneMgr = mRoot->createSceneManager(ST_GENERIC, "My scene manager");
    
	// Add resource locations
	//ResourceGroupManager::getSingleton().addResourceLocation(mResourcePath,
	//														 std::string("FileSystem"), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
	setupResources(mResourcePath);
	ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
	
	// Create the camera, node & attach camera
	Camera *mCamera = mSceneMgr->createCamera("PlayerCam");
	SceneNode *camNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
	camNode->attachObject(mCamera);
	mWindow->addViewport(mCamera);

    mCamera->setPosition(Ogre::Vector3(0,0,0));
    mCamera->lookAt(Ogre::Vector3(0,0,300));
    mCamera->roll( Ogre::Radian( M_PI ) );
    mCamera->setNearClipDistance( 0.2 );

	createScene();

}
Exemple #10
0
bool Game::bulletSetup(){

	AxisAlignedBox bounds(
		Ogre::Vector3 (-10000, -10000, -10000),
		Ogre::Vector3 (10000,  10000,  10000)
	);
	Vector3 gravityVector(0,-9.81 * 2,0);

	mWorld = new OgreBulletDynamics::DynamicsWorld(mSceneMgr, bounds, gravityVector);
	debugDrawer = new OgreBulletCollisions::DebugDrawer();
	debugDrawer->setDrawWireframe(true);	// we want to see the Bullet containers

	mWorld->setDebugDrawer(debugDrawer);
	mWorld->setShowDebugShapes(false);
	SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode("debugDrawer", Ogre::Vector3::ZERO);
	node->attachObject(static_cast <SimpleRenderable *> (debugDrawer));

	return true;

}
Exemple #11
0
bool Scene::clear(TypeID type)
{
  std::vector<SceneNode*>::iterator iter;
  for (iter = nodes.begin(); iter != nodes.end();) {
    if ((*iter)->getTypeID() == type) {
      SceneNode* node = (*iter);
      int id = node->getObjID();
      if (id == rootSubscene.getObjID()) 
        ++iter;
      else {
        hide(node->getObjID());
        delete node;
        iter = nodes.erase(iter);
      }
    } else
      ++iter;
  }
  SAVEGLERROR;
  return true;
}
Exemple #12
0
void Play2State::_constructTestStageSceneNode(void)
{

	SceneNode* mCollision = mSceneMgr->getRootSceneNode()->createChildSceneNode("CollisionNode");
	Entity* collisionEntity[COLLISION_MAX];
	for (int i = 0; i<mPattern.size(); ++i)
	{
		char collisionName[20];
		sprintf(collisionName, "CollisionEntity%d", i + 1);

		collisionEntity[i] = mSceneMgr->createEntity(collisionName, "coin.mesh");


		sprintf(collisionName, "CollisionNode%d", i + 1);
		collisionNode[i] = mCollision->createChildSceneNode(collisionName, mPattern[i]);
		//mCollision->setScale(3, 3, 1);
		collisionNode[i]->attachObject(collisionEntity[i]);
		//collisionNode[i]->scale(2.0f, 2.0f, 2.0f);
	}
}
Exemple #13
0
	void VideoManager::createQuad(String name,String material_name,float left,float top,float right,float bottom)
	{
		ManualObject* model = OgreManager::getSingleton().getSceneManager()->createManualObject(name);
		model->begin(material_name);

		model->position(right,bottom,0); model->textureCoord(1,1);
		model->position(right,top   ,0); model->textureCoord(1,0);
		model->position(left ,top   ,0); model->textureCoord(0,0);
		model->position(left ,top   ,0); model->textureCoord(0,0);
		model->position(right,bottom,0); model->textureCoord(1,1);
		model->position(left, bottom,0); model->textureCoord(0,1);

		model->end();
		// make the model 2D
		model->setUseIdentityProjection(true);
		model->setUseIdentityView(true);
		// and atach it to the root node
		SceneNode* node = OgreManager::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode();
		node->attachObject(model);
	}
void // load and place a model in a certain location.
Grid::loadObject(std::string name, std::string filename, int row, int height, int col, float scale)
{
	using namespace Ogre;

	if (row >= nRows || col >= nCols || row < 0 || col < 0)
		return;

	Entity *ent = mSceneMgr->createEntity(name, filename);
    SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode(name,
        Ogre::Vector3(0.0f, 0.0f,  0.0f));
    node->attachObject(ent);
    node->setScale(scale, scale, scale);

	GridNode* gn = this->getNode(row, col);
	node->setPosition(getPosition(row, col)); 
	node->setPosition(getPosition(row, col).x, height, getPosition(row, col).z);
	gn->setOccupied();
	gn->entity = ent;
}
	/// Draw the world.
	void draw(RenderQueueDrawContext& ctx)
	{
		if(ctx.m_debugDraw)
		{
			m_dbgDrawer.prepareFrame(&ctx);
			m_dbgDrawer.setViewProjectionMatrix(ctx.m_viewProjectionMatrix);
			m_dbgDrawer.setModelMatrix(Mat4::getIdentity());
			m_physDbgDrawer.drawWorld(m_node->getSceneGraph().getPhysicsWorld());
			m_dbgDrawer.finishFrame();
		}
	}
Exemple #16
0
void Aircraft::createPickup(SceneNode &node, const TextureHolder &textures) const
{
    auto type = static_cast<Pickup::Type>(randomInt(Pickup::TypeCount));
    
    std::unique_ptr<Pickup> pickup(new Pickup(type, textures));
    pickup->setPosition(getWorldPosition());
    pickup->setVelocity(0.f, 1.f);
    node.attachChild(std::move(pickup));

    
}
  bool nextLocation(void)
  {
    if (mWalkList.empty())  // 더 이상 목표 지점이 없으면 false 리턴
      return false;
    mDestination = mWalkList.front(); // 큐의 가장 앞에서 꺼내기
    mWalkList.pop_front(); // 가장 앞 포인트를 제거
    mDirection = mDestination - mProfessorNode->getPosition( ); // 방향 계산
    mDistance = mDirection.normalise( ); // 거리 계산

    return true;
  }
    //-----------------------------------------------------------------------
	bool MovableObject::isInScene(void) const
	{
		if (mParentNode != 0)
		{
			if (mParentIsTagPoint)
			{
				TagPoint* tp = static_cast<TagPoint*>(mParentNode);
				return tp->getParentEntity()->isInScene();
			}
			else
			{
				SceneNode* sn = static_cast<SceneNode*>(mParentNode);
				return sn->isInSceneGraph();
			}
		}
		else
		{
			return false;
		}
	}
Exemple #19
0
MWScene::MWScene(OEngine::Render::OgreRenderer &_rend)
  : rend(_rend)
{
  rend.createScene("PlayerCam", 55, 5);

  // Set default mipmap level (NB some APIs ignore this)
  TextureManager::getSingleton().setDefaultNumMipmaps(5);

  // Load resources
  ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

  // Turn the entire scene (represented by the 'root' node) -90
  // degrees around the x axis. This makes Z go upwards, and Y go into
  // the screen (when x is to the right.) This is the orientation that
  // Morrowind uses, and it automagically makes everything work as it
  // should.
  SceneNode *rt = rend.getScene()->getRootSceneNode();
  mwRoot = rt->createChildSceneNode();
  mwRoot->pitch(Degree(-90));
}
Exemple #20
0
TEST_F(Instancing, Bounds) {
    SceneManager* sceneMgr = SceneManagerEnumerator::getSingleton().createSceneManager(ST_GENERIC);
    Entity* entity = sceneMgr->createEntity("robot.mesh");

    MeshPtr mesh = entity->getMesh();
    InstanceBatchShader batch(NULL, mesh, entity->getSubEntity(0)->getMaterial(), 1, NULL, "");
    InstancedEntity instanced_entity(&batch, 0);

    SceneNode* node = sceneMgr->createSceneNode();
    node->attachObject(&instanced_entity);
    node->attachObject(entity);
    node->translate(Vector3::UNIT_X);
    node->setScale(Vector3(2, 2, 2));

    EXPECT_EQ(instanced_entity.getBoundingBox(), entity->getBoundingBox());
    EXPECT_EQ(instanced_entity.getBoundingRadius(), entity->getBoundingRadius());

    sceneMgr->destroyEntity(entity);
    MeshManager::getSingleton().remove(mesh->getHandle());
}
Exemple #21
0
void GrassPage::removeEntities()
{
  std::list<SceneNode*>::iterator i;
  for (i = nodeList.begin(); i != nodeList.end(); ++i) {
    SceneNode *node = *i;
    int numObjs = node->numAttachedObjects();
    for (int j = 0; j < numObjs; j++) {
      Entity *ent = static_cast<Entity*>(node->getAttachedObject(j));
      if (!ent)
        continue;
      // remove the mesh
      MeshManager::getSingleton().remove(ent->getMesh()->getName());
      // then the entity
      sceneMgr->destroyEntity(ent);
      // and finally the scene node
      sceneMgr->destroySceneNode(node);
    }
  }
  nodeList.clear();
}
Exemple #22
0
void OgreARAppLogic::createCameraBackground()
{
	// Create background rectangle covering the whole screen
	Rectangle2D* rect = new Rectangle2D(true);
	rect->setCorners(-1.0, 1.0, 1.0, -1.0);
	rect->setMaterial("CameraMaterial");

	// Render the background before everything else
	rect->setRenderQueueGroup(RENDER_QUEUE_BACKGROUND);

	// Hacky, but we need to set the bounding box to something big
	// Use infinite AAB to always stay visible
	AxisAlignedBox aabInf;
	aabInf.setInfinite();
	rect->setBoundingBox(aabInf);

	// Attach background to the scene
	SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Background");
	node->attachObject(rect);
}
Exemple #23
0
/**
*  @brief
*    Post draw all scene nodes recursive
*/
void SPScene::DrawPost(Renderer &cRenderer, SceneContainer &cContainer)
{
	// Get the scene container (can be a null pointer)
	SceneContainer *pContainer = GetSceneContainer();

	// Draw parent container
	if (&cContainer != pContainer)
		cContainer.DrawPost(cRenderer);

	// Loop through all nodes
	for (uint32 i=0; i<cContainer.GetNumOfElements(); i++) {
		SceneNode *pNode = cContainer.GetByIndex(i);
		if (pNode != pContainer && pNode->IsVisible() && (pNode->GetDrawFunctionFlags() & SceneNode::UseDrawPost)) {
			if (pNode->IsContainer())
				DrawPost(cRenderer, static_cast<SceneContainer&>(*pNode));
			else
				pNode->DrawPost(cRenderer);
		}
	}
}
/**
*  @brief
*    Called when a scene node was found
*/
void SNGun::OnSceneNode(SceneQuery &cQuery, SceneNode &cSceneNode)
{
	// Is this gun still active?
	if (IsActive()) {
		// Is this a bomb?
		if (cSceneNode.IsInstanceOf("SNBomb")) {
			// Is the bomb still alive?
			if (!cSceneNode.GetAttribute("Killed")->GetBool()) {
				// Jap, kill the bomb right now
				cSceneNode.SetAttribute("Killed", "1");

				// Destroy this gun
				Delete();

				// Done, do NOT continue the query!
				cQuery.Stop();
			}
		}
	}
}
/**
 * Construct a box with the given dimensions.
 */
SceneNode* ConstructBox(float x, float y, float z)
{
   UnitSquareFlatSurface* xySurf = new UnitSquareFlatSurface(x,y,true,Vector2(),.05f);
   UnitSquareFlatSurface* xzSurf = new UnitSquareFlatSurface(x,z,true,Vector2(),.05f);
   UnitSquareFlatSurface* yzSurf = new UnitSquareFlatSurface(z,y,true,Vector2(),.05f);
   x *= .5;
   y *= .5;
   z *= .5;

   // Contruct transform nodes for the sides of the box.
   // Perform rotations so the sides face outwards
   // Bottom is rotated 180 degrees so it faces outwards
   TransformNode* bottomTransform = new TransformNode;
   bottomTransform->Translate(0.0f, 0.0f, -z);
   bottomTransform->Rotate(180.0f, 1.0f, 0.0f, 0.0f);   

   // Back is rotated -90 degrees about x: (z -> y)
   TransformNode* backTransform = new TransformNode;
   backTransform->Translate(0.0f, y, 0.0f);
   backTransform->Rotate(-90.0f, 1.0f, 0.0f, 0.0f);   

   // Front wall is rotated 90 degrees about x: (y -> z)
   TransformNode* frontTransform = new TransformNode;
   frontTransform->Translate(0.0f, -y, 0.0f);
   frontTransform->Rotate(90.0f, 1.0f, 0.0f, 0.0f);   

   // Left wall is rotated -90 about y: (z -> -x)
   TransformNode* leftTransform = new TransformNode;
   leftTransform->Translate(-x, 0.0f, 00.0f);
   leftTransform->Rotate(-90.0f, 0.0f, 1.0f, 0.0f);

   // Right wall is rotated 90 degrees about y: (z -> x)
   TransformNode* rightTransform = new TransformNode;
   rightTransform->Translate(x, 0.0f, 0.0f);
   rightTransform->Rotate(90.0f, 0.0f, 1.0f, 0.0f);

   // Top 
   TransformNode* topTransform = new TransformNode;
   topTransform->Translate(0.0f, 0.0f, z);

   // Create a SceneNode and add the 6 sides of the box.
   SceneNode* box = new SceneNode;
   box->AddChild(backTransform);
   backTransform->AddChild(xzSurf);
   box->AddChild(leftTransform);
   leftTransform->AddChild(yzSurf);
   box->AddChild(rightTransform);
   rightTransform->AddChild(yzSurf);
   box->AddChild(frontTransform);
   frontTransform->AddChild(xzSurf);
   box->AddChild(bottomTransform);
   bottomTransform->AddChild(xySurf);
   box->AddChild(topTransform);
   topTransform->AddChild(xySurf);
   return box;
}
//[-------------------------------------------------------]
//[ Private virtual PLEngine::EngineApplication functions ]
//[-------------------------------------------------------]
void Application70::OnCreateScene(SceneContainer &cContainer)
{
	// Create a camera
	SceneNode *pCamera = cContainer.Create("PLScene::SNCamera", "FreeCamera", "Position=\"1 2 -3\" Rotation=\"25 210 0\"");
	if (pCamera && pCamera->IsInstanceOf("PLScene::SNCamera")) {
		// Make this to our main scene camera
		SetCamera(reinterpret_cast<SNCamera*>(pCamera));

		// Add a controller modifier so we can look around the camera by using a default control
		pCamera->AddModifier("PLEngine::SNMEgoLookController");

		// Add a controller modifier so we can move around the camera by using a default control
		pCamera->AddModifier("PLEngine::SNMMoveController");
	}

	// Create the floor
	cContainer.Create("PLScene::SNMesh", "Floor", "Position=\"0 0 -5\" Scale=\"4 0.1 4\" Mesh=\"Default\"");

	// Create an instance of the fire particle effect scene node
	cContainer.Create("SNFireSample", "Fire", "Position=\"0.5 0.3 -5\" Scale=\"0.1 0.1 0.1\"");

	// Create an instance of the basic particle effect scene node
	cContainer.Create("SNBasicSample", "Basic", "Position=\"-0.5 0.1 -8\" Scale=\"0.5 0.5 0.5\"");

	// Create an instance of the gravitation particle effect scene node
	cContainer.Create("SNGravitationSample", "Gravitation", "Position=\"-1 1 -5\" Scale=\"0.5 0.5 0.5\"");

	// Create an instance of the galaxy particle effect scene node
	cContainer.Create("SNGalaxySample", "Galaxy", "Position=\"-3 0.5 -8\" Scale=\"0.5 0.5 0.5\"");

	// Setup scene surface painter
	SurfacePainter *pPainter = GetPainter();
	if (pPainter && pPainter->IsInstanceOf("PLScene::SPScene")) {
		SPScene *pSPScene = static_cast<SPScene*>(pPainter);
		pSPScene->SetRootContainer(cContainer.GetContainer());
		pSPScene->SetSceneContainer(&cContainer);
	}

	// Set scene container
	SetScene(&cContainer);
}
/**
*  @brief
*    Draws recursive
*/
void SRPDeferredLighting::DrawRec(Renderer &cRenderer, const SQCull &cCullQuery, SRPDeferredGBuffer &cSRPDeferredGBuffer)
{
	// Get scene container
	const VisContainer &cVisContainer = cCullQuery.GetVisContainer();

	// Render all visible scene nodes of this scene container
	Iterator<VisNode*> cIterator = cVisContainer.GetVisNodes().GetIterator();
	while (cIterator.HasNext()) {
		// Get visibility node and scene node
		const VisNode   *pVisNode   = cIterator.Next();
			  SceneNode *pSceneNode = pVisNode->GetSceneNode();
		if (pSceneNode) {
			// Is this scene node a portal?
			if (pVisNode->IsPortal()) {
				// Get the target cell visibility container
				const VisContainer *pVisCell = static_cast<const VisPortal*>(pVisNode)->GetTargetVisContainer();
				if (pVisCell && pVisCell->GetCullQuery()) {
					// Draw the target cell
					DrawRec(cRenderer, *pVisCell->GetCullQuery(), cSRPDeferredGBuffer);
				}

			// Is this scene node a container? We do not need to check for cells because we will
			// NEVER receive cells from SQCull directly, they are ONLY visible through portals! (see above)
			} else if (pVisNode->IsContainer()) {
				// Draw this container without special processing
				if (static_cast<const VisContainer*>(pVisNode)->GetCullQuery())
					DrawRec(cRenderer, *static_cast<const VisContainer*>(pVisNode)->GetCullQuery(), cSRPDeferredGBuffer);

			// Is this a light?
			} else if (pSceneNode->IsLight()) {
				if (static_cast<SNLight*>(pSceneNode)->IsRenderLight()) {
					// Render the light
					RenderLight(cRenderer, cCullQuery, cSRPDeferredGBuffer, *static_cast<SNLight*>(pSceneNode), *pVisNode);
				}

			// This must just be a quite boring scene node, ignore it
			} else {
			}
		}
	}
}
	bool RenderTarget::_readyDrawCalls()
	{
		mTriangleCount = 0;
		mBatchCount = 0;
		mSavedByBatching = 0;

		// If theres no camera, nothing to render
		if (!mCamera) return false;

		// Get the cameras parent, if its not attached to anything, theres nothing to render
		SceneNode* camParent = mCamera->getParent();
		if (!camParent) return false;

		// Find the highest node in the hierarchy
		SceneNode* rootNode = camParent->getRootNode();
		if (!rootNode) return false;

		Main::getRenderSystem().clear(glm::vec4(0.1,0.1,0.1, 1), GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		mCachedRenderableList.clear();
		rootNode->_getRenderables(mCachedRenderableList, mCamera, true);

		mCachedDrawCallList.clear();
		for (auto iter : mCachedRenderableList)
			iter->_extractDrawCalls(mCachedDrawCallList, *mCamera);

		std::sort(mCachedDrawCallList.begin(), mCachedDrawCallList.end(),
			[](const Renderable::DrawCall& first, const Renderable::DrawCall& second)
		{
			return first.sortKey.key < second.sortKey.key;
		});

		// Update the render system with the camera data
		glm::mat4 camMatrix = mCamera->getParent()->getGlobalTransform();
		glm::mat4 viewMatrix = glm::inverse(camMatrix);
		ngRenderSys.setCameraMatrices(mCamera->getProjMatrix(), viewMatrix, camMatrix);



		return true;
	}
Exemple #29
0
	void Model::LoadSkeleton(std::fstream& fileStream, SceneNode* parentNode)
	{
		bool isSceneNode;
		ModelDeSerializer::ReadAsBytes(fileStream, isSceneNode);

		SceneNode* node;

		if (isSceneNode)
		{
			node = new SceneNode(*this, fileStream);
		}
		else
		{
			std::string name;
			ModelDeSerializer::ReadAsBytes(fileStream, name);

			//find bone and do fixup
			UINT boneIndex = mBoneIndexMapping[name];
			node = mBones[boneIndex];
		}

		node->SetParent(parentNode);

		if (parentNode != nullptr)
		{
			parentNode->Children().push_back(node);
		}
		else
		{
			mRootNode = node;
		}

		uint_t childCount;
		ModelDeSerializer::ReadAsBytes(fileStream, childCount);
		node->Children().reserve(childCount);

		for (int i = 0; i < childCount; i++)
		{
			LoadSkeleton(fileStream, node);
		}
	}
v8::Handle<v8::Value> ScriptHandler::translateSceneNode(const v8::Arguments &args)
{
	v8::HandleScope handleScope;

	v8::Local<v8::String> value = args[0]->ToString();

	int vectorX = args[1]->Int32Value();
	int vectorY = args[2]->Int32Value();
	int vectorZ = args[3]->Int32Value();

	v8::String::AsciiValue ascii(value);

	string nodeName = *ascii;
	
	SceneNode * tempNode = Root::getInstance().findSceneNodeByName(nodeName);

	if(tempNode != NULL)
		tempNode->translate(Vector(vectorX, vectorY, vectorZ));
	
	return value;
}