2 registered members (SBGuy, AndrewAMD),
739
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: "linked portal door"
[Re: 3run]
#457372
01/15/16 14:09
01/15/16 14:09
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
Serious User
|
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Take a look at this. As the video describtion says: Duke Nukem 3D supported non-euclidean geometry, in 1996. Maybe Unreal had same non-euclidean geometry support, I don't know unfortunately. Tomorrow I'll make a small research probably, it's too late right now here at my place. , didn't know that about DukeN3d (pretty cool), but the Unreal 1 I mean was like a real Portal portal/teleport. It could be my nostaligia blinding me a bit, but iirc you could really look through it (like a real view /not like flat tv) and also fire projectiles etc. through it. I remember seeing it in only 1 map, which looks similar to UT 1's Codex. My brother also remembers how well it looked so I know atleast it was not a dream. He even remembered reading something like that they changed the portals/teleports for UT 1 cause the Unreal 1 were to heavy on the computer. (dont quote me on that though) Edit: found it I think http://s37.photobucket.com/user/BrainStorm_wow/media/UT3/tele.jpg.htmlAlso perhaps read this (although it seems to be more about using the ut3 editor) -> https://forums.epicgames.com/threads/717287-How-do-you-make-Classic-Unreal-Tournament-teleporters
Last edited by Reconnoiter; 01/15/16 14:12.
|
|
|
Re: "linked portal door"
[Re: Reconnoiter]
#457373
01/15/16 14:18
01/15/16 14:18
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Thank you very much guys, that will be an interesting read! Reconnoiter@ that screen looks pretty great! it's really increadible to hear, that they've done this back in 1998. I found this on the forum so far, it seems that making portals were in vogue back in 2007 Portal Madness [Demo] Portal Tech 2 And I even found a shader made by XxXGuitar511:
texture mtlSkin1;
float4x4 matWorldViewProj;
float4x4 matWorldView;
float fAlpha;
sampler imageTex = sampler_state
{
Texture = <mtlSkin1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap;
AddressV = wrap;
};
struct vIn
{
float4 Pos : POSITION;
};
struct vOut
{
float4 Pos : POSITION;
float3 Tex : TEXCOORD0;
};
struct pIn
{
float3 Tex : TEXCOORD0;
};
vOut pVS (vIn In)
{
vOut Out = (vOut)0;
Out.Pos = mul(In.Pos, matWorldViewProj);
Out.Tex = mul(In.Pos, matWorldView).xyz;
//
return(Out);
}
float4 pPS (pIn In) : COLOR
{
float2 tPos = In.Tex.xy/In.Tex.z;
//
tPos.y = 1 - (tPos.y*1.135 + 0.5);
tPos.x = tPos.x*0.855 + 0.5;
//
float4 color = tex2D(imageTex, tPos);
color.a *= fAlpha;
//
return(color);
}
technique portalView
{
pass one
{
VertexShader = compile vs_1_1 pVS();
PixelShader = compile ps_2_0 pPS();
}
}
But I don't have any use for it yet. I'm still researching! Edit: there were even some threads with open sources for portals, but all links are dead OPEN SOURCE PROJECT - REAL TIME PORTALS Portal Madness... WIP Edit2: I guess I found some tips over the net: Render your portal space scene with same camera orientation, but camera position shifted by the same vector that describes the camera's offset from the portal in local space. Edit3: I found a 'little' but in my code, I'm passing same positions/angles for source and destination portals to updateView function. To fix that just change the following line:
updateView(portalEnt[i].portalView, portalEnt[i].linkedEnt.x, portalEnt[j].ownerEnt.x, portalEnt[i].linkedEnt.pan, portalEnt[j].ownerEnt.pan);
TO:
updateView(portalEnt[i].portalView, portalEnt[i].linkedEnt.x, portalEnt[i].ownerEnt.x, portalEnt[i].linkedEnt.pan, portalEnt[i].ownerEnt.pan);
Plus I found a good tutorial: Tom's Programming BlogAnd I'm trying to get the matrix calculations from it correctly working in my project.
|
|
|
Re: "linked portal door"
[Re: 3run]
#457375
01/15/16 21:05
01/15/16 21:05
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
After reading several article and unsucsessfuly trying to convert the calculation from the Tom's Blog (it works, but independently from portal angles, so if you rotate destination or source portal, everything get's **** up), I tried to create something by myself. Thank to those article, I somehow got the main idea of what I needed to do, so I came up with a small demo (only math calculations, no reflation and fancy stuff yet). HERE IS THE SOURCE (just save it and run from SED):
ENTITY* heroEnt;
ENTITY* ghost1Ent;
ENTITY* portal1Ent;
ENTITY* portal2Ent;
void calculatePortal(ENTITY* ent, VECTOR* srcPos, VECTOR* dstPos, ANGLE* srcAng, ANGLE* dstAng){
if(!heroEnt){ return; }
ANGLE tempAng;
vec_fill(tempAng.pan, 0);
VECTOR tempPos;
vec_fill(tempPos.x, 0);
ang_diff(tempAng.pan, dstAng.pan, srcAng.pan);
vec_set(tempPos.x, srcPos.x);
vec_sub(tempPos.x, heroEnt.x);
vec_rotate(tempPos.x, tempAng.pan);
// vec_inverse(tempPos.x); // uncomment this to mirror player's position at destination portal (comment ang_rotate 180 bellow!)
vec_add(tempPos.x, dstPos.x);
ANGLE temp2Ang, endAng;
vec_fill(temp2Ang.pan, 0);
vec_fill(endAng.pan, 0);
ang_diff(temp2Ang.pan, srcAng.pan, heroEnt.pan);
vec_inverse(temp2Ang.pan);
ang_rotate(temp2Ang.pan, vector(180, 0, 0));
vec_set(endAng.pan, dstAng.pan);
ang_add(endAng.pan, temp2Ang.pan);
// if player far away from us:
if(vec_dist(heroEnt.x, ent.x) > 25){
if(!is(ent.parent, INVISIBLE)){
set(ent.parent, INVISIBLE);
}
}
else{
if(is(ent.parent, INVISIBLE)){
reset(ent.parent, INVISIBLE);
}
vec_set(ent.parent.x, tempPos.x);
vec_set(ent.parent.pan, endAng.pan);
VECTOR tempVec;
vec_fill(tempVec.x, 0);
vec_set(tempVec.x, vector(2.5, 0, 0));
vec_rotate(tempVec.x, ent.parent.pan);
vec_add(tempVec.x, ent.parent.x);
draw_point3d(tempVec.x, COLOR_RED, 100, 1);
}
}
void portal1(){
VECTOR tempVec;
vec_fill(tempVec.x, 0);
portal1Ent = my;
vec_set(my.scale_x, vector(0.05, 1, 1));
my.pan += random(360);
set(my, LIGHT | UNLIT | PASSABLE);
vec_set(my.blue, COLOR_RED);
my.parent = ent_create(CUBE_MDL, my.x, NULL);
vec_set(my.parent.scale_x, vector(0.25, 0.25, 0.25));
set(my.parent, TRANSLUCENT | LIGHT | UNLIT | PASSABLE);
vec_set(my.parent.blue, COLOR_RED);
while(!portal2Ent){ wait(1); }
while(1){
my.pan += 5 * (key_cul - key_cur) * time_step;
my.x += 5 * (key_t - key_g) * time_step;
my.y += 5 * (key_f - key_h) * time_step;
vec_set(tempVec.x, vector(5, 0, 0));
vec_rotate(tempVec.x, my.pan);
vec_add(tempVec.x, my.x);
draw_line3d(tempVec.x, NULL, 100);
draw_line3d(tempVec.x, COLOR_RED, 100);
draw_line3d(my.x, COLOR_RED, 100);
draw_point3d(tempVec.x, COLOR_RED, 100, 1);
calculatePortal(my, my.x, portal2Ent.x, my.pan, portal2Ent.pan);
wait(1);
}
}
void portal2(){
VECTOR tempVec;
vec_fill(tempVec.x, 0);
portal2Ent = my;
vec_set(my.scale_x, vector(0.05, 1, 1));
my.pan += random(360);
set(my, LIGHT | UNLIT | PASSABLE);
vec_set(my.blue, COLOR_GREEN);
my.parent = ent_create(CUBE_MDL, my.x, NULL);
vec_set(my.parent.scale_x, vector(0.25, 0.25, 0.25));
set(my.parent, TRANSLUCENT | LIGHT | UNLIT | PASSABLE);
vec_set(my.parent.blue, COLOR_GREEN);
while(!portal1Ent){ wait(1); }
while(1){
my.pan += 5 * (key_cuu - key_cud) * time_step;
my.x += 5 * (key_i - key_k) * time_step;
my.y += 5 * (key_j - key_l) * time_step;
vec_set(tempVec.x, vector(5, 0, 0));
vec_rotate(tempVec.x, my.pan);
vec_add(tempVec.x, my.x);
draw_line3d(tempVec.x, NULL, 100);
draw_line3d(tempVec.x, COLOR_GREEN, 100);
draw_line3d(my.x, COLOR_GREEN, 100);
draw_point3d(tempVec.x, COLOR_GREEN, 100, 1);
calculatePortal(my, my.x, portal1Ent.x, my.pan, portal1Ent.pan);
wait(1);
}
}
void main(){
fps_max = 60;
level_load("");
random_seed(0);
// create portals:
ent_create(CUBE_MDL, vector(-25, 25, 0), portal1);
ent_create(CUBE_MDL, vector(25, -25, 0), portal2);
VECTOR tempVec;
vec_fill(tempVec.x, 0);
heroEnt = ent_create(CUBE_MDL, nullvector, NULL);
vec_set(heroEnt.scale_x, vector(0.25, 0.25, 0.25));
set(heroEnt, TRANSLUCENT | LIGHT | UNLIT);
vec_set(heroEnt.blue, COLOR_WHITE);
c_setminmax(heroEnt);
sun_light = 0;
set(camera, ISOMETRIC);
camera.arc = 10;
camera.z = 100;
camera.tilt = -90;
while(1){
DEBUG_VAR(heroEnt.pan, 210);
DEBUG_VAR(portal1Ent.pan, 250);
DEBUG_VAR(portal2Ent.pan, 270);
heroEnt.skill1 = 5 * (key_w - key_s) * time_step;
heroEnt.skill2 = 5 * (key_a - key_d) * time_step;
heroEnt.pan += 5 * (key_z - key_x) * time_step;
c_move(heroEnt, nullvector, heroEnt.skill1, IGNORE_PASSABLE | GLIDE);
vec_set(tempVec.x, vector(2.5, 0, 0));
vec_rotate(tempVec.x, heroEnt.pan);
vec_add(tempVec.x, heroEnt.x);
draw_point3d(tempVec.x, COLOR_RED, 100, 1);
draw_text("green and red cubes are 'ghost' players position in the destination portals\nwhite cube is player, and those two red/green lines are portals\nyou can see the way they are facing from the lines comming out of portals\nthe green one is source portal and the other one is destination portal (and visa versa)\nuse cursor keys to rotate the portals use WSAD to move the player around \nand TGFH and IKJL to move portals", 10, 10, COLOR_WHITE);
wait(1);
}
}
Please give it a try guys and tell me, am I even on the right track? Edit: I think, this will at least help me with object duplication, to get the seamless transition of object from one portal to another. Edit2: I edited the code (updated). Best regards!
|
|
|
Re: "linked portal door"
[Re: 3run]
#457379
01/16/16 01:00
01/16/16 01:00
|
Joined: Feb 2012
Posts: 371
Dico
Senior Member
|
Senior Member
Joined: Feb 2012
Posts: 371
|
After reading several article and unsucsessfuly trying to convert the calculation from the Tom's Blog (it works, but independently from portal angles, so if you rotate destination or source portal, everything get's **** up), I tried to create something by myself. Thank to those article, I somehow got the main idea of what I needed to do, so I came up with a small demo (only math calculations, no reflation and fancy stuff yet). HERE IS THE SOURCE (just save it and run from SED):
ENTITY* heroEnt;
ENTITY* ghost1Ent;
ENTITY* portal1Ent;
ENTITY* portal2Ent;
void calculatePortal(ENTITY* ent, VECTOR* srcPos, VECTOR* dstPos, ANGLE* srcAng, ANGLE* dstAng){
if(!heroEnt){ return; }
ANGLE tempAng;
vec_fill(tempAng.pan, 0);
VECTOR tempPos;
vec_fill(tempPos.x, 0);
ang_diff(tempAng.pan, dstAng.pan, srcAng.pan);
vec_diff(tempPos.x, srcPos.x, heroEnt.x);
vec_rotate(tempPos.x, tempAng.pan);
vec_inverse(tempPos.x);
vec_add(tempPos.x, dstPos.x);
ANGLE temp2Ang, endAng;
vec_fill(temp2Ang.pan, 0);
vec_fill(endAng.pan, 0);
ang_diff(temp2Ang.pan, srcAng.pan, heroEnt.pan);
vec_set(endAng.pan, dstAng.pan);
vec_inverse(temp2Ang.pan);
ang_add(endAng.pan, temp2Ang.pan);
// if player far away from us:
if(vec_dist(heroEnt.x, ent.x) > 25){
if(!is(ent.parent, INVISIBLE)){
set(ent.parent, INVISIBLE);
}
}
else{
if(is(ent.parent, INVISIBLE)){
reset(ent.parent, INVISIBLE);
}
vec_set(ent.parent.x, tempPos.x);
vec_set(ent.parent.pan, endAng.pan);
}
}
void portal1(){
VECTOR tempVec;
vec_fill(tempVec.x, 0);
portal1Ent = my;
vec_set(my.scale_x, vector(0.05, 1, 1));
my.pan += random(360);
set(my, LIGHT | UNLIT | PASSABLE);
vec_set(my.blue, COLOR_RED);
my.parent = ent_create(CUBE_MDL, my.x, NULL);
vec_set(my.parent.scale_x, vector(0.25, 0.25, 0.25));
set(my.parent, TRANSLUCENT | LIGHT | UNLIT | PASSABLE);
vec_set(my.parent.blue, COLOR_RED);
while(!portal2Ent){ wait(1); }
while(1){
my.pan += 5 * (key_cul - key_cur) * time_step;
my.x += 5 * (key_t - key_g) * time_step;
my.y += 5 * (key_f - key_h) * time_step;
vec_set(tempVec.x, vector(5, 0, 0));
vec_rotate(tempVec.x, my.pan);
vec_add(tempVec.x, my.x);
draw_line3d(tempVec.x, NULL, 100);
draw_line3d(tempVec.x, COLOR_RED, 100);
draw_line3d(my.x, COLOR_RED, 100);
draw_point3d(tempVec.x, COLOR_RED, 100, 1);
calculatePortal(my, my.x, portal2Ent.x, my.pan, portal2Ent.pan);
wait(1);
}
}
void portal2(){
VECTOR tempVec;
vec_fill(tempVec.x, 0);
portal2Ent = my;
vec_set(my.scale_x, vector(0.05, 1, 1));
my.pan += random(360);
set(my, LIGHT | UNLIT | PASSABLE);
vec_set(my.blue, COLOR_GREEN);
my.parent = ent_create(CUBE_MDL, my.x, NULL);
vec_set(my.parent.scale_x, vector(0.25, 0.25, 0.25));
set(my.parent, TRANSLUCENT | LIGHT | UNLIT | PASSABLE);
vec_set(my.parent.blue, COLOR_GREEN);
while(!portal1Ent){ wait(1); }
while(1){
my.pan += 5 * (key_cuu - key_cud) * time_step;
my.x += 5 * (key_i - key_k) * time_step;
my.y += 5 * (key_j - key_l) * time_step;
vec_set(tempVec.x, vector(5, 0, 0));
vec_rotate(tempVec.x, my.pan);
vec_add(tempVec.x, my.x);
draw_line3d(tempVec.x, NULL, 100);
draw_line3d(tempVec.x, COLOR_GREEN, 100);
draw_line3d(my.x, COLOR_GREEN, 100);
draw_point3d(tempVec.x, COLOR_GREEN, 100, 1);
calculatePortal(my, my.x, portal1Ent.x, my.pan, portal1Ent.pan);
wait(1);
}
}
void main(){
fps_max = 60;
level_load("");
random_seed(0);
// create portals:
ent_create(CUBE_MDL, vector(-25, 25, 0), portal1);
ent_create(CUBE_MDL, vector(25, -25, 0), portal2);
heroEnt = ent_create(CUBE_MDL, nullvector, NULL);
vec_set(heroEnt.scale_x, vector(0.25, 0.25, 0.25));
set(heroEnt, TRANSLUCENT | LIGHT | UNLIT);
vec_set(heroEnt.blue, COLOR_WHITE);
c_setminmax(heroEnt);
sun_light = 0;
set(camera, ISOMETRIC);
camera.arc = 10;
camera.z = 100;
camera.tilt = -90;
while(1){
DEBUG_VAR(heroEnt.pan, 210);
DEBUG_VAR(portal1Ent.pan, 250);
DEBUG_VAR(portal2Ent.pan, 270);
heroEnt.skill1 = 5 * (key_w - key_s) * time_step;
heroEnt.skill2 = 5 * (key_a - key_d) * time_step;
heroEnt.pan += 5 * (key_z - key_x) * time_step;
c_move(heroEnt, nullvector, heroEnt.skill1, IGNORE_PASSABLE | GLIDE);
draw_text("green and red cubes are 'ghost' players position in the destination portals\nwhite cube is player, and those two white lines are portals\nyou can see the way they are facing from the lines comming out of portals\nthe one near by the player is source portal and the other\none is destination portal, use cursor keys to rotate the portals\nuse WSAD to move the player around and TGFH and IKJL to move portals", 10, 10, COLOR_WHITE);
wait(1);
}
}
Please give it a try guys and tell me, am I even on the right track? Edit: I think, this will at least help me with object duplication, to get the seamless transition of object from one portal to another. Best regards! Thats cool , im also have a solution for portal view rendring so it not look like a flat tv ,i will upload the source here.
|
|
|
Re: "linked portal door"
[Re: Dico]
#457406
01/17/16 10:00
01/17/16 10:00
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
Hi, I gived a try to this issue. I was pretty sure I was right when sentenced how portal camera offset and orientation should be computed but failed
ANGLE angBack;
vec_set ( &angBack, &entPortalA->pan );
vec_inverse ( &angBack );
vec_diff ( &camPortalA->x, &camera->x, &entPortalA->x );
vec_rotate ( &camPortalA->x, &angBack );
vec_rotate ( &camPortalA->x, &entPortalB->pan );
vec_add ( &camPortalA->x, &entPortalB->x );
vec_set ( &camPortalA->pan, &camera->pan );
ang_add ( &camPortalA->pan, &angBack );
ang_add ( &camPortalA->pan, &entPortalB->pan );
This what I got so far: downloadMove portals by right and left mouse buttons. Vertical portals, portal cameras clipping planes, and portals shader work good at least xP
|
|
|
Re: "linked portal door"
[Re: txesmi]
#457418
01/17/16 18:32
01/17/16 18:32
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Vertical portals, portal cameras clipping planes, and portals shader work good at least xP Thank you very much! I just got home after the week end, so I'll continue on copulating with my poor brain My best regards!
|
|
|
Re: "linked portal door"
[Re: txesmi]
#457421
01/17/16 23:42
01/17/16 23:42
|
Joined: Feb 2012
Posts: 371
Dico
Senior Member
|
Senior Member
Joined: Feb 2012
Posts: 371
|
Hi, I gived a try to this issue. I was pretty sure I was right when sentenced how portal camera offset and orientation should be computed but failed
ANGLE angBack;
vec_set ( &angBack, &entPortalA->pan );
vec_inverse ( &angBack );
vec_diff ( &camPortalA->x, &camera->x, &entPortalA->x );
vec_rotate ( &camPortalA->x, &angBack );
vec_rotate ( &camPortalA->x, &entPortalB->pan );
vec_add ( &camPortalA->x, &entPortalB->x );
vec_set ( &camPortalA->pan, &camera->pan );
ang_add ( &camPortalA->pan, &angBack );
ang_add ( &camPortalA->pan, &entPortalB->pan );
This what I got so far: downloadMove portals by right and left mouse buttons. Vertical portals, portal cameras clipping planes, and portals shader work good at least xP Good exemple , thanks
|
|
|
|