Example #1
0
	// 渲染
	Bool D3D9Renderer::renderTexture(Texture* pTexture, Color cDiffuse, const Rect& rcTex, const Rect& rcScreen)
	{
		if (pTexture)
		{
			// 带贴图渲染
			IDirect3DTexture9* pTex = ((D3D9Texture*)pTexture)->_pTex;
			return _render(pTex, pTexture->getSize(), cDiffuse, rcTex, rcScreen);
		}
		else
		{
			// 纯色渲染
			Point ptTex(16, 16);
			return _render(0, ptTex, cDiffuse, rcTex, rcScreen);
		}
	}
Example #2
0
float *PlainSuperMesh::render(UserInterface *ui,
                              glm::mat4 const& model,
                              float *args)
{
#if 0
  printf("[ [ %5.2f %5.2f %5.2f %5.2f ]   THIS MATRIX<%s>\n"
         "  [ %5.2f %5.2f %5.2f %5.2f ]\n"
         "  [ %5.2f %5.2f %5.2f %5.2f ]\n"
         "  [ %5.2f %5.2f %5.2f %5.2f ] ]\n",
         matrix[0][0], matrix[0][1], matrix[0][2], matrix[0][3], 
         name.c_str(),
         matrix[1][0], matrix[1][1], matrix[1][2], matrix[1][3], 
         matrix[2][0], matrix[2][1], matrix[2][2], matrix[2][3], 
         matrix[3][0], matrix[3][1], matrix[3][2], matrix[3][3] );

  printf("[ [ %5.2f %5.2f %5.2f %5.2f ]   PARENT MODEL\n"
         "  [ %5.2f %5.2f %5.2f %5.2f ]\n"
         "  [ %5.2f %5.2f %5.2f %5.2f ]\n"
         "  [ %5.2f %5.2f %5.2f %5.2f ] ]\n",
         model[0][0], model[0][1], model[0][2], model[0][3], 
         model[1][0], model[1][1], model[1][2], model[1][3], 
         model[2][0], model[2][1], model[2][2], model[2][3], 
         model[3][0], model[3][1], model[3][2], model[3][3] );
#endif

  glm::mat4 m = model * matrix;

  /*glm::vec4 org = m * glm::vec4(0,0,0,1);
  printf("---------------------------------------> (%5.2f %5.2f %5.2f)\n",
         org[0], org[1], org[2]);
  */
  args = _render(ui, m, args);
  //show_axes(ui, m);
  return args;
}
Example #3
0
void GraphicsEngine::frame(double time) {
    _cameraMgr->update();
    bool renderResult = _render(time);
    Ogre::WindowEventUtilities::messagePump();
    if(_renderWindow->isClosed() || !renderResult) {
        _parent->changeState(Game::GS_QUIT);
    }
}
Example #4
0
const bool XG_TextBox::Load(XG_Container* handle){
	XG_Component::Load(handle);
	this->Set_Size(this->w,this->h);
	Texture _b(1,this->data.Get_Font()->Get_H_Font());
	Image _render(_b);
	this->cursore=_render;
	return this->UpDate_Render();
}
Example #5
0
float *SingleAxisTranslationMesh::render(UserInterface *ui,
                                         glm::mat4 const& model,
                                         float *args)
{
  //printf("TRANSLATE <%.3f %.3f %3f> * %.3f\n", axis[0], axis[1], axis[2], args[0]);
  float distance = *args++;
  glm::mat4 m = glm::translate(model * matrix, axis*distance);
  return _render(ui, m, args);
}
Example #6
0
float *SingleAxisRotationMesh::render(UserInterface *ui,
                                         glm::mat4 const& model,
                                         float *args)
{
  //printf("ROTATE <%.3f %.3f %3f> * %.3f\n", axis[0], axis[1], axis[2], args[0]);
  float angle = *args++;
  glm::mat4 m = glm::rotate(model * matrix, angle, axis);
  return _render(ui, m, args);
}
Example #7
0
void DocumentationViewer::_render(shared_ptr<EntitiesEntity> entity, shared_ptr<XMLPortalExporter> exporter, uint32 level, uint32 levelMax, bool withTexts, bool forContent)
{
	if(entity == nullptr)
		return;

	if(levelMax == 0) // Disabled.
		return;

	if(forContent)
		exporter->setMode(XMLPortalExporter::emFull);
	else
		exporter->setMode(XMLPortalExporter::emLite);
	
	entity->exportXML(exporter);

	bool exportTexts = withTexts;
	// I testi già comparsi sopra non compaiono nel sottoindice.
	if( (exportTexts) && (forContent == false) )
		exportTexts = (level > 0);

	// Esporta gli oggetti testo
	if(exportTexts)
	{
		shared_ptr<EntitiesEntities> texts = entity->getChilds(getDatabase(), portalObjectTypeText, RangeUint32(0, 0), EntitiesEntity::coPositionAsc);
		if(texts != nullptr && texts->empty() == false)
		{
			shared_ptr<XMLNode> nodeTexts = exporter->getRoot()->addChild(_S("texts"));
			for(EntitiesEntities::const_iterator i = texts->begin(); i != texts->end(); ++i)
			{
				exporter->getPage()->getPortal()->getEntity(exporter->getDatabase(), *i)->exportXML(exporter->createChild<XMLPortalExporter>(nodeTexts->addChild(_S("text"))));
			}
		}
	}

	bool exportSections = true;
	if(levelMax != static_cast<uint32>(-1))
	{
		if(forContent)
			exportSections = (level<(levelMax-1));
		else
			exportSections = (level<=(levelMax-1));
	}

	// Crea un nodo delle sotto-sezioni
	if(exportSections)
	{
		shared_ptr<EntitiesEntities> subSections = entity->getChilds(getDatabase(), portalObjectTypeSection, RangeUint32(0, 0), EntitiesEntity::coPositionAsc);
		if(subSections != nullptr && subSections->empty() == false)
		{
			shared_ptr<XMLNode> nodeSubSections = exporter->getRoot()->addChild(_S("sections"));
			for(EntitiesEntities::const_iterator i = subSections->begin(); i != subSections->end(); ++i)
			{
				_render(exporter->getPage()->getPortal()->getEntity(getDatabase(), *i), exporter->createChild<XMLPortalExporter>(nodeSubSections->addChild(_S("section"))), level +1, levelMax, withTexts, forContent);
			}
		}
	}
}
Example #8
0
void TileLayerComponentManager::render(EntityRef entity, float interp, const OrthographicCamera& camera) {
	compactArray();

	_states.shader = _spriteRenderer->shader().shader;
	_states.buffer = _spriteRenderer->buffer();
	_states.format = _spriteRenderer->format();

	_render(entity, interp, camera);
}
void ForestCellBatch::render( SceneRenderState *state )
{
   if ( mDirty )
   {
      _rebuildBatch();
      mDirty = false;
   }

   _render( state );
}
Example #10
0
void DocumentationViewer::onLoad()
{
	ViewerBase::onLoad();

	shared_ptr<XMLNode> root = getComponentDocument()->getRoot();
	OS_ASSERT(root != nullptr);

	shared_ptr<EntitiesEntity> entity = m_entity;
	if(entity == nullptr)
		entity = getEntity(getDatabase());

	/* Defaults
	String tocLayout = _S("right");
	int32 tocMinTexts = 3;
	int32 contentLevel = 1;
	int32 subindexLevel = -1;
	bool subindexShowTexts = true;
	*/
	String tocLayout = root->getAttributeString("toc_layout");
	int32 tocMinTexts = root->getAttributeInt32("toc_mintexts");
	int32 contentLevel = root->getAttributeInt32("content_level");
	int32 subindexLevel = root->getAttributeInt32("subindex_level");
	bool subindexShowTexts = root->getAttributeBool("subindex_showtexts");

	shared_ptr<XMLPortalExporter> exporter(OS_NEW XMLPortalExporter(getDocument()->create(_S("documentation")), getPage(), XMLPortalExporter::emFull));

	exporter->setAttributeString("toc_layout", tocLayout);
	exporter->setAttributeInt32("toc_mintexts", tocMinTexts);
	exporter->setAttributeInt32("content_level", contentLevel);
	exporter->setAttributeInt32("subindex_level", subindexLevel);
	exporter->setAttributeBool("subindex_showtexts", subindexShowTexts);

	shared_ptr<XMLPortalExporter> contentsExporter = exporter->createChild<XMLPortalExporter>(_S("contents"));

	if(entity != nullptr)
		_render(entity, contentsExporter, 0, contentLevel, true, true);

	shared_ptr<XMLPortalExporter> subindexExporter = exporter->createChild<XMLPortalExporter>(_S("subindex"));

	if(entity != nullptr)
		_render(entity, subindexExporter, 0, subindexLevel, subindexShowTexts, false);
}
Example #11
0
void BitmapTextComponentManager::render(EntityRef entity, float interp, const OrthographicCamera& camera) {
	compactArray();

	_states.shader = _spriteRenderer->shader().shader;
	_states.buffer = _spriteRenderer->buffer();
	_states.format = _spriteRenderer->format();
	_states.textureFlags = Texture::BILINEAR_NO_MIPMAP | Texture::CLAMP;
	_states.blendingMode = BLEND_ALPHA;

	_render(entity, interp, camera);
}
Example #12
0
void
Scene::render()
{
    // cache the current draw buffer; bail out if we didn't get one
    if ((_current_framebuffer = gPanel.get_draw_buffer()) == nullptr) {
        return;
    }

    _current_framebuffer->clear();
    _render();
    gPanel.push_draw_buffer();
}
Example #13
0
void Engine::exec(void) {
	if(!_timer.is_started()) _timer.start();
	if( _timer.is_paused() ) _timer.unpause();

	_window->clear();

	if(_logic != nullptr) _logic(this);
	if(_render != nullptr) _render(this);

	_window->render();

	_window->incFrames();
	++_frames;
}
Example #14
0
    void render( const RenderInput& renderInput,
                 RenderOutput& renderOutput )
    {
        reshape( renderInput.windowSize );

        _engine->preRender();

        _engine->getCamera()->set(
            renderInput.position, renderInput.target, renderInput.up );

#if(BRAYNS_USE_DEFLECT || BRAYNS_USE_REST)
        if( !_extensionPluginFactory )
            _intializeExtensionPluginFactory( );
        _extensionPluginFactory->execute( );
#endif

        ScenePtr scene = _engine->getScene();
        CameraPtr camera = _engine->getCamera();
        FrameBufferPtr frameBuffer = _engine->getFrameBuffer();
        const Vector2i& frameSize = frameBuffer->getSize();

        if( _parametersManager->getRenderingParameters().getSunOnCamera() )
        {
            LightPtr sunLight = scene->getLight( 0 );
            DirectionalLight* sun =
                dynamic_cast< DirectionalLight* > ( sunLight.get() );
            if( sun )
            {
                sun->setDirection( camera->getTarget() - camera->getPosition() );
                scene->commitLights();
            }
        }

        camera->commit();
        _render( );

        uint8_t* colorBuffer = frameBuffer->getColorBuffer( );
        size_t size =
            frameSize.x( ) * frameSize.y( ) * frameBuffer->getColorDepth( );
        renderOutput.colorBuffer.assign( colorBuffer, colorBuffer + size );

        float* depthBuffer = frameBuffer->getDepthBuffer( );
        size = frameSize.x( ) * frameSize.y( );
        renderOutput.depthBuffer.assign( depthBuffer, depthBuffer + size );

        _engine->postRender();
    }
