[Solved] SKYBOX viewpoint move in relation to the player?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

[Solved] SKYBOX viewpoint move in relation to the player?

Postby Tormentor667 » Sat Dec 23, 2017 8:17 am

I know, I can remember that I have asked this already times before but I can't find the appropriate thread or solution anymore. So here is what I have:

Imagine having a large outdoor area, in which the player is moving. This area also uses a skybox, which is smaller than the outdoor area. Now normally, the skybox viewpoint would stick where it is and not move when you travel through the outdoor area. But what can I do to make the skybox viewpoint seamlessly move according to the player speed and direction, just much slower (a fractional definable part) so it looks like the skybox is part of the area where the sky is used in?

Thanks already for your support
Last edited by Tormentor667 on Sun Dec 24, 2017 2:02 pm, edited 1 time in total.
User avatar
Tormentor667
needs more detail
 
Joined: 16 Jul 2003
Location: Germany

Re: Making a SKYBOX viewpoint move in relation to the player

Postby Rachael » Sat Dec 23, 2017 10:10 am

This has not been implemented yet. I was actually going to implement this willy nilly at one point, but the code relating to skyboxes is really complicated right now.
User avatar
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Making a SKYBOX viewpoint move in relation to the player

Postby Tormentor667 » Sat Dec 23, 2017 10:53 am

Could it be done somehow through ACS?
User avatar
Tormentor667
needs more detail
 
Joined: 16 Jul 2003
Location: Germany

Re: Making a SKYBOX viewpoint move in relation to the player

Postby Rachael » Sat Dec 23, 2017 11:13 am

If it can, it definitely won't be smooth.

I think your best bet might be to try it through ZScript, since ZScript can call the SkyboxCam object directly without a tag and can be run during intertics.
User avatar
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Making a SKYBOX viewpoint move in relation to the player

Postby AFADoomer » Sat Dec 23, 2017 1:36 pm

Here's an initial hack at doing this in ZScript... This actor can be used in place of a standard SkyViewpoint actor. Argument 1 controls the amount of scaling of the viewpoint's movement.
Code: Select allExpand view
class SkyViewPointStatic SkyViewPoint
{
    
PlayerPawn base;
    
Vector3 basepos;
    
int scaling;

    Default
    {
        
//$Arg1 "Skybox Scene Scale"
        //$Arg1Tooltip "The scale of the skybox's scene (default is 100).  The larger this number is, the farther away the skybox contents will appear to be."
    
}

    
override void PostBeginPlay()
    {
        
// Set the scaling value according to whatever arg 1 value is passed; use 100 if nothing provided
        
scaling args[1] == 100 args[1];

        
// Save the spawn location vector for later
        
SpawnPoint pos;

        
// Iterate through all of the possible players in the game
        
for (int i 0MAXPLAYERSi++)
        {
            
// If a player is in the game and has spawned...
            
if (playeringame[i] && players[i].mo)
            {
                if (!
base) { base players[i].mo; } // Set the skybox to follow the first player who is in the game
                
else { base null; break; } // If there are multiple players, don't move the skybox
            
}
        }
    }

    
override void Tick()
    {
        if (
base)
        {
            
Vector3 newvel;

            
// Reset the viewpoint's height location
            
double heightdelta = (base.pos.base.floorz) / scaling;
            
SetOrigin((pos.xpos.ySpawnPoint.heightdelta), true);

            
// Only move the viewpoint on the x/y axis if the player actually is moving along that axis; otherwise stay still
            
if (basepos.!= base.pos.x) { newvel.base.vel.x; }
            if (
basepos.!= base.pos.y) { newvel.base.vel.y; }
            
newvel.= -base.vel.z;

            
// Adjust the move amount by scaling value
            
newvel /= scaling;
            
A_ChangeVelocity(newvel.xnewvel.ynewvel.zCVF_RELATIVE CVF_REPLACE);

            
// Save the player's old position for the move checks
            
basepos base.pos;
        }

        
Super.Tick();
    }
}


Probably not perfect, but it works...

EDIT: Updated with fixed code that doesn't botch the rotational math.
Last edited by AFADoomer on Sun Dec 24, 2017 9:51 am, edited 1 time in total.
User avatar
AFADoomer
 
Joined: 15 Jul 2003

Re: Making a SKYBOX viewpoint move in relation to the player

Postby Ozymandias81 » Sat Dec 23, 2017 1:41 pm

Maybe this try could be of help, still didn't test btw
User avatar
Ozymandias81
Doom is a State of Mind... Out of Control.
 
Joined: 04 Jul 2013
Location: Mount Olympus, Mars
Github ID: Ozymandias81
Operating System: Windows Vista/7/2008 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Making a SKYBOX viewpoint move in relation to the player

Postby ibm5155 » Sun Dec 24, 2017 8:02 am

