View Full Version : [Transition] Taskswitch.tra
morte0815
2006-10-03, 20:36
This one is inspired by the Vista-Taskswitch (i dont know how the topmost window gets to the back, so i created my own way)
// Taskswitch.tra
// Author - morte0815
float time;
Texture background;
void Init()
{
time = 0;
background.LoadTexture("Plasma_edge.jpg");
}
void DrawFrame()
{
gfxSetTexture(background);
gfxTexRect(-1.1f, 1.1f, 1.1f, -1.1f);
}
void TexRect(float top, float bottom, float left, float right,
float ttop, float tbottom, float tleft, float tright)
{
gfxBegin(PRIM_QUADLIST);
gfxTexCoord(tleft,ttop);
gfxVertex(left,top,0);
gfxTexCoord(tright,ttop);
gfxVertex(right,top,0);
gfxTexCoord(tright,tbottom);
gfxVertex(right,bottom,0);
gfxTexCoord(tleft,tbottom);
gfxVertex(left,bottom,0);
gfxEnd();
}
void Render()
{
gfxSetAspect(0);
time += TIMEPASS;
// gfxSetBlendMode(BLEND_ADD);
// float angle = time - 1.5f;
// if (angle < 0){ angle = -angle;}
// angle = 1.5f - angle;
// gfxRotate(Pow(360,angle*2),0,0,1);
if (time < 1.0f){
gfxTranslate(0, 0, 2.414+time*2);
gfxRotate(-65*time,0,1,0);
gfxTranslate(0, 0, -time/2.0f);
gfxPushMatrix();
gfxTranslate(0, 0, 1);
DrawFrame();
gfxSetTexture(TEXTURE_NEXTPRESET);
gfxTexRect(-1, 1, 1, -1);
gfxPopMatrix();
DrawFrame();
gfxSetTexture(TEXTURE_CURRPRESET);
gfxTexRect(-1, 1, 1, -1);
}
if (time > 1.0f && time < 2.0f)
{
gfxTranslate(0, 0, 4.414);
gfxRotate(-65,0,1,0);
gfxTranslate(0, 0, -0.5f);
gfxPushMatrix();
gfxTranslate(0, 0, 1-(time-1));
DrawFrame();
gfxSetTexture(TEXTURE_NEXTPRESET);
gfxTexRect(-1, 1, 1, -1);
gfxPopMatrix();
gfxPushMatrix();
gfxTranslate(0,(time-1)*2,0);
gfxSetTexture(background);
TexRect(1.1f,0.0f,-1.1f,1.1f,1.0f,0.5f,0.0f,1.0f);
gfxSetTexture(TEXTURE_CURRPRESET);
TexRect(1,0,-1,1,1.0f,0.5f,0.0f,1.0f);
gfxPopMatrix();
gfxTranslate(0,(1-time)*2,0);
gfxSetTexture(background);
TexRect(0.0f,-1.1f,-1.1f,1.1f,0.5f,0.0f,0.0f,1.0f);
gfxSetTexture(TEXTURE_CURRPRESET);
TexRect(0,-1,-1,1,0.5f,0.0f,0.0f,1.0f);
}
if (time > 2.0f)
{
gfxTranslate(0, 0, 4.414-(time-2)*2);
gfxRotate(-65+(time-2)*65,0,1,0);
gfxTranslate(0, 0, -0.5f);
gfxPushMatrix();
DrawFrame();
gfxSetTexture(TEXTURE_NEXTPRESET);
gfxTexRect(-1, 1, 1, -1);
}
if (time>=3){
FINISHED = true;
}
}
In this one there is still a bug (the textures tear when the splitted window is shifted away), but i dont know why, so i cant fix it. Maybe someone else finds the bug.
Cya
:shocked: Outstanding! :shocked:
I didn't notice any tearing here.
morte0815
2006-10-03, 23:33
:shocked: Outstanding! :shocked:
I didn't notice any tearing here.
THANKS!!
You can see the tearing if you use this version (it stops at the splitting of the current visualization):
// Taskswitch_tearing.tra
// Author - morte0815
float time;
Texture background;
void Init()
{
time = 0;
background.LoadTexture("Plasma_edge.jpg");
}
void DrawFrame()
{
gfxSetTexture(background);
gfxTexRect(-1.1f, 1.1f, 1.1f, -1.1f);
}
void TexRect(float top, float bottom, float left, float right,
float ttop, float tbottom, float tleft, float tright)
{
gfxBegin(PRIM_QUADLIST);
gfxTexCoord(tleft,ttop);
gfxVertex(left,top,0);
gfxTexCoord(tright,ttop);
gfxVertex(right,top,0);
gfxTexCoord(tright,tbottom);
gfxVertex(right,bottom,0);
gfxTexCoord(tleft,tbottom);
gfxVertex(left,bottom,0);
gfxEnd();
}
void Render()
{
gfxSetAspect(0);
time += TIMEPASS;
// gfxSetBlendMode(BLEND_ADD);
// float angle = time - 1.5f;
// if (angle < 0){ angle = -angle;}
// angle = 1.5f - angle;
// gfxRotate(Pow(360,angle*2),0,0,1);
if (time < 1.0f){
gfxTranslate(0, 0, 2.414+time*2);
gfxRotate(-65*time,0,1,0);
gfxTranslate(0, 0, -time/2.0f);
gfxPushMatrix();
gfxTranslate(0, 0, 1);
DrawFrame();
gfxSetTexture(TEXTURE_NEXTPRESET);
gfxTexRect(-1, 1, 1, -1);
gfxPopMatrix();
DrawFrame();
gfxSetTexture(TEXTURE_CURRPRESET);
gfxTexRect(-1, 1, 1, -1);
}
if (time > 1.0f )
{
gfxTranslate(0, 0, 4.414);
gfxRotate(-65,0,1,0);
gfxTranslate(0, 0, -0.5f);
gfxPushMatrix();
gfxTranslate(0, 0, 1);
DrawFrame();
gfxSetTexture(TEXTURE_NEXTPRESET);
gfxTexRect(-1, 1, 1, -1);
gfxPopMatrix();
gfxPushMatrix();
gfxTranslate(0,0,0);
gfxSetTexture(background);
TexRect(1.1f,0.0f,-1.1f,1.1f,1.0f,0.5f,0.0f,1.0f);
gfxSetTexture(TEXTURE_CURRPRESET);
TexRect(1,0,-1,1,1.0f,0.5f,0.0f,1.0f);
gfxPopMatrix();
gfxTranslate(0,0,0);
gfxSetTexture(background);
TexRect(0.0f,-1.1f,-1.1f,1.1f,0.5f,0.0f,0.0f,1.0f);
gfxSetTexture(TEXTURE_CURRPRESET);
TexRect(0,-1,-1,1,0.5f,0.0f,0.0f,1.0f);
}
if (time>=3){
FINISHED = true;
}
}
maybe add some randomness so it does the transition in more than direction ? :)
morte0815
2006-10-04, 02:17
Since i cant edit my posts anymore (ADMIN!!!!!!!! :laugh:) here is a version with some randomnes:
// taskswitch.tra
// Author - morte0815
float time;
Texture background;
float angleA;
float angleB;
float vertical;
void Init()
{
time = 0;
background.LoadTexture("Plasma_edge.jpg");
angleA = Rand() * 180 - 90;
angleB = Rand() * 180 - 90;
vertical = Rand();
}
void DrawFrame()
{
gfxSetTexture(background);
gfxTexRect(-1.1f, 1.1f, 1.1f, -1.1f);
}
void TexRect(float top, float bottom, float left, float right,
float ttop, float tbottom, float tleft, float tright)
{
gfxBegin(PRIM_QUADLIST);
gfxTexCoord(tleft,ttop);
gfxVertex(left,top,0);
gfxTexCoord(tright,ttop);
gfxVertex(right,top,0);
gfxTexCoord(tright,tbottom);
gfxVertex(right,bottom,0);
gfxTexCoord(tleft,tbottom);
gfxVertex(left,bottom,0);
gfxEnd();
}
void Render()
{
gfxSetAspect(0);
time += TIMEPASS;
if (time < 1.0f){
gfxTranslate(0, 0, 2.414+time*2);
gfxRotate(angleA*time,0,1,0);
gfxRotate(angleB*time,1,0,0);
gfxTranslate(0, 0, -time/2.0f);
gfxPushMatrix();
gfxTranslate(0, 0, 1);
DrawFrame();
gfxSetTexture(TEXTURE_NEXTPRESET);
gfxTexRect(-1, 1, 1, -1);
gfxPopMatrix();
DrawFrame();
gfxSetTexture(TEXTURE_CURRPRESET);
gfxTexRect(-1, 1, 1, -1);
}
if (time > 1.0f && time < 2.0f)
{
gfxTranslate(0, 0, 4.414);
gfxRotate(angleA,0,1,0);
gfxRotate(angleB,1,0,0);
gfxTranslate(0, 0, -0.5f);
gfxPushMatrix();
gfxTranslate(0, 0, 1-(time-1));
DrawFrame();
gfxSetTexture(TEXTURE_NEXTPRESET);
gfxTexRect(-1, 1, 1, -1);
gfxPopMatrix();
gfxPushMatrix();
if (vertical >0.5f){
gfxTranslate(0,(time-1)*2,0);
}
else{
gfxTranslate((time-1)*2,0,0);
}
gfxSetTexture(background);
TexRect(1.1f,0.0f,-1.1f,1.1f,0.0f,0.5f,0.0f,1.0f);
gfxSetTexture(TEXTURE_CURRPRESET);
TexRect(1,0,-1,1,0.0f,0.5f,0.0f,1.0f);
gfxPopMatrix();
if (vertical>0.5f){
gfxTranslate(0,(1-time)*2,0);
}
else{
gfxTranslate((1-time)*2,0,0);
}
gfxSetTexture(background);
TexRect(0.0f,-1.1f,-1.1f,1.1f,0.5f,1.0f,0.0f,1.0f);
gfxSetTexture(TEXTURE_CURRPRESET);
TexRect(0,-1,-1,1,0.5f,1.0f,0.0f,1.0f);
}
if (time > 2.0f)
{
gfxTranslate(0, 0, 4.414-(time-2)*2);
gfxRotate(angleA+(time-2)*-angleA,0,1,0);
gfxRotate(angleB+(time-2)*-angleB,1,0,0);
gfxTranslate(0, 0, -0.5f);
gfxPushMatrix();
if (vertical>0.5f){
gfxTranslate(0,(time-1)*2,0);
}
else{
gfxTranslate((time-1)*2,0,0);
}
gfxSetTexture(background);
TexRect(1.1f,0.0f,-1.1f,1.1f,0.0f,0.5f,0.0f,1.0f);
gfxSetTexture(TEXTURE_CURRPRESET);
TexRect(1,0,-1,1,0.0f,0.5f,0.0f,1.0f);
gfxPopMatrix();
gfxPushMatrix();
if (vertical>0.5f){
gfxTranslate(0,(1-time)*2,0);
}
else{
gfxTranslate((1-time)*2,0,0);
}
gfxSetTexture(background);
TexRect(0.0f,-1.1f,-1.1f,1.1f,0.5f,1.0f,0.0f,1.0f);
gfxSetTexture(TEXTURE_CURRPRESET);
TexRect(0,-1,-1,1,0.5f,1.0f,0.0f,1.0f);
gfxPopMatrix();
DrawFrame();
gfxSetTexture(TEXTURE_NEXTPRESET);
gfxTexRect(-1, 1, 1, -1);
}
if (time>=3){
FINISHED = true;
}
}
When it splits the current preset the textures coords are wrong and it draws it upside down. I am not sure if this is the tearing you are talking about or not. Anyway, the fixed version is below. I have also removed a few gfxTranslate functions as it was jumping at the end due to not being at the correct z position. You will probably have a better idea how to fix that than me.
// Taskswitch.tra
// Author - morte0815
float time;
Texture background;
void Init()
{
time = 0;
background.LoadTexture("Plasma_edge.jpg");
}
void DrawFrame()
{
gfxSetTexture(background);
gfxTexRect(-1.1f, 1.1f, 1.1f, -1.1f);
}
void TexRect(float top, float bottom, float left, float right,
float ttop, float tbottom, float tleft, float tright)
{
gfxBegin(PRIM_QUADLIST);
gfxTexCoord(tleft,ttop);
gfxVertex(left,top,0);
gfxTexCoord(tright,ttop);
gfxVertex(right,top,0);
gfxTexCoord(tright,tbottom);
gfxVertex(right,bottom,0);
gfxTexCoord(tleft,tbottom);
gfxVertex(left,bottom,0);
gfxEnd();
}
void Render()
{
gfxSetAspect(0);
time += TIMEPASS;
// gfxSetBlendMode(BLEND_ADD);
// float angle = time - 1.5f;
// if (angle < 0){ angle = -angle;}
// angle = 1.5f - angle;
// gfxRotate(Pow(360,angle*2),0,0,1);
if (time < 1.0f){
gfxTranslate(0, 0, 2.414+time*2);
gfxRotate(-65*time,0,1,0);
// gfxTranslate(0, 0, -time/2.0f);
gfxPushMatrix();
gfxTranslate(0, 0, 1);
DrawFrame();
gfxSetTexture(TEXTURE_NEXTPRESET);
gfxTexRect(-1, 1, 1, -1);
gfxPopMatrix();
DrawFrame();
gfxSetTexture(TEXTURE_CURRPRESET);
gfxTexRect(-1, 1, 1, -1);
}
if (time > 1.0f && time < 2.0f)
{
gfxTranslate(0, 0, 4.414);
gfxRotate(-65,0,1,0);
// gfxTranslate(0, 0, -0.5f);
gfxPushMatrix();
gfxTranslate(0, 0, 1-(time-1));
DrawFrame();
gfxSetTexture(TEXTURE_NEXTPRESET);
gfxTexRect(-1, 1, 1, -1);
gfxPopMatrix();
gfxPushMatrix();
gfxTranslate(0,(time-1)*2,0);
gfxSetTexture(background);
TexRect(1.1f,0.0f,-1.1f,1.1f,1.0f,0.5f,0.0f,1.0f);
gfxSetTexture(TEXTURE_CURRPRESET);
TexRect(1,0,-1,1,0.0f,0.5f,0.0f,1.0f);
gfxPopMatrix();
gfxTranslate(0,(1-time)*2,0);
gfxSetTexture(background);
TexRect(0.0f,-1.1f,-1.1f,1.1f,0.5f,0.0f,0.0f,1.0f);
gfxSetTexture(TEXTURE_CURRPRESET);
TexRect(0,-1,-1,1,0.5f,1.0f,0.0f,1.0f);
}
if (time > 2.0f)
{
gfxTranslate(0, 0, 4.414-(time-2)*2);
gfxRotate(-65+(time-2)*65,0,1,0);
// gfxTranslate(0, 0, -0.5f);
gfxPushMatrix();
DrawFrame();
gfxSetTexture(TEXTURE_NEXTPRESET);
gfxTexRect(-1, 1, 1, -1);
}
if (time>=3){
FINISHED = true;
}
}