Example #15
0
void Box::render() {
    _render();
   
    if (!wireframe) {
        glColor4f((GLfloat)fillColor[0],
            (GLfloat)fillColor[1],
            (GLfloat)fillColor[2],
            (GLfloat)fillColor[3]);
        glutSolidCube(1.0f); 
    }
   
    glColor4f((GLfloat)lineColor[0],
        (GLfloat)lineColor[1],
        (GLfloat)lineColor[2],
        (GLfloat)lineColor[3]);
    glutWireCube(1.0f);
}
Example #16
0
    void render()
    {
        ScenePtr scene = _engine->getScene();
        CameraPtr camera = _engine->getCamera();
        FrameBufferPtr frameBuffer = _engine->getFrameBuffer();
        const Vector2i& frameSize = frameBuffer->getSize();

        _engine->preRender();

#if(BRAYNS_USE_DEFLECT || BRAYNS_USE_REST)
        if( !_extensionPluginFactory )
            _intializeExtensionPluginFactory( );
        _extensionPluginFactory->execute( );
#endif
        if( _parametersManager->getRenderingParameters().getSunOnCamera() )
        {
            LightPtr sunLight = scene->getLight( 0 );
            DirectionalLight* sun =
                dynamic_cast< DirectionalLight* > ( sunLight.get() );
            if( sun )
            {
                sun->setDirection( camera->getTarget() - camera->getPosition() );
                scene->commitLights();
            }
        }

        camera->commit();
        _render( );

        _engine->postRender();

        const Vector2ui windowSize = _parametersManager
            ->getApplicationParameters()
            .getWindowSize();
        if( windowSize != frameSize )
            reshape(windowSize);
    }
Example #17
0
	// 渲染(渲染目标)
	Bool D3D9Renderer::renderRenderTarget(RenderTarget* pRT, Color cDiffuse, const Rect& rcTex, const Rect& rcScreen)
	{
		IDirect3DTexture9* pTex = ((D3D9RenderTarget*)pRT)->_pTex;
		return _render(pTex, pRT->getRenderSize(), cDiffuse, rcTex, rcScreen);
	}
Example #18
0
	void GameObject::render(Shader* shader, Camera *cam, SceneManager* smgr)
	{
		_render(shader, cam, smgr);
		postRender(shader, cam, smgr);

	}
Example #19
0
	void Container::_renderPatches( GfxDevice * pDevice, const Rect& _canvas, const Rect& _window, Patches * _pPatches )
	{
	
		// We start by eliminating dirt outside our geometry
	
		Patches 	patches( _pPatches->size() );								// TODO: Optimize by pre-allocating?
	
		for( const Rect * pRect = _pPatches->begin() ; pRect != _pPatches->end() ; pRect++ )
		{
			if( _canvas.intersectsWith( *pRect ) )
				patches.push( Rect(*pRect,_canvas) );
		}
	
	
		// Render container itself
		
		for( const Rect * pRect = patches.begin() ; pRect != patches.end() ; pRect++ )
			_render(pDevice, _canvas, _window, *pRect );
			
		
		// Render children
	
		Rect	dirtBounds = patches.getUnion();
		
		if( m_bSiblingsOverlap )
		{
	
			// Create WidgetRenderContext's for siblings that might get dirty patches
	
			std::vector<WidgetRenderContext> renderList;
	
			Rect childGeo;
			Hook * p = _firstHookWithGeo( childGeo );
			while(p)
			{
				Rect geo = childGeo + _canvas.pos();
	
				if( p->_isVisible() && geo.intersectsWith( dirtBounds ) )
					renderList.push_back( WidgetRenderContext(p->_widget(), geo ) );
	
				p = _nextHookWithGeo( childGeo, p );
			}
	
			// Go through WidgetRenderContexts in reverse order (topmost first), push and mask dirt
	
			for( int i = renderList.size()-1 ; i >= 0 ; i-- )
			{
				WidgetRenderContext * p = &renderList[i];
	
				p->patches.push( &patches );
	
				p->pWidget->_maskPatches( patches, p->geo, p->geo, pDevice->blendMode() );		//TODO: Need some optimizations here, grandchildren can be called repeatedly! Expensive!
	
				if( patches.isEmpty() )
					break;
			}
	
			// Go through WidgetRenderContexts and render the patches
	
			for( int i = 0 ; i < (int) renderList.size() ; i++ )
			{
				WidgetRenderContext * p = &renderList[i];
				p->pWidget->_renderPatches( pDevice, p->geo, p->geo, &p->patches );
			}
	
		}
		else
		{
			Rect childGeo;
			Hook * p = _firstHookWithGeo( childGeo );
	
			while(p)
			{
				Rect canvas = childGeo + _canvas.pos();
				if( p->_isVisible() && canvas.intersectsWith( dirtBounds ) )
					p->_widget()->_renderPatches( pDevice, canvas, canvas, &patches );
				p = _nextHookWithGeo( childGeo, p );
			}
	
		}
	}