I did a moving sky in Glitchland
In case you want, I did a loop calling this line
Code: Select allExpand view
script 2 ENTER{
    int H = 20;
    int A = 50;
    thing_changetid(playernumber(),playernumber()+1000);
    while(true){
 >>>>>    SetActorPosition(2, -GetActory(1000)/100+14096.0, GetActorX(1000)/100+19424.0, GetActorZ(1000)/25+48.0, 0);
        if(H>0){
            if(GetActorProperty(0,APROP_Health) < 20){
                H--;
                SpawnForced("Stimpack",getactorx(1000),getactory(1000),getsectorceilingz(0,getactorx(1000),getactory(1000))-10.0,0,0);
                delay(35*10);
            }
        }
        if(A>0){
            if(CheckWeapon("Pistol") || CheckWeapon("Chaingun")){
               if(CheckInventory("Clip") < 3){
                    A--;
                    SpawnForced("Clip",getactorx(1000),getactory(1000),getsectorceilingz(0,getactorx(1000),getactory(1000))-10.0,0,0);
                    delay(35*10);
                }
            }
            if(CheckWeapon("Shotgun") || CheckWeapon("SuperShotgun")){
                if(CheckInventory("Shell") < 3){
                    A--;
                    SpawnForced("Shell",getactorx(1000),getactory(1000),getsectorceilingz(0,getactorx(1000),getactory(1000))-10.0,0,0);
                    delay(35*10);
                }
            }
        }
       
        delay(1);
    }
}


EDIT: The only draw side is that it's single player only (maybe with zandronum using clientside scripts)
User avatar
ibm5155
Just Spooky
 
Joined: 20 Jul 2011

Re: Making a SKYBOX viewpoint move in relation to the player

Postby Tormentor667 » Sun Dec 24, 2017 2:02 pm

Can confirm: AFADoomers code works like a charm, thanks kindly :)
User avatar
Tormentor667
needs more detail
 
Joined: 16 Jul 2003
Location: Germany

Re: [Solved] SKYBOX viewpoint move in relation to the player

Postby ZZYZX » Mon Dec 25, 2017 8:11 am

I suggest using players[i].camera, not players[i].mo, because player sometimes F12's or does other complex things.
Sadly I personally don't know how to detect chasecam (other than &CF_CHASECAM and duplicate logic, but that's not really a good way to do it)

Obligatory notice that if someone (looks at Graf and Eruanna, especally Eruanna) didn't block my RenderFrame code, we'd be able to change skybox depending on which view is currently rendering. Transparently supporting all kinds of weird camera hacks that GZDoom has — security cameras, preview security cameras (cameratextures), skyboxes, portals, line portals, chasecams, etc...

Note: there is still RenderOverlay event that has this:
Code: Select allExpand view
struct RenderEvent native ui version("2.4")
{
    native readonly Vector3 ViewPos;
    native readonly double ViewAngle;
    native readonly double ViewPitch;
    native readonly double ViewRoll;
    native readonly double FracTic;
    native readonly Actor Camera;
}
You can probably pick up real camera pos from there, but high chance that it won't work (I'm not sure if ViewPos and everything else gets saved before it goes into portals/skyboxes, it might NOT, as such this event will receive "last used" data and not the one you see...)
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine
Discord: ZZYZX#1394
Github ID: jewalky

Re: [Solved] SKYBOX viewpoint move in relation to the player

Postby AFADoomer » Mon Dec 25, 2017 12:43 pm

Yeah, there are a few quirks with just using player position... Bob isn't accounted for, and I need to tweak how I'm accounting for height changes.

I think it's "good enough" for right now, but I'll experiment with using the camera (and possible the RenderEvent) and see if that produces better results.

Thanks!
User avatar
AFADoomer
 
Joined: 15 Jul 2003

Re: [Solved] SKYBOX viewpoint move in relation to the player

Postby Zeberpal » Tue Feb 27, 2018 12:39 pm

Hello! Thank you for this kind of script!
If it is okay to post a little cry for help here: I have never touched ZSCRIPT before, but I'm dying to implement this feature in my map.

I wish you could spare a few bits to explain how to import this script into PK3 and ultimately make it work in GZDoom.

Here is what I do:
1) Create zscript.zsc file and copypaste AKADoomer's code. There is nothing more than that in my .Pk3
2) :? Since it seems to be a replacement for SkyboxViewpoint, I put it(thing type 9080) in my map, play with Argument 1 as it requires, however nothing happens.

How to do it right?
User avatar
Zeberpal
 
Joined: 28 Apr 2013
Location: RU

Re: [Solved] SKYBOX viewpoint move in relation to the player

Postby ramon.dexter » Wed Feb 28, 2018 1:35 am

Zeberpal: your assumption is not correct. The new skypoint inherits from skyboxviewpoint, but nothing more. You need to assign it a doomed number in order to work with it.

Check this: https://zdoom.org/wiki/Using_inheritance
User avatar
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: [Solved] SKYBOX viewpoint move in relation to the player

Postby Zeberpal » Wed Feb 28, 2018 3:50 am

ramon.dexter wrote:You need to assign it a doomed number in order to work with it.


Thanks for reply ramon.dexter, it works now) However, it seems it is impossible to give a number to a class like we do in DECORATE?
So I used MAPINFO to assign DoomEdNums there
Code: Select allExpand view
DoomEdNums
{
666 = SkyViewPointStatic, 0, 11, 0, 0, 0  //AFADoomer's class
}


Wondering if it is an okay practice.
User avatar
Zeberpal
 
Joined: 28 Apr 2013
Location: RU

Re: [Solved] SKYBOX viewpoint move in relation to the player

Postby ramon.dexter » Wed Feb 28, 2018 6:57 am

zeberpal: No, you cannot assign doomed number to the in the way like in decorate (actor blabla 12345). But the assignement in mapinfo is similar. It is assigned to the one class (also, you need only the number; whats behind it is not neccessary.
User avatar
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests