Ejemplo n.º 1
0
void ManageFade()
{
	arxtime.update();
	
	// TODO can this really become negative ?
	long tim = long(arxtime.now_ul() - FADESTART);
	if(tim <= 0)
		return;

	float Visibility = tim / (float)FADEDURATION;

	if(FADEDIR > 0)
		Visibility = 1.f - Visibility;

	if(Visibility > 1.f)
		Visibility = 1.f;

	if(Visibility < 0.f) {
		FADEDIR = 0;
		return;
	}

	LAST_FADEVALUE=Visibility;
	GRenderer->SetBlendFunc(BlendSrcAlpha, BlendInvSrcAlpha);
	GRenderer->SetRenderState(Renderer::DepthWrite, false);
	GRenderer->SetRenderState(Renderer::AlphaBlending, true);
	
	Color color = Color4f(FADECOLOR, Visibility).to<u8>();
	EERIEDrawBitmap(Rectf(g_size), 0.0001f, NULL, color);

	GRenderer->SetRenderState(Renderer::AlphaBlending, false);
	GRenderer->SetRenderState(Renderer::DepthWrite, true);
}
Ejemplo n.º 2
0
void GL2HudRenderer::render() {
	if (client->getStateId() != Client::StateId::PLAYING)
		return;

	const Character &character = client->getLocalCharacter();
	if (!character.isValid())
		return;

	GL(Enable(GL_TEXTURE_2D));
	vec2f texs[4];
	GL2TextureManager::Entry tex_entry = renderer->getTextureManager()->get(client->getLocalCharacter().getBlock());
	GL2TextureManager::getTextureCoords(tex_entry.index, tex_entry.type, texs);
	GL(BindTexture(GL_TEXTURE_2D, tex_entry.tex));

	GL(Color4f(1.0f, 1.0f, 1.0f, 1.0f));

	GL(PushMatrix());
	float d = (client->getGraphics()->getWidth() < client->getGraphics()->getHeight() ? client->getGraphics()->getWidth() : client->getGraphics()->getHeight()) * 0.05f;
	GL(Translatef(-client->getGraphics()->getDrawWidth() * 0.48f, -client->getGraphics()->getDrawHeight() * 0.48f, 0));
	glBegin(GL_QUADS);
		glTexCoord2f(texs[0][0], texs[0][1]); glVertex2f(0, 0);
		glTexCoord2f(texs[1][0], texs[1][1]); glVertex2f(d, 0);
		glTexCoord2f(texs[2][0], texs[2][1]); glVertex2f(d, d);
		glTexCoord2f(texs[3][0], texs[3][1]); glVertex2f(0, d);
	glEnd();
	LOG_OPENGL_ERROR;

	GL(PopMatrix());
}
    virtual void mousePressed(const MouseEventUnrecPtr e)
    {
        if(dynamic_cast<WindowEventProducer*>(e->getSource())->getKeyModifiers() & KeyEvent::KEY_MODIFIER_COMMAND)
        {
            mgr->mouseButtonPress(e->getButton(), e->getLocation().x(), e->getLocation().y());
        }
        else
        {
            Line TheRay;
            if(e->getButton() == MouseEvent::BUTTON1)
            {

                mgr->getCamera()->calcViewRay(TheRay,e->getLocation().x(),e->getLocation().y(),*(mgr->getWindow()->getPort(0)));
                std::cout<<"Velocity "<<TheRay.getDirection()<<std::endl;
            }
            RocketParticleSystem->addParticle(TheRay.getPosition(),
                                              Vec3f(0.0,1.0f,0.0f),
                                              Color4f(1.0,0.0,0.0,1.0), 
                                              Vec3f(1.0,1.0,1.0), 
                                              10, 
                                              Vec3f(TheRay.getDirection()*50), //Velocity
                                              Vec3f(0.0f,0.0f,0.0f)
                                             );
        }
    }
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
void Particle::Update(long _lTime)
{
	ulTime += _lTime;
	iTexTime += _lTime;
	fTimeSec = _lTime * ( 1.0f / 1000 );

	if (ulTime < ulTTL)
	{
		float ft = fOneOnTTL * ulTime;

		// backup old pos
		p3OldPos.x = p3Pos.x;
		p3OldPos.y = p3Pos.y;
		p3OldPos.z = p3Pos.z;

		// update new pos
		p3Pos.x += p3Velocity.x * fTimeSec; 
		p3Pos.y += p3Velocity.y * fTimeSec; 
		p3Pos.z += p3Velocity.z * fTimeSec;

		fSize = fSizeStart + (fSizeEnd - fSizeStart) * ft;
		fColor[0] = fColorStart[0] + (fColorEnd[0] - fColorStart[0]) * ft;
		fColor[1] = fColorStart[1] + (fColorEnd[1] - fColorStart[1]) * ft;
		fColor[2] = fColorStart[2] + (fColorEnd[2] - fColorStart[2]) * ft;
		fColor[3] = fColorStart[3] + (fColorEnd[3] - fColorStart[3]) * ft;

		ulColor = Color4f(fColor[0], fColor[1], fColor[2], fColor[3]).to<u8>();
	}
}
Ejemplo n.º 5
0
bool SampleBase::onInit()
{
	m_frameCount = 0;
	m_fps = 0.0f;

	addChannel( MSG_DEV );

	if ( !WinFrame::create( "Sample Test" , g_ScreenWidth , g_ScreenHeight ,
		   SysMsgHandler::MsgProc , false ) )
		return false;

	if ( !CFly::initSystem() )
		return  false;
	mWorld =  WorldManager::getInstance().createWorld( getHWnd() , g_ScreenWidth , g_ScreenHeight , 32 , false );

	CFly::PluginManager::getInstance().registerLinker( "CW3" , new Cw3FileLinker );

	if ( !mWorld )
		return false;

	mWorld->setDir( DIR_OBJECT , SAMPLE_DATA_DIR );
	mWorld->setDir( DIR_ACTOR  , SAMPLE_DATA_DIR"/NPC" );
	mWorld->setDir( DIR_TEXTURE, SAMPLE_DATA_DIR );
	mWorld->setDir( DIR_SHADER , SAMPLE_DATA_DIR"/Shader" );
	mMainViewport = mWorld->createViewport( 0 , 0 , g_ScreenWidth , g_ScreenHeight );
	mMainScene    = mWorld->createScene( 1 );
	mMainScene->setAmbientLight( Color4f(1,1,1) );

	mMainCamera = mMainScene->createCamera();
	mMainCamera->setAspect( float(  g_ScreenWidth ) / g_ScreenHeight );
	mMainCamera->setNear(5.0f);
	mMainCamera->setFar(100000.0f);

	return onSetupSample();
}
Ejemplo n.º 6
0
Panzerfaust::Panzerfaust()
{
	
	m_renderer = Renderer();
	//debugUnitTest(m_elements);
	m_internalTime = 0.f;
	m_isQuitting = m_renderer.m_fatalError;
	m_console.m_log = ConsoleLog();
	//m_world = World();
	m_worldCamera = Camera();

	m_displayConsole = false;

	//HACK test values
	m_console.m_log.appendLine("This is a test of the emergency broadcast system");
	m_console.m_log.appendLine("Do not be alarmed or concerned");
	m_console.m_log.appendLine("This is only a test");

	UnitTestXMLParser(".\\Data\\UnitTest.xml");
	unitTestEventSystem();
	//g_serverConnection = new Connection("129.119.246.221", "5000");
	g_serverConnection = new Connection("127.0.0.1", "8080");
	g_localUser = User();
	g_localUser.m_unit = Entity();
	g_localUser.m_unit.m_color = Color4f(0.2f, 1.0f, 0.2f, 1.f);
	g_localUser.m_userType = USER_LOCAL;
	g_localUser.m_unit.m_position = Vector2f(0,0);
	CommandParser::RegisterCommand("connect", ChangeServer);
	CommandParser::RegisterCommand("color", ChangeColor);
}
Ejemplo n.º 7
0
	bool onSetupSample()
	{
		createCoorditeAxis( 120 );

		mMainCamera->setLookAt( Vector3( 0,0,150 ) , Vector3(0,0,0), Vector3(0,1,0) );

		Vertex vtx[4] =
		{
			{ 0 , 0 , 0 , 0 , 0 , 1 } ,
			{ 100 , 0 , 0 , 1 , 0 , 0 } ,
			{ 100 , 100 , 0 , 1 , 1 , 1 } ,
			{ 0 , 100 , 0 , 0 , 1 , 0 } ,
		};

		int idx[6] = 
		{
			0 , 1 , 2 ,
			0 , 2 , 3 ,
		};

		Material* mat = mWorld->createMaterial(  0 , 0 , 0 , 1 , Color4f( 1 , 1 , 1 , 1 ) );
		ShaderEffect* shader = mat->addShaderEffect( "CoordTest" ,"CoordTest" );
		shader->addParam( SP_WVP   , "mWVP" );

		mat->setLightingColor( CFLC_EMISSIVE , CFMC_VERTEX_C1 );
		Object* obj = mMainScene->createObject();
		obj->createIndexedTriangle( mat , CFVT_XYZ_CF1 , (float*)vtx , 4 , idx , 2 );
		return true; 
	}