Example #20
0
void level::renderLevel(character &currentCharacter, level &currentLevel)
{
	float2D tempPos;
	switch(_colorModel)
	{
		//This is the full color mode
		//This is black tiles
		case 1:
			currentCharacter.render();
			_render();
			break;
			//This is feathered lighting model and the
			//point light model
		case 2:
			//check if the player has moved
			tempPos = currentCharacter.getPosition() + float2D().polarRotate(currentCharacter.getViewAngle())*currentCharacter.getSize();
			if(!(_previousCharacterPos == tempPos) || currentCharacter.getViewAngle() != _flashLightAngle)
			{
				_frontSound = 0;
				_leftSound = 0;
				_backSound = 0;
				_rightSound = 0;
				//if the player has moved then set the 
				//previous position to the new position
				_previousCharacterPos = tempPos;
				_flashLightAngle = currentCharacter.getViewAngle();
				//next update the flash light
				_flashLight = new light(_previousCharacterPos, TO_DEGREE(_flashLightAngle) - (135 / 2), 135, 135, 100);
				//_flashLight = new light(_previousCharacterPos, TO_DEGREE(_flashLightAngle), 1, 1, 200);
				_flashLight->buildEmitter(currentLevel, currentCharacter);
				cout << endl;
				cout << "Front sound: " << _frontSound << endl;
				cout << "Back sound: " << _backSound << endl;
				cout << "Left sound: " << _leftSound << endl;
				cout << "Right sound: " << _rightSound << endl;
				ALchangeGain(_frontSound, _leftSound, _backSound, _rightSound);
			}
			currentCharacter.render();
			_render();
			break;
		case 3:
		case 4:
			_render();
			_renderRayTexture();
			currentCharacter.render();
			
			
			
			break;
			//This is the mode you can see the 
			//rays in i.e. the light debug render
		case 5:
			//check if the player has moved
			tempPos = currentCharacter.getPosition() + float2D().polarRotate(currentCharacter.getViewAngle())*currentCharacter.getSize();
			if(!(_previousCharacterPos == tempPos) || currentCharacter.getViewAngle() != _flashLightAngle)
			{
				_frontSound = 0;
				_leftSound = 0;
				_backSound = 0;
				_rightSound = 0;
				//if the player has moved then set the 
				//previous position to the new position
				_previousCharacterPos = tempPos;
				_flashLightAngle = currentCharacter.getViewAngle();
				//next update the flash light
				_flashLight = new light(_previousCharacterPos, TO_DEGREE(_flashLightAngle) - (135/2), 135, 135, 100);
				//_flashLight = new light(_previousCharacterPos, TO_DEGREE(_flashLightAngle), 1, 1, 200);
				_flashLight->buildEmitter(currentLevel, currentCharacter);
				
				cout << "Front sound: " << _frontSound << endl;
				cout << "Back sound: " << _backSound << endl;
				cout << "Left sound: " << _leftSound << endl;
				cout << "Right sound: " << _rightSound << endl;
			}
			currentCharacter.render();
			_flashLight->debugRender();
			_render();
			break;
			//This will be the flash light mode
		case 6:
			break;
			//This is the sound model
		case 7:
			break;
		default:;
	}
}
Example #21
0
void CViewWindow::onIdle()
{
	if (RenderEngineImp::isNull()) 
	{
		return;
	}
	static u32 oldTime = GetTickCount();
	u32 currentTime = GetTickCount();
	float delta = currentTime - oldTime;
	oldTime = currentTime;
	//_camera.lookAt(Vec3::ZERO);
	Vec3 pos = _cameraRelativeShpereCoordination.getPosition();
	_camera.setPosition(pos);
	float s = Zen::Basic::Sin(_cameraRelativeShpereCoordination.mAngleUpFromXZ);
	//进入球的背面
	Vec3 lookTaTarget = _cameraRelativeShpereCoordination.mOrigion;
	if (s < 0)
	{
		_camera.lookAt(lookTaTarget, Vec3::NEGATIVE_UNIT_Y);
	}
	else
	{
		_camera.lookAt(lookTaTarget);
	}
	_camera.update();
	Mat4 m = _camera.getProjectionMatrix() * _camera.getViewMatrix();
	if (_model)
	{
		_model->setMatrix("gWorldViewProj", m);
		Mat4 w = Mat4::IDENTITY;
		_model->setMatrix("gWorld", w);
		_model->setMatrix("gWorldInverseTranspose", w);
		_model->setMatrix("gView", _camera.getViewMatrix());
		_model->setMatrix("gProjection", _camera.getProjectionMatrix());
		//
		{
			Zen::Effect* fx = RenderEngineImp::getInstancePtr()->getRenderEngine()->getEffectManager()->getEffectByFile("shader/aPTSkin.fx");
			if (fx)
			{
				Vec3 l = _light.mPosition.getPosition();
				l.normalise();
				Vec4 p(l.x, l.y, l.z, 0);
				fx->setVector("gLightPosition", &p);
			}
		}
		//
		_model->update(delta);
	}
	Zen::Effect* fx = _material->getEffect();
	if (fx)
	{
		fx->setMatrix("g_mWorldViewProjection", m);
	}

	//
	{
		if (gTerrain.getMaterial())
		{
			Zen::Effect* fx = gTerrain.getMaterial()->getEffect();
			if (fx)
			{
				fx->setMatrix("g_mViewProjection", m);
			}
		}
	}
	//
	{
		if (mSculptor.mMaterial)
		{
			Zen::Effect* fx = mSculptor.mMaterial->getEffect();
			if (fx)
			{
				fx->setMatrix("g_mViewProjection", m);
			}
		}
	}
	_calcFPS();
	//
	RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->clear(0, NULL, Zen::eClearFlags_Target | Zen::eClearFlags_ZBuffer, Zen::Color::Black, 1.0f, 0L);
	RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->beginScene();
	//
	_render();
	//
	RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->endScene();
	RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->present(NULL, NULL, NULL);
}
Example #22
0
void	SfBall::run() {
    while (_window->isOpen()) {
        _update();
        _render();
    }
}
Example #23
0
	void Widget::_renderPatches( GfxDevice * pDevice, const Rect& _canvas, const Rect& _window, const Patches& patches )
	{
		pDevice->setClipList(patches.size(), patches.begin());
		_render( pDevice, _canvas, _window );
	}
void MarkerRenderer::render()
{
    const MarkersMap& map = _markers->getMarkers();
    for( MarkersMap::const_iterator it = map.begin(); it != map.end(); ++it )
        _render( it->second );
}