ScarletBlackMarket/script/3drender/3dtimebicht.dnh

188 lines
3.8 KiB
Plaintext
Raw Permalink Normal View History

2022-08-20 05:42:00 +00:00
// 3D STAGE TUTORIAL
// X : horizontal, Y : vertical, Z : depth (close/near)
// Stage script -> Set textures
#TouhouDanmakufu[Stage]
#Title["3D Stages"]
#Text["Stage script for 3D practice"]
#ScriptVersion[3]
#System["script/KevinSystem/Kevin_System.txt"]
let CSD = GetCurrentScriptDirectory;
let texturefloor = CSD ~ "sprite/dafloorEX.png";
let texturewall = CSD ~ "sprite/damagicwall.png";
let texturefog = CSD ~ "sprite/cardbg4.png";
// REMEMBER : set variable texturefloor as png because my ass internet
// can't download a simple png
// ------- Function to create one floor piece -------//
/*
SetAngleXYZ?
+ Rotates/flips the 3D sprite around a X, Y, Z axis.
+ Direction is influenced by HOW THE CAMERA IS SET -> Setting the camera
correctly is important!
X : horizontal
Y : vertical
Z : depth
*/
function FloorCreation(locX,locY,locZ){
let floorObj = ObjPrim_Create(OBJ_SPRITE_3D);
ObjPrim_SetTexture(floorObj,texturefloor);
Obj_SetRenderPriorityI(floorObj,20);
ObjSprite3D_SetSourceDestRect(floorObj,0,0,512,512);
ObjRender_SetScaleXYZ(floorObj,1,1,0);
ObjRender_SetZWrite(floorObj,true);
ObjRender_SetAngleXYZ(floorObj,90,0,0); // Floor-styled render
ObjRender_SetPosition(floorObj,locX,locY,locZ); // Positioning of floor, notice function parameters
}
function WallCreation(locX,locY,locZ){
let floorObj = ObjPrim_Create(OBJ_SPRITE_3D);
ObjPrim_SetTexture(floorObj,texturewall);
Obj_SetRenderPriorityI(floorObj,20);
ObjSprite3D_SetSourceDestRect(floorObj,0,0,1024,1024);
ObjRender_SetScaleXYZ(floorObj,0.5,1,0);
ObjRender_SetZWrite(floorObj,true);
ObjRender_SetAngleXYZ(floorObj,0,90,0); // Wall-styled render
ObjRender_SetPosition(floorObj,locX,locY,locZ);
}
function FogCreation(locX,locY,locZ){
let floorObj = ObjPrim_Create(OBJ_SPRITE_3D);
ObjPrim_SetTexture(floorObj,texturefog);
Obj_SetRenderPriorityI(floorObj,20);
ObjSprite3D_SetSourceDestRect(floorObj,0,0,1024,1024); // Fully covers screen
ObjRender_SetScaleXYZ(floorObj,4,4,0);
ObjRender_SetZWrite(floorObj,true);
// ObjRender_SetAngleXYZ(floorObj,0,0,0); -> NOT USED,
// as the fog will always be facing player
ObjSprite3D_SetBillboard(floorObj,true);
ObjRender_SetPosition(floorObj,locX,locY,locZ);
}
@Initialize{
// Call the task to start stage renders
//SetIntersectionVisualization(true);
StageTime;
scrollitbabe;
}
@Event{
}
@MainLoop{
yield;
}
@Finalize{
}
task StageTime{
// Fog construction
SetFogEnable(true);
SetFogParam(1024,1536,20,15,35);
FogCreation(0,0,2048);
// Stage construction, like cardboard house building
ascent(i in 0..4){
FloorCreation(0,0,512*i);
yield;
}
ascent (i in 0..4){
WallCreation(-256,256,512*i);
yield;
}
ascent (i in 0..4){
WallCreation(256,256,512*i);
yield;
}
}
// Stage scrolling
/* Guide : CAMERAS?????
* AZIMUTH *
SetCameraAzimuthAngle(0); - ?????
SetCameraElevationAngle(0); - How HIGH the camera is
SetCameraRadius(0); - How FAR the camera is
* FOCUS *
SetCameraFocusX(0);
SetCameraFocusY(0);
SetCameraFocusZ(0);
* ????? *
SetCameraYaw(0);
SetCameraPitch(0);
SetCameraRoll(0);
*/
task scrollitbabe{
let scroll = 0;
let ang = 0;
let theyaeur = -180;
// CAMERA SYSTEM handled here
// Min/max camera render distance
SetCameraPerspectiveClip(16,6000);
// Camera settings - TBE (to be explained)
async{
loop{
SetCameraAzimuthAngle(theyaeur);
theyaeur = Interpolate_Decelerate(-105, -115, cos(NormalizeAngle(ang)));
ang += 1;
yield;
}
}
SetCameraElevationAngle(15);
SetCameraRadius(64);
SetCameraFocusX(0);
SetCameraFocusY(512);
SetCameraFocusZ(-512);
/* GUIDE : The scroll illusion
Make a variable, add it to CameraZ
Count the variable to move CameraZ forward
At a certain point, reset it back to the beginning
Add fog, profit(?) */
loop{
SetCameraFocusZ(-512+scroll);
if(scroll > 512){
scroll = 0;
}
scroll+=24;
yield;
}
// Maintaining the perfect illusion with Fog
}