void TexturedQuadUIDrawObject::draw(const GraphicsWeakPtr Graphics, Real32 Opacity) const
{
    //TODO: add Color Field to TexturedQuadUIDrawObject
	Graphics->drawQuad(getPoint1(),getPoint2(),getPoint3(),getPoint4(),
                       getTexCoord1(), getTexCoord2(), getTexCoord3(), getTexCoord4(),
                       Color4f(1.0f,1.0f,1.0f,1.0f), getTexture(),
                       getOpacity()*Opacity);
}
Ejemplo n.º 9
0
void ModelBrowserTool::Render()
{
    Renderer* renderer = GraphicSubsystem::Instance()->GetRenderer();
    GD_ASSERT(renderer);

    renderer->SetViewport( 0, 0, mModelBrowserWindow->mViewerFrame->width(), mModelBrowserWindow->mViewerFrame->height() );
    renderer->SetClearColor( Color4f( 0.1f, 0.2f, 0.4f, 1.0f) );

    renderer->SetCulling( Renderer::CullBackFace );
    
    // Render.
	renderer->Clear( Renderer::ColorBuffer | Renderer::DepthBuffer );
    
    renderer->SetRenderState( Renderer::DepthTest, true );

    // Camera.
    renderer->SetMatrixMode(Renderer::ProjectionMatrix);
    renderer->LoadIdentity();
    renderer->Perspective(mCamera.GetFovAngle(), 
                          (float)mModelBrowserWindow->mViewerFrame->width() / (float)mModelBrowserWindow->mViewerFrame->height(),
                          mCamera.GetNearView(), mCamera.GetFarView());

    renderer->SetMatrixMode(Renderer::ModelViewMatrix);
    renderer->LoadIdentity();
    renderer->SetView( mCamera.GetPosition(), mObjectCenter - mCamera.GetPosition(), mCamera.GetUp() );

    Light light;
    light.mPosition = mCamera.GetPosition();
    light.mAmbient = Color4f(0.1f,0.1f, 0.1f,1.0f);
    light.mDiffuse = Color4f(0.9f,0.9f, 0.9f,1.0f);
    light.mType = Renderer::LightPoint;
    renderer->SetRenderState( Renderer::Light_i, true, 0 );
    renderer->SetLight( 0, light );   
    renderer->SetRenderState( Renderer::Lighting, true );

    renderer->SetColor(Color4f(1.0f, 1.0f, 1.0f, 1.0f));
    
	// Change the orientation.
    static Float pAngle = 0;
    pAngle += 0.05f;
    mModel->SetOrientation(Quaternionf( Vector3f(0,1,0), pAngle ));

	renderer->Translate(mModel->GetPosition());
	renderer->Rotate(mModel->GetOrientation());
    mModel->Render();
}
Ejemplo n.º 10
0
void Panzerfaust::update(float deltaTime)
{
	bool forwardVelocity = m_IOHandler.m_keyIsDown['W'];
	bool backwardVelocity = m_IOHandler.m_keyIsDown['S'];
	bool leftwardVelocity = m_IOHandler.m_keyIsDown['A'];
	bool rightwardVelocity = m_IOHandler.m_keyIsDown['D'];

	//HACK
	const float SPEED_OF_CAMERA = 50.f;

	g_localUser.m_unit.m_target.x += (rightwardVelocity - leftwardVelocity)*SPEED_OF_CAMERA*deltaTime;
	g_localUser.m_unit.m_target.y += (forwardVelocity - backwardVelocity)*SPEED_OF_CAMERA*deltaTime;
	g_localUser.update(deltaTime);

	GamePacket currentPacket;
	do 
	{
		bool newUser = true;
		currentPacket = g_serverConnection->receivePackets();
		if (currentPacket.ID != 0)
		{
			Color3b packetColor = Color3b();
			packetColor.r = currentPacket.r;
			packetColor.g = currentPacket.g;
			packetColor.b = currentPacket.b;

			for (unsigned int ii = 0; ii < g_users.size(); ii++)
			{
				
				if (Color3b(g_users[ii].m_unit.m_color) == packetColor)
				{
					newUser = false;
					g_users[ii].m_unit.m_target = Vector2f(currentPacket.x, currentPacket.y);
				}
			}
			if (newUser)
			{
				User tempUser = User();
				tempUser.m_unit.m_position = Vector2f(currentPacket.x, currentPacket.y);
				tempUser.m_unit.m_target = Vector2f(currentPacket.x, currentPacket.y);
				tempUser.m_unit.m_color = Color4f(packetColor.r/255.f, packetColor.g/255.f, packetColor.b/255.f, 1.f);
				tempUser.m_userType = USER_REMOTE;
				g_users.push_back(tempUser);
			}
		}
	} while (currentPacket.ID != 0);

	for (unsigned int ii = 0; ii < g_users.size(); ii++)
	{
		g_users[ii].update(deltaTime);
	}

	mouseUpdate();

	m_internalTime += deltaTime;

	//m_world.update(deltaTime);
}
ComponentTransitPtr DefaultTableCellEditor::getTableCellEditorComponent(Table* const table, const boost::any& value, bool isSelected, UInt32 row, UInt32 column)
{
    if(value.empty()){
        return ComponentTransitPtr(NULL);
    }
    TextFieldRefPtr TheTextField = TextField::create();
    std::string tempString;
    try
    {
        tempString = lexical_cast(value);
    }
    catch (boost::bad_lexical_cast &)
    {
        //Could not convert to string
    }
    TheTextField->setText(tempString);
    TheTextField->setPreferredSize(Vec2f(100,30));
    TheTextField->setAlignment(Vec2f(0.5,0.5));
    TheTextField->selectAll();
    TheTextField->setCaretPosition(TheTextField->getText().size());
    ColorLayerRefPtr tempBackground;
    tempBackground = ColorLayer::create();

    TheTextField->setBackground(tempBackground);

    //if(isSelected){
    //	tempBackground->setColor(Color4f(0.4, 0.4, 1.0, 1.0));
    //}
    //else{
    tempBackground->setColor(Color4f(1.0, 1.0, 1.0, 1.0));
    //}

    LineBorderRefPtr tempBorder;

    tempBorder = LineBorder::create();
    tempBorder->setColor(Color4f(0.0, 0.0, 1.0, 1.0));

    TheTextField->setBorder(tempBorder);

    setDefaultStringEditor(TheTextField);
    _EditorActionConnection = getDefaultStringEditor()->connectActionPerformed(boost::bind(&DefaultTableCellEditor::handleEditorAction, this, _1));
    _EditorFocusLostConnection = getDefaultStringEditor()->connectFocusLost(boost::bind(&DefaultTableCellEditor::handleEditorFocusLost, this, _1));
    _EditorKeyPressedConnection = getDefaultStringEditor()->connectKeyPressed(boost::bind(&DefaultTableCellEditor::handleEditorKeyPressed, this, _1));
    return ComponentTransitPtr(getDefaultStringEditor());
}
Ejemplo n.º 12
0
FogChunkBase::FogChunkBase(void) :
    Inherited(),
    _sfMode                   (GLenum(GL_EXP)),
    _sfColor                  (Color4f(0.f, 0.f, 0.f, 0.f)),
    _sfStart                  (Real32(0.f)),
    _sfEnd                    (Real32(1.f)),
    _sfDensity                (Real32(1.f))
{
}
Ejemplo n.º 13
0
MaterialUnrecPtr Graphics3DExtrude::createDefaultMaterial(void)
{
	MaterialChunkUnrecPtr TheMaterialChunk = MaterialChunk::create();

		TheMaterialChunk->setAmbient(Color4f(0.4,0.4,0.4,1.0));
		TheMaterialChunk->setDiffuse(Color4f(0.8,0.8,0.8,1.0));
		TheMaterialChunk->setSpecular(Color4f(0.85,0.85,0.85,1.0));
		TheMaterialChunk->setEmission(Color4f(0.0,0.0,0.0,1.0));
		TheMaterialChunk->setShininess(50.0);
		TheMaterialChunk->setLit(true);
		TheMaterialChunk->setColorMaterial(true);
	
	ChunkMaterialUnrecPtr TheMaterial = ChunkMaterial::create();

    TheMaterial->addChunk(TheMaterialChunk);

	return TheMaterial;
}
LineUIDrawObjectBase::LineUIDrawObjectBase(void) :
    Inherited(),
    _sfTopLeft                (Pnt2f(0,0)),
    _sfBottomRight            (Pnt2f(0,0)),
    _sfWidth                  (Real32(1)),
    _sfColor                  (Color4f(1.0,1.0,1.0,1.0)),
    _sfOpacity                (Real32(1.0))
{
}
Ejemplo n.º 15
0
LabelBase::LabelBase(void) :
    Inherited(),
    _sfPosition               (Pnt3f(0,0,0)),
    _sfPixelOffset            (Vec2f(0,0)),
    _sfOrientation            (Real32(0.0)),
    _sfHorizontalAlign        (UInt8(1)),
    _sfVerticalAlign          (UInt8(1)),
    _sfMargin                 (Vec2f(0,0)),
    _sfColor                  (Color4f(1,1,1,1)),
    _sfBgColor                (Color4f(0,0,0,0)),
    _sfShadowColor            (Color4f(0,0,0,1)),
    _sfShadowOffset           (Vec2f(1,-1)),
    _sfBorderColor            (Color4f(0,0,0,0)),
    _sfBorderOffset           (Vec2f(4,4)),
    _sfImportance             (Real32(1)),
    _sfTextureObject          (NULL)
{
}
Ejemplo n.º 16
0
void GameWorld::addPxMoveBall(int num)
{
	Color4f color(50 / 255.0, 225 / 255.0, 50 / 255.0);
	for (int i = 0;i < num;i++) {
		PxMoveBall* newball = new PxMoveBall(color, 5.0, 100.0f);
		Material mtl;
		PerlinImage perlinGreen = createPerlinGreenImage(40, 40, 6, 1.8);
		PerlinTexture(perlinGreen, mtl.kd_texid);
		mtl.ka = Color4f(1, 1, 1, 1);
		mtl.kd = Color4f(1, 1, 1, 1);
		newball->mtl = mtl;
		newball->createPxBall(*gPhysics, PxTransform(PxVec3(rand() % 500 - 250, 100, rand() % 700 - 350)), *gMaterial);
		newball->pxActor->setAngularDamping(0.5);
		gScene->addActor(*(newball->pxActor));
		pxMoveBalls.push_back(newball);
		perlinGreen.clear();
	}
}
Ejemplo n.º 17
0
Archivo: GL.cpp Proyecto: vvuk/mc-nvpr
void
GL::SetColor(const Color& aColor)
{
  MOZ_ASSERT(IsCurrent());

  if (!memcmp(&mColor, &aColor, sizeof(Color))) {
    return;
  }

  if (aColor.a == 1) {
    Color4f(aColor.r, aColor.g, aColor.b, 1);
  } else {
    const float a = aColor.a;
    Color4f(a * aColor.r, a * aColor.g, a * aColor.b, a);
  }

  mColor = aColor;
}
Ejemplo n.º 18
0
void Entity::RenderSelected() const
{
    Renderer* renderer = GraphicSubsystem::Instance()->GetRenderer();
    GD_ASSERT(renderer);

	// Render the bounding box.
	renderer->SetRenderState( Renderer::Lighting, false );
    renderer->SetPolygonMode( Renderer::BothFace, Renderer::FillWireframe );
    renderer->SetCulling( Renderer::NoCulling );
    
    renderer->SetColor(Color4f(1.0f, 0.0f, 0.0f, 1.0f));
    renderer->DrawBox( mBoundingBox.Min(), mBoundingBox.Max() );
    renderer->SetColor(Color4f(1.0f, 1.0f, 1.0f, 1.0f));

    renderer->SetRenderState( Renderer::Lighting, true );
    renderer->SetPolygonMode( Renderer::BothFace, Renderer::FillSolid );
    renderer->SetCulling( Renderer::CullBackFace );
}
Ejemplo n.º 19
0
            void recursive_render(const aiScene *scene, const aiNode* nd)
            {
                int i;
                unsigned int n = 0, t;
                aiMatrix4x4 m = nd->mTransformation;

                // update transform
                aiTransposeMatrix4(&m);
                glPushMatrix();
                glMultMatrixf((float*)&m);

                // draw all meshes assigned to this node
                for (; n < nd->mNumMeshes; ++n) {
                    const aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];

                    apply_material(scene->mMaterials[mesh->mMaterialIndex]);
                    if(mesh->mNormals == NULL)
                        glDisable(GL_LIGHTING);
                    else
                        glEnable(GL_LIGHTING);
                    if(mesh->mColors[0] == NULL)
                        glDisable(GL_COLOR_MATERIAL);
                    else
                        glEnable(GL_COLOR_MATERIAL);

                    for (t = 0; t < mesh->mNumFaces; ++t)
                    {
                        const aiFace* face = &mesh->mFaces[t];
                        GLenum face_mode;

                        switch(face->mNumIndices)
                        {
                        case 1: face_mode = GL_POINTS; break;
                        case 2: face_mode = GL_LINES; break;
                        case 3: face_mode = GL_TRIANGLES; break;
                        default: face_mode = GL_POLYGON; break;
                        }

                        glBegin(face_mode);
                        for(i = 0; i < (int)face->mNumIndices; i++)
                        {
                            int index = face->mIndices[i];
                            if(mesh->mColors[0] != NULL)
                                Color4f(&mesh->mColors[0][index]);
                            if(mesh->mNormals != NULL)
                                glNormal3fv(&mesh->mNormals[index].x);
                            glVertex3fv(&mesh->mVertices[index].x);
                        }
                        glEnd();
                    }
                }
                // draw all children
                for (n = 0; n < nd->mNumChildren; ++n)
                    recursive_render(scene, nd->mChildren[n]);
                glPopMatrix();
            }
MaterialLayerBase::MaterialLayerBase(void) :
    Inherited(),
    _sfMaterial               (NULL),
    _sfColor                  (Color4f(1.0f,1.0f,1.0f,1.0f)),
    _sfScale                  (UInt32(MaterialLayer::SCALE_STRETCH)),
    _sfScaleAbsoluteSize      (Vec2s(1,1)),
    _sfVerticalAlignment      (Real32(0.5)),
    _sfHorizontalAlignment    (Real32(0.5))
{
}
Ejemplo n.º 21
0
ParticleSystem::ParticleSystem()
	: m_nextPosition(0.f)
	, iParticleNbAlive(0)
	, iNbTex(0)
	, iTexTime(500)
	, bTexLoop(true)
	, eMat(1.f)
{
	
	for(size_t i = 0; i < 20; i++) {
		tex_tab[i] = NULL;
	}
	
	m_parameters.m_nbMax = 50;
	m_parameters.m_rotation = 0;
	m_parameters.m_freq = -1;
	m_parameters.m_spawnFlags = 0;
	m_parameters.m_direction = Vec3f(0.f, -1.f, 0.f);
	m_parameters.m_startSegment.m_size = 1;
	m_parameters.m_endSegment.m_size = 1;
	m_parameters.m_startSegment.m_color = Color4f(0.1f, 0.1f, 0.1f, 0.1f);
	m_parameters.m_endSegment.m_color = Color4f(0.1f, 0.1f, 0.1f, 0.1f);
	m_parameters.m_speed = 10;
	m_parameters.m_life = 1000;
	m_parameters.m_pos = Vec3f(0.f);
	m_parameters.m_flash = 0;
	m_parameters.m_rotation = 0;
	m_parameters.m_rotationRandomDirection = false;
	m_parameters.m_rotationRandomStart = false;
	m_parameters.m_gravity = Vec3f(0.f);
	m_parameters.m_lifeRandom = 1000;
	m_parameters.m_angle = 0;
	m_parameters.m_speedRandom = 10;
	m_parameters.m_startSegment.m_sizeRandom = 1;
	m_parameters.m_startSegment.m_colorRandom = Color4f(0.1f, 0.1f, 0.1f, 0.1f);
	m_parameters.m_endSegment.m_sizeRandom = 1;
	m_parameters.m_endSegment.m_colorRandom = Color4f(0.1f, 0.1f, 0.1f, 0.1f);
	m_parameters.m_blendMode = RenderMaterial::Additive;
	
	GenerateMatrixUsingVector(eMat, Vec3f(0.f, 1.f, 0.f), 0);
	
}
Ejemplo n.º 22
0
SimpleScreenDoc::SimpleScreenDoc(SimpleSceneManager*  SceneManager,
                                 WindowEventProducer* MainWindow)
{
    _DocForeground = makeDocForeground();
    _DocForeground->setBgColor(Color4f(0.0f,0.0f,0.0f,0.8f));
    _DocForeground->setBorderColor(Color4f(1.0f,1.0f,1.0f,1.0f));
    _DocForeground->setTextMargin(Vec2f(5.0f,5.0f));
    _DocForeground->setHorizontalAlign(SimpleTextForeground::Left);
    _DocForeground->setVerticalAlign(SimpleTextForeground::Top);
    _DocForeground->setActive(false);

    _DocShowForeground = makeDocShowForeground();

    ViewportRefPtr TutorialViewport = SceneManager->getWindow()->getPort(0);
    TutorialViewport->addForeground(_DocForeground);
    TutorialViewport->addForeground(_DocShowForeground);

    MainWindow->connectKeyTyped(boost::bind(&SimpleScreenDoc::keyTyped,
                                            this,
                                            _1));
    
    //Color Keyframe Sequence
    KeyframeColorSequenceRecPtr ColorKeyframes = KeyframeColorSequenceColor4f::create();
    ColorKeyframes->addKeyframe(Color4f(1.0f,1.0f,1.0f,1.0f),0.0f);
    ColorKeyframes->addKeyframe(Color4f(1.0f,1.0f,1.0f,1.0f),5.0f);
    ColorKeyframes->addKeyframe(Color4f(1.0f,1.0f,1.0f,0.0f),7.0f);
    
    //Animator
    KeyframeAnimatorRecPtr TheAnimator = KeyframeAnimator::create();
    TheAnimator->setKeyframeSequence(ColorKeyframes);
    
    //Animation
    _ShowDocFadeOutAnimation = FieldAnimation::create();
    _ShowDocFadeOutAnimation->setAnimator(TheAnimator);
    _ShowDocFadeOutAnimation->setInterpolationType(Animator::LINEAR_INTERPOLATION);
    _ShowDocFadeOutAnimation->setCycling(1);
    _ShowDocFadeOutAnimation->setAnimatedField(_DocShowForeground,
                                               SimpleTextForeground::ColorFieldId);

    _ShowDocFadeOutAnimation->attachUpdateProducer(MainWindow);
    _ShowDocFadeOutAnimation->start();
}
Ejemplo n.º 23
0
Color4f ColorChooser::getColor(void) const
{
	if(_SelectionModel != NULL)
	{
		return _SelectionModel->getSelectedColor();
	}
	else
	{
		return Color4f();
	}
}
Ejemplo n.º 24
0
void GUIController::draw_gui (const std::shared_ptr<CameraObject> &camera, const DTfloat lag)
{
#ifdef DT3_EDITOR
    if (camera->is_picking())
        return;
#endif
    
    System::renderer()->clear_viewport(false,false,true);

    draw_gui_recursive(this, _gui_camera, Color4f(1.0F,1.0F,1.0F,1.0F), 0);    // GUIController goes first
}
Ejemplo n.º 25
0
TextureBackgroundBase::TextureBackgroundBase(void) :
    Inherited(),
    _sfColor                  (Color4f(1.f, 1.f, 1.f, 0.f)),
    _sfTexture                (NULL),
    _mfTexCoords              (),
    _sfRadialDistortion       (Real32(0)),
    _sfCenterOfDistortion     (Vec2f(0.5, 0.5)),
    _sfHor                    (UInt16(2)),
    _sfVert                   (UInt16(2))
{
}
Color4f AbstractColorChooserPanel::getColorFromModel(void) const
{
    if(getParentChooser() != NULL && getParentChooser()->getSelectionModel() != NULL)
    {
        return getParentChooser()->getSelectionModel()->getSelectedColor();
    }
    else
    {
        return Color4f();
    }
}
Ejemplo n.º 27
0
RendererOGL::RendererOGL(WindowSDL *window, const Graphics::Settings &vs)
: Renderer(window, window->GetWidth(), window->GetHeight())
, m_numLights(0)
, m_numDirLights(0)
//the range is very large due to a "logarithmic z-buffer" trick used
//http://outerra.blogspot.com/2009/08/logarithmic-z-buffer.html
//http://www.gamedev.net/blog/73/entry-2006307-tip-of-the-day-logarithmic-zbuffer-artifacts-fix/
, m_minZNear(0.0001f)
, m_maxZFar(10000000.0f)
, m_useCompressedTextures(false)
, m_invLogZfarPlus1(0.f)
, m_activeRenderTarget(0)
, m_activeRenderState(nullptr)
, m_matrixMode(MatrixMode::MODELVIEW)
{
	if (!initted) {
		initted = true;

		if (!ogl_LoadFunctions())
			Error("glLoadGen failed to load functions.\n");

		if (ogl_ext_EXT_texture_compression_s3tc == ogl_LOAD_FAILED)
			Error(
				"OpenGL extension GL_EXT_texture_compression_s3tc not supported.\n"
				"Pioneer can not run on your graphics card as it does not support compressed (DXTn/S3TC) format textures."
			);
	}

	m_viewportStack.push(Viewport());

	const bool useDXTnTextures = vs.useTextureCompression;
	m_useCompressedTextures = useDXTnTextures;

	//XXX bunch of fixed function states here!
	glCullFace(GL_BACK);
	glFrontFace(GL_CCW);
	glEnable(GL_CULL_FACE);
	glEnable(GL_DEPTH_TEST);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
	glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);

	SetMatrixMode(MatrixMode::MODELVIEW);

	m_modelViewStack.push(matrix4x4f::Identity());
	m_projectionStack.push(matrix4x4f::Identity());

	SetClearColor(Color4f(0.f, 0.f, 0.f, 0.f));
	SetViewport(0, 0, m_width, m_height);

	if (vs.enableDebugMessages)
		GLDebug::Enable();
}
Ejemplo n.º 28
0
ChunkMaterialPtr PhongMaterial::createChunkMaterial(void)
{
    _arbFragmentProgram = Window::registerExtension("GL_ARB_fragment_program");

    ChunkMaterialPtr cmat = ChunkMaterial::create();

    MaterialChunkPtr matc = MaterialChunk::create();
    beginEditCP(matc);
    matc->setAmbient(Color4f(0.1, 0.1, 0.2, 1.0));
    matc->setDiffuse(Color4f(0.2, 0.2, 0.8, 1.0));
    matc->setSpecular(Color4f(0.8, 0.8, 0.8, 1.0));
    matc->setShininess(100);
    endEditCP(matc);

    beginEditCP(cmat, ChunksFieldMask);
    cmat->addChunk(matc);
    endEditCP(cmat, ChunksFieldMask);

    // phong shading without a fragment shader looks quite black ;-)
    // all cards with a fragment shader should also have a vertex shader.
    if(Window::hasCommonExtension(_arbFragmentProgram))
    {
        VertexProgramChunkPtr vpc = VertexProgramChunk::create();
        beginEditCP(vpc);
        vpc->setProgram(_phong_vp_prg);
        endEditCP(vpc);

        FragmentProgramChunkPtr fpc = FragmentProgramChunk::create();
        std::string phong_fp_prg = _phong_fp_begin_prg + _phong_fp_end_prg;
        beginEditCP(fpc);
        fpc->setProgram(phong_fp_prg);
        endEditCP(fpc);

        beginEditCP(cmat, ChunksFieldMask);
        cmat->addChunk(vpc);
        cmat->addChunk(fpc);
        endEditCP(cmat, ChunksFieldMask);
    }
    return cmat;
}
Ejemplo n.º 29
0
ComponentTransitPtr LuaDebuggerInterface::generateSplitOptionListComponent(List* const Parent,
                                                     const boost::any& Value,
                                                     UInt32 Index,
                                                     bool IsSelected,
                                                     bool HasFocus)
{
    ButtonRecPtr TheComponent = Button::create();
    TheComponent->setBackgrounds(NULL);
    TheComponent->setAlignment(Vec2f(0.0f,0.5f));

    std::string ValueString;
    try
    {
        ValueString = boost::any_cast<std::string>(Value);

        BoostPath IconPath;
        if(ValueString.compare("Horizontal") == 0)
        {
            IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-left-right.png"));
        }
        else if(ValueString.compare("Vertical") == 0)
        {
            IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-top-bottom.png"));
        }
        else
        {
            IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-none.png"));
        }

        TheComponent->setImages(IconPath.string());
    }
    catch (boost::bad_lexical_cast &)
    {
        //Could not convert to string
    }

    TheComponent->setText(ValueString);

    if(IsSelected)
    {
        LineBorderRecPtr LabelBorder = LineBorder::create();
        LabelBorder->setWidth(1.0f);
        LabelBorder->setColor(Color4f(0.0f,0.0f,0.0f,1.0f));
        TheComponent->setBorders(LabelBorder);
    }
    else
    {
        TheComponent->setBorders(NULL);
    }

    return ComponentTransitPtr(TheComponent);
}
ArcUIDrawObjectBase::ArcUIDrawObjectBase(void) :
    Inherited(),
    _sfCenter                 (Pnt2f(0,0)),
    _sfWidth                  (Real32(1)),
    _sfHeight                 (Real32(1)),
    _sfStartAngleRad          (Real32(0.0)),
    _sfEndAngleRad            (Real32(6.283185307)),
    _sfSubDivisions           (UInt16(24)),
    _sfColor                  (Color4f(1.0,1.0,1.0,1.0)),
    _sfLineWidth              (Real32(1.0)),
    _sfOpacity                (Real32(1.0))
{
}