Add projects including README.md(s), .gitignore(s) and the actual project files.
Signed-off-by: Michael Fabian Dirks <michael.dirks@project-kube.de>
This commit is contained in:
@@ -0,0 +1,282 @@
|
||||
Const CfgMeshToRender$ = "D:\Projekte\Blitz3D\Sirius\GFX\ENV\VINxROIDx001.3ds"
|
||||
Const CfgDiffuseMap$ = "D:\Projekte\Blitz3D\Sirius\GFX\ENV\VINxROIDx001DIFF.png"
|
||||
Const CfgDiffuseFlags% = (1+256+512)
|
||||
Const CfgNormalMap$ = "D:\Projekte\Blitz3D\Sirius\GFX\ENV\VINxROIDx001NORM.png"
|
||||
Const CfgNormalFlags = (1+256+512)
|
||||
|
||||
Const CfgFrameSizeX = 128
|
||||
Const CfgFrameSizeY = 128
|
||||
Const CfgPitchMin# = -90
|
||||
Const CfgPitchMax# = 90
|
||||
Const CfgPitchFrames = 5
|
||||
Const CfgYawMin# = 0
|
||||
Const CfgYawMax# = 360
|
||||
Const CfgYawFrames = 16
|
||||
Const CfgDistance# = 120
|
||||
|
||||
; Includes
|
||||
Include "FreeImage.bb"
|
||||
Include "FastExt.bb"
|
||||
Include "../Advanced Text (Library)/AdvText.bb"
|
||||
Include "Impostor.bb"
|
||||
|
||||
; Set up 3D Scene
|
||||
Graphics3D 1024, 1024, 32, 2:InitExt()
|
||||
SetBuffer_ BackBuffer()
|
||||
|
||||
; Set up Camera
|
||||
Global CameraPivot = CreatePivot()
|
||||
Global Camera = CreateCamera(CameraPivot)
|
||||
MoveEntity Camera, 0, 0, -CfgDistance
|
||||
|
||||
AmbientLight 255, 255, 255
|
||||
|
||||
; Set up Impostor data
|
||||
Local ImpostorMesh% = LoadMesh(CfgMeshToRender)
|
||||
Local ImpostorDiffuse% = LoadTexture(CfgDiffuseMap, CfgDiffuseFlags)
|
||||
Local ImpostorNormal% = LoadTexture(CfgNormalMap, CfgNormalFlags)
|
||||
|
||||
; Set up final image
|
||||
Local DiffuseSheet% = CreateImage(CfgFrameSizeX, CfgFrameSizeY, CfgYawFrames * CfgPitchFrames)
|
||||
Local NormalSheet% = CreateImage(CfgFrameSizeX, CfgFrameSizeY, CfgYawFrames * CfgPitchFrames)
|
||||
|
||||
; Set up render target
|
||||
;Const RTSize% = 2048
|
||||
Local RenderTarget% = CreateTexture(CfgFrameSizeX, CfgFrameSizeY, 1+256+FE_RENDER+FE_ZRENDER)
|
||||
CameraViewport Camera, 0, 0, CfgFrameSizeX, CfgFrameSizeY
|
||||
|
||||
; Render
|
||||
SetBuffer TextureBuffer(RenderTarget)
|
||||
Local YawStep# = (CfgYawMax - CfgYawMin) / CfgYawFrames
|
||||
Local PitchStep# = (CfgPitchMax - CfgPitchMin) / CfgPitchFrames
|
||||
Local Yaw, Pitch
|
||||
For Yaw = 0 To CfgYawFrames - 1
|
||||
Local RealYaw# = CfgYawMin + (YawStep * Yaw)
|
||||
For Pitch = 0 To CfgPitchFrames - 1
|
||||
Local RealPitch# = CfgPitchMin + (PitchStep * Pitch)
|
||||
Local Frame = Pitch * CfgYawFrames + Yaw
|
||||
|
||||
RotateEntity CameraPivot, RealPitch, RealYaw, 0, 1
|
||||
|
||||
; Render Diffuse
|
||||
Cls:EntityTexture ImpostorMesh, ImpostorDiffuse:RenderWorld:CopyRectStretch(0, 0, CfgFrameSizeX, CfgFrameSizeY, 0, 0, CfgFrameSizeX, CfgFrameSizeY, TextureBuffer(RenderTarget), ImageBuffer(DiffuseSheet, Frame))
|
||||
; Render Normal
|
||||
Cls:EntityTexture ImpostorMesh, ImpostorNormal:RenderWorld:CopyRectStretch(0, 0, CfgFrameSizeX, CfgFrameSizeY, 0, 0, CfgFrameSizeX, CfgFrameSizeY, TextureBuffer(RenderTarget), ImageBuffer(NormalSheet, Frame))
|
||||
Next
|
||||
Next
|
||||
SetBuffer BackBuffer()
|
||||
FreeTexture RenderTarget
|
||||
|
||||
Local Stream = WriteFile("Preview.imp")
|
||||
WriteShort Stream, CfgFrameSizeX
|
||||
WriteShort Stream, CfgFrameSizeY
|
||||
WriteByte Stream, CfgPitchFrames
|
||||
WriteFloat Stream, CfgPitchMin
|
||||
WriteFloat Stream, CfgPitchMax
|
||||
WriteByte Stream, CfgYawFrames
|
||||
WriteFloat Stream, CfgYawMin
|
||||
WriteFloat Stream, CfgYawMax
|
||||
CloseFile(Stream)
|
||||
Stream = WriteFile("PreviewNormal.imp")
|
||||
WriteShort Stream, CfgFrameSizeX
|
||||
WriteShort Stream, CfgFrameSizeY
|
||||
WriteByte Stream, CfgPitchFrames
|
||||
WriteFloat Stream, CfgPitchMin
|
||||
WriteFloat Stream, CfgPitchMax
|
||||
WriteByte Stream, CfgYawFrames
|
||||
WriteFloat Stream, CfgYawMin
|
||||
WriteFloat Stream, CfgYawMax
|
||||
CloseFile(Stream)
|
||||
|
||||
|
||||
Function SaveAnimImageSheet(Image%, File$, FramesX%, FramesY%)
|
||||
Local x, y, img = CreateImage(ImageWidth(Image) * FramesX, ImageHeight(Image) * FramesY)
|
||||
For x = 0 To FramesX - 1
|
||||
For y = 0 To FramesY - 1
|
||||
Local frame = y * FramesX + x
|
||||
CopyRect 0, 0, ImageWidth(Image), ImageHeight(Image), x * ImageWidth(Image), y * ImageHeight(Image), ImageBuffer(Image, frame), ImageBuffer(img)
|
||||
Next
|
||||
Next
|
||||
FiSaveImage(img, File)
|
||||
End Function
|
||||
|
||||
SaveAnimImageSheet(DiffuseSheet, "Preview.png", CfgYawFrames, CfgPitchFrames)
|
||||
SaveAnimImageSheet(NormalSheet, "PreviewNormal.png", CfgYawFrames, CfgPitchFrames)
|
||||
|
||||
Global ControlHelp1$
|
||||
ControlHelp1$ = ControlHelp1$ + "Controls:" + Chr(10)
|
||||
ControlHelp1$ = ControlHelp1$ + Chr(9) + "1 - Mode: Draw Sheet" + Chr(10)
|
||||
ControlHelp1$ = ControlHelp1$ + Chr(9) + "2 - Mode: Draw Frame" + Chr(10)
|
||||
ControlHelp1$ = ControlHelp1$ + Chr(9) + "3 - Mode: 3D Preview" + Chr(10)
|
||||
Global ControlHelp2$
|
||||
ControlHelp2$ = ControlHelp2$ + "Sheet Mode Controls:" + Chr(10)
|
||||
ControlHelp2$ = ControlHelp2$ + Chr(9) + "Q - Sheet: Diffuse" + Chr(10)
|
||||
ControlHelp2$ = ControlHelp2$ + Chr(9) + "W - Sheet: Normal" + Chr(10)
|
||||
Global ControlHelp3$
|
||||
ControlHelp3$ = ControlHelp3$ + "Frame Mode Controls:" + Chr(10)
|
||||
ControlHelp3$ = ControlHelp3$ + Chr(9) + "Q - Sheet: Diffuse" + Chr(10)
|
||||
ControlHelp3$ = ControlHelp3$ + Chr(9) + "W - Sheet: Normal" + Chr(10)
|
||||
ControlHelp3$ = ControlHelp3$ + Chr(9) + "A - Previous Frame" + Chr(10)
|
||||
ControlHelp3$ = ControlHelp3$ + Chr(9) + "D - Next Frame" + Chr(10)
|
||||
Global ControlHelp4$
|
||||
ControlHelp4$ = ControlHelp4$ + "3D Mode Controls:" + Chr(10)
|
||||
ControlHelp4$ = ControlHelp4$ + Chr(9) + "Q - Sheet: Diffuse" + Chr(10)
|
||||
ControlHelp4$ = ControlHelp4$ + Chr(9) + "W - Sheet: Normal" + Chr(10)
|
||||
ControlHelp4$ = ControlHelp4$ + Chr(9) + "Mouse - Rotate Camera" + Chr(10)
|
||||
|
||||
Local Timer = CreateTimer(30)
|
||||
|
||||
Const DrawModeSheet% = 0
|
||||
Const DrawModeFrame% = 1
|
||||
Const DrawMode3D% = 2
|
||||
Local DrawMode% = DrawModeSheet
|
||||
|
||||
Local ModeSheet_Image% = DiffuseSheet
|
||||
Local ModeSheet_XOff% = 0
|
||||
Local ModeSheet_YOff% = 0
|
||||
|
||||
Local ModeFrame_Image% = DiffuseSheet
|
||||
Local ModeFrame_Frame% = 0
|
||||
|
||||
|
||||
Local Mode3D_DiffImp.Impostor = Impostor_Load("Preview.imp")
|
||||
Local Mode3D_NormImp.Impostor = Impostor_Load("PreviewNormal.imp")
|
||||
Local Mode3D_Pitch# = 0
|
||||
Local Mode3D_Yaw# = 0
|
||||
Local Mode3D_Pivot = CreatePivot()
|
||||
Local Mode3D_Camera = CreateCamera(Mode3D_Pivot)
|
||||
MoveEntity Mode3D_Camera, 0, 0, -100
|
||||
EntityTexture ImpostorMesh, ImpostorDiffuse:HideEntity Mode3D_NormImp\Pivot
|
||||
|
||||
CameraViewport Camera, 0, 256, 512, 512
|
||||
CameraViewport Mode3D_Camera, 512, 256, 512, 512
|
||||
MoveEntity Mode3D_DiffImp\Mesh, 1000, 0, 0
|
||||
MoveEntity Mode3D_NormImp\Mesh, 1000, 0, 0
|
||||
ScaleEntity Mode3D_DiffImp\Mesh, CfgDistance, CfgDistance, 1
|
||||
ScaleEntity Mode3D_NormImp\Mesh, CfgDistance, CfgDistance, 1
|
||||
MoveEntity Mode3D_Pivot, 1000, 0, 0
|
||||
CameraRange Camera, 0.1, 500
|
||||
CameraRange Mode3D_Camera, 0.1, 500
|
||||
|
||||
;Local tc = CreateCube(Mode3D_Pivot)
|
||||
EntityTexture Mode3D_DiffImp\Mesh, Mode3D_DiffImp\Sheet, 0, 0
|
||||
|
||||
While Not KeyHit(1)
|
||||
Cls
|
||||
|
||||
; 3D - Render
|
||||
If DrawMode = DrawMode3D
|
||||
Impostor_Update(Mode3D_Camera)
|
||||
;EntityTexture Mode3D_DiffImp\Mesh, Mode3D_DiffImp\Sheet, 0, 0
|
||||
WireFrame KeyDown(57)
|
||||
RenderWorld
|
||||
EndIf
|
||||
|
||||
; 2D - Rener
|
||||
AdvText 0, 0, ControlHelp1, 0, 0, 1
|
||||
|
||||
; Show Mode specific data.
|
||||
Select DrawMode
|
||||
Case DrawModeSheet
|
||||
; Control
|
||||
If MouseDown(1) And MouseHit(1) Then
|
||||
MoveMouse MouseX(), MouseY()
|
||||
ElseIf MouseDown(1)
|
||||
ModeSheet_XOff = ModeSheet_XOff + MouseXSpeed()
|
||||
ModeSheet_YOff = ModeSheet_YOff + MouseYSpeed()
|
||||
EndIf
|
||||
|
||||
If KeyHit(16) Then ModeSheet_Image = DiffuseSheet
|
||||
If KeyHit(17) Then ModeSheet_Image = NormalSheet
|
||||
|
||||
; Render
|
||||
Local rw = ImageWidth(ModeSheet_Image) * CfgYawFrames
|
||||
Local rh = ImageHeight(ModeSheet_Image) * CfgPitchFrames
|
||||
For p = 0 To CfgPitchFrames - 1
|
||||
For y = 0 To CfgYawFrames - 1
|
||||
DrawImage ModeSheet_Image, GraphicsWidth() / 2 - rw / 2 + ModeSheet_XOff + ImageWidth(ModeSheet_Image) * y, GraphicsHeight() / 2 - rh / 2 + ModeSheet_YOff + ImageHeight(ModeSheet_Image) * p, y + p * CfgYawFrames
|
||||
Next
|
||||
Next
|
||||
|
||||
; Show Help
|
||||
AdvText 0, 50, ControlHelp2, 0, 0, 1
|
||||
Case DrawModeFrame
|
||||
; Control
|
||||
If KeyHit(16) Then ModeFrame_Image = DiffuseSheet
|
||||
If KeyHit(17) Then ModeFrame_Image = NormalSheet
|
||||
If KeyHit(30) Then ModeFrame_Frame = ModeFrame_Frame - 1
|
||||
If KeyHit(32) Then ModeFrame_Frame = ModeFrame_Frame + 1
|
||||
|
||||
If ModeFrame_Frame < 0 Then ModeFrame_Frame = CfgPitchFrames * CfgYawFrames - 1
|
||||
If ModeFrame_Frame = (CfgPitchFrames * CfgYawFrames) Then ModeFrame_Frame = 0
|
||||
|
||||
; Render
|
||||
DrawImage ModeFrame_Image, GraphicsWidth() / 2 - ImageWidth(ModeFrame_Image) / 2, GraphicsHeight() / 2 - ImageHeight(ModeFrame_Image) / 2, ModeFrame_Frame
|
||||
|
||||
; Show Help
|
||||
AdvText 0, 50, ControlHelp3, 0, 0, 1
|
||||
Case DrawMode3D
|
||||
; Control
|
||||
If KeyHit(16) Then
|
||||
HideEntity Mode3D_NormImp\Pivot
|
||||
ShowEntity Mode3D_DiffImp\Pivot
|
||||
EntityTexture ImpostorMesh, ImpostorDiffuse
|
||||
EndIf
|
||||
If KeyHit(17) Then
|
||||
ShowEntity Mode3D_NormImp\Pivot
|
||||
HideEntity Mode3D_DiffImp\Pivot
|
||||
EntityTexture ImpostorMesh, ImpostorNormal
|
||||
EndIf
|
||||
|
||||
If MouseDown(1) And MouseHit(1)
|
||||
MoveMouse 512, 384
|
||||
ElseIf MouseDown(1)
|
||||
Mode3D_Pitch = Math_MaxMin(Mode3D_Pitch + MouseYSpeed() / 15.0, 90, -90)
|
||||
Mode3D_Yaw = Mode3D_Yaw + MouseXSpeed() / 15.0
|
||||
RotateEntity Mode3D_Pivot, Mode3D_Pitch, Mode3D_Yaw, 0, 1
|
||||
RotateEntity CameraPivot, Mode3D_Pitch, Mode3D_Yaw, 0, 1
|
||||
MoveMouse 512, 384
|
||||
EndIf
|
||||
|
||||
If MouseDown(2) And MouseHit(2)
|
||||
MoveMouse 512, 384
|
||||
ElseIf MouseDown(2)
|
||||
MoveEntity Mode3D_Camera, 0, 0, (MouseXSpeed() - MouseYSpeed()) / 15.0
|
||||
MoveMouse 512, 384
|
||||
EndIf
|
||||
|
||||
; Show Help
|
||||
AdvText 0, 50, ControlHelp4, 0, 0, 1
|
||||
End Select
|
||||
|
||||
; Switch Mode Hotkeys
|
||||
If KeyHit(2) Then DrawMode = DrawModeSheet
|
||||
If KeyHit(3) Then DrawMode = DrawModeFrame
|
||||
If KeyHit(4) Then DrawMode = DrawMode3D
|
||||
|
||||
Flip 0
|
||||
WaitTimer Timer
|
||||
Wend
|
||||
|
||||
Function Math_MaxMin#(Value#, Max#, Min#)
|
||||
If Value> Max Then Return Max
|
||||
If Value < Min Then Return Min
|
||||
Return Value
|
||||
End Function
|
||||
Function Math_Max#(Value#, Max#)
|
||||
If Value> Max Then Return Max
|
||||
Return Value
|
||||
End Function
|
||||
Function Math_Min#(Value#, Min#)
|
||||
If Value < Min Then Return Min
|
||||
Return Value
|
||||
End Function
|
||||
Function Math_Clip#(Value#, Low#, High#)
|
||||
Local Out#, Diff#
|
||||
Diff = High-Low:Out = Value-Low
|
||||
If (Out >= Diff) Then Out = Out - Floor(Out/Diff)*Diff
|
||||
If (Out < 0) Then Out = Out - Floor(Out/Diff)*Diff
|
||||
Return Low+Out
|
||||
End Function
|
||||
;~IDEal Editor Parameters:
|
||||
;~C#Blitz3D
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 94 KiB |
@@ -0,0 +1,47 @@
|
||||
Include "Impostor.bb"
|
||||
|
||||
Graphics3D 1024, 768, 32, 2
|
||||
SetBuffer BackBuffer()
|
||||
Local Timer = CreateTimer(60)
|
||||
|
||||
;Camera
|
||||
Local CamPivot = CreatePivot()
|
||||
Local Cam = CreateCamera(CamPivot)
|
||||
MoveEntity Cam, 0, 0, -20
|
||||
|
||||
; Impostor
|
||||
Local MyImp.Impostor = Impostor_Load("Cube.imp")
|
||||
;EntityFX MyImp\Mesh, 16
|
||||
MoveEntity MyImp\Mesh, 0, 0, 0
|
||||
ScaleEntity MyImp\Mesh, 10, 10, 10
|
||||
|
||||
; Base Cube
|
||||
Local Flr = CreateCube()
|
||||
MoveEntity Flr, 0, -10, 0
|
||||
ScaleEntity Flr, 10, .001, 10
|
||||
EntityColor Flr, 51, 51, 51
|
||||
|
||||
While Not KeyHit(1)
|
||||
Cls
|
||||
WireFrame KeyDown(2)
|
||||
If MouseDown(1) And MouseHit(1)
|
||||
MoveMouse 512, 384
|
||||
ElseIf MouseDown(1)
|
||||
RotateEntity CamPivot, EntityPitch(CamPivot) + MouseYSpeed() / 15.0, EntityYaw(CamPivot) + MouseXSpeed() / 15.0, 0, 1
|
||||
MoveMouse 512, 384
|
||||
EndIf
|
||||
|
||||
If MouseDown(2) And MouseHit(2)
|
||||
MoveMouse 512, 384
|
||||
ElseIf MouseDown(2)
|
||||
MoveEntity Cam, 0, 0, (MouseXSpeed() - MouseYSpeed()) / 15.0
|
||||
MoveMouse 512, 384
|
||||
EndIf
|
||||
|
||||
Impostor_Update(Cam)
|
||||
RenderWorld
|
||||
|
||||
Flip 0:WaitTimer Timer
|
||||
Wend
|
||||
;~IDEal Editor Parameters:
|
||||
;~C#Blitz3D
|
||||
@@ -0,0 +1,496 @@
|
||||
; Include file for FastExt v1.17 library
|
||||
; (c) 2006-2010 created by MixailV aka Monster^Sage [monster-sage@mail.ru] http://www.fastlibs.com
|
||||
|
||||
|
||||
|
||||
Const FE_VERSION$ = "1.17"
|
||||
|
||||
|
||||
|
||||
; íîâûå êîíñòàíòû äëÿ ñîçäàíèÿ òåêñòóðû (ôóíêöèÿ CreateTexture)
|
||||
; New constants for texture creating (CreateTexture function only)
|
||||
Const FE_ExSIZE = 2048
|
||||
Const FE_RENDER = 4096
|
||||
Const FE_ZRENDER = 8192
|
||||
|
||||
|
||||
; íîâûå êîíñòàíòû äëÿ FX ( ôóíêöèè EntityFX èëè BrushFX )
|
||||
; New constants for brush Fx ( EntityFX or BrushFX functions only)
|
||||
Const FE_WIRE = 64 ; ðèñóþòñÿ òîëüêî ëèíèè
|
||||
Const FE_POINT = 128 ; ðèñóþòñÿ òîëüêî òî÷êè
|
||||
|
||||
|
||||
; Êîíñòàíòû äëÿ ôóíêöèè RenderPostprocess
|
||||
; RenderPostprocess function constants
|
||||
Const FE_DOF = 1
|
||||
Const FE_Glow = 2
|
||||
Const FE_Blur = 4
|
||||
Const FE_Inverse = 8
|
||||
Const FE_Grayscale = 16
|
||||
Const FE_Contrast = 32
|
||||
Const FE_BlurDirectional = 64
|
||||
Const FE_BlurZoom = 128
|
||||
Const FE_BlurSpin = 256
|
||||
Const FE_BlurMotion = 512
|
||||
Const FE_Overlay = 1024
|
||||
Const FE_Posterize = 2048
|
||||
Const FE_Rays = 4096
|
||||
|
||||
|
||||
; -------------------- DirectX7 constants (only for TextureBlendCustom function) -----------------------
|
||||
; Control
|
||||
Const D3DTOP_DISABLE = 1 ; disables stage
|
||||
Const D3DTOP_SELECTARG1 = 2 ; the Default
|
||||
Const D3DTOP_SELECTARG2 = 3
|
||||
|
||||
; Modulate
|
||||
Const D3DTOP_MODULATE = 4 ; multiply args together
|
||||
Const D3DTOP_MODULATE2X = 5 ; multiply And 1 bit
|
||||
Const D3DTOP_MODULATE4X = 6 ; multiply And 2 bits
|
||||
|
||||
; Add
|
||||
Const D3DTOP_ADD = 7 ; add arguments together
|
||||
Const D3DTOP_ADDSIGNED = 8 ; add With -0.5 bias
|
||||
Const D3DTOP_ADDSIGNED2X = 9 ; As above but left 1 bit
|
||||
Const D3DTOP_SUBTRACT = 10 ; Arg1 - Arg2, With no saturation
|
||||
Const D3DTOP_ADDSMOOTH = 11 ; add 2 args, subtract product Arg1 + Arg2 - Arg1*Arg2 = Arg1 + (1-Arg1)*Arg2
|
||||
|
||||
; Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha)
|
||||
Const D3DTOP_BLENDDIFFUSEALPHA = 12 ; iterated alpha
|
||||
Const D3DTOP_BLENDTEXTUREALPHA = 13 ; texture alpha
|
||||
Const D3DTOP_BLENDFACTORALPHA = 14 ; alpha from D3DRENDERSTATE_TEXTUREFACTOR Linear alpha blend With pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha)
|
||||
Const D3DTOP_BLENDTEXTUREALPHAPM = 15 ; texture alpha
|
||||
Const D3DTOP_BLENDCURRENTALPHA = 16 ; by alpha of current color
|
||||
|
||||
; Specular mapping
|
||||
Const D3DTOP_PREMODULATE = 17 ; modulate With Next texture before use
|
||||
Const D3DTOP_MODULATEALPHA_ADDCOLOR = 18 ; Arg1.RGB + Arg1.A*Arg2.RGB COLOROP only
|
||||
Const D3DTOP_MODULATECOLOR_ADDALPHA = 19 ; Arg1.RGB*Arg2.RGB + Arg1.A COLOROP only
|
||||
Const D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20 ; (1-Arg1.A)*Arg2.RGB + Arg1.RGB COLOROP only
|
||||
Const D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21 ; (1-Arg1.RGB)*Arg2.RGB + Arg1.A COLOROP only
|
||||
|
||||
; Bump mapping
|
||||
Const D3DTOP_BUMPENVMAP = 22 ; per pixel env map perturbation
|
||||
Const D3DTOP_BUMPENVMAPLUMINANCE = 23 ; With luminance channel
|
||||
; This can do either diffuse Or specular bump mapping With correct input.
|
||||
; Performs the function (Arg1.R*Arg2.R + Arg1.G*Arg2.G + Arg1.B*Arg2.B)
|
||||
; where each component has been scaled And offset To make it signed.
|
||||
; The result is replicated into all four (including alpha) channels.
|
||||
; This is a valid COLOROP only.
|
||||
Const D3DTOP_DOTPRODUCT3 = 24
|
||||
|
||||
Const FETOP_PROJECT = $010000 ; FastExt constant for 2D projective texturing TextureCoords=0 (UV0)
|
||||
Const FETOP_PROJECT0 = $010000 ; FastExt constant for 2D projective texturing TextureCoords=0 (UV0)
|
||||
Const FETOP_PROJECT1 = $020000 ; FastExt constant for 2D projective texturing TextureCoords=1 (UV1)
|
||||
|
||||
Const FETOP_PROJECT3D = $050000 ; FastExt constant for 3D projective texturing TextureCoords=0 (UV0)
|
||||
Const FETOP_PROJECT3D0 = $050000 ; FastExt constant for 3D projective texturing TextureCoords=0 (UV0)
|
||||
Const FETOP_PROJECT3D1 = $060000 ; FastExt constant for 3D projective texturing TextureCoords=1 (UV1)
|
||||
|
||||
|
||||
|
||||
; -------------------- DirectX7 constants (only for EntityBlendCustom & BrushBlendCustom functions) -----------------------
|
||||
Const D3DBLEND_ZERO = 1
|
||||
Const D3DBLEND_ONE = 2
|
||||
Const D3DBLEND_SRCCOLOR = 3
|
||||
Const D3DBLEND_INVSRCCOLOR = 4
|
||||
Const D3DBLEND_SRCALPHA = 5
|
||||
Const D3DBLEND_INVSRCALPHA = 6
|
||||
Const D3DBLEND_DESTALPHA = 7
|
||||
Const D3DBLEND_INVDESTALPHA = 8
|
||||
Const D3DBLEND_DESTCOLOR = 9
|
||||
Const D3DBLEND_INVDESTCOLOR = 10
|
||||
Const D3DBLEND_SRCALPHASAT = 11
|
||||
Const D3DBLEND_BOTHSRCALPHA = 12
|
||||
Const D3DBLEND_BOTHINVSRCALPHA = 13
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; íîâûå êîíñòàíòû äëÿ òåêñòóðíûõ ñìåøèâàíèé (ôóíêöèÿ TextureBlend)
|
||||
; New constants for texture stage blending (TextureBlend function)
|
||||
Const FE_ALPHACURRENT = (D3DTOP_BLENDCURRENTALPHA Shl 8) Or D3DTOP_SELECTARG1 ; = $1002 ïðîçðà÷íîñòü ïðåäûäóùåé òåêñòóðû äëÿ òåêóùåé
|
||||
Const FE_ALPHAMODULATE = (D3DTOP_MODULATE Shl 8) Or D3DTOP_MODULATE ; = $0404 óìíîæåíèå ïðîçðà÷íîñòè (èñïîëüçóåì åùå è òåêóùóþ ïðîçðà÷íîñòü)
|
||||
Const FE_BUMP = (D3DTOP_BUMPENVMAP Shl 8) Or D3DTOP_SELECTARG2 ; = $1603 òåêñòóðà èñêàæåíèé
|
||||
Const FE_BUMPLUM = (D3DTOP_BUMPENVMAPLUMINANCE Shl 8) Or D3DTOP_SELECTARG2 ; = $1703 òåêñòóðà èñêàæåíèé + êàíàë ÿðêîñòè
|
||||
Const FE_PROJECT = FETOP_PROJECT Or (D3DTOP_MODULATE Shl 8) Or D3DTOP_MODULATE ; = $010404 òåêñòóðà íàêëàäûâàåòñÿ êàê ïðîåêöèÿ (óìíîæåíèåì)
|
||||
Const FE_PROJECTSMOOTH = FETOP_PROJECT Or (D3DTOP_ADDSMOOTH Shl 8) Or D3DTOP_MODULATE ; = $010B04 òåêñòóðà íàêëàäûâàåòñÿ êàê ïðîåêöèÿ (ïëàâíûì ñëîæåíèåì)
|
||||
Const FE_MULTIPLY4X = (D3DTOP_MODULATE4X Shl 8)
|
||||
Const FE_ADDSIGNED = (D3DTOP_ADDSIGNED Shl 8)
|
||||
Const FE_ADDSIGNED2X = (D3DTOP_ADDSIGNED2X Shl 8)
|
||||
Const FE_ADDSMOOTH = (D3DTOP_ADDSMOOTH Shl 8)
|
||||
Const FE_SUB = (D3DTOP_SUBTRACT Shl 8)
|
||||
Const FE_SPECULAR0 = (D3DTOP_MODULATEALPHA_ADDCOLOR Shl 8)
|
||||
Const FE_SPECULAR1 = (D3DTOP_MODULATECOLOR_ADDALPHA Shl 8)
|
||||
Const FE_SPECULAR2 = (D3DTOP_MODULATEINVALPHA_ADDCOLOR Shl 8)
|
||||
Const FE_SPECULAR3 = (D3DTOP_MODULATEINVCOLOR_ADDALPHA Shl 8)
|
||||
|
||||
|
||||
|
||||
|
||||
; íîâûå êîíñòàíòû äëÿ áðàø (åíòèòè) ñìåøèâàíèé (ôóíêöèÿ BrushBlend è EntityBlend)
|
||||
; New constants for brush (entity) blending (BrushBlend and EntityBlend function)
|
||||
Const FE_INVALPHA = $010605
|
||||
Const FE_INVCOLOR = $010406
|
||||
Const FE_INVCOLORADD = $010402
|
||||
Const FE_NOALPHA = $000101
|
||||
|
||||
|
||||
|
||||
|
||||
; ãëîáàëüíûé òèï äëÿ ïîëó÷åíèÿ âîçìîæíîñòåé âèäåî-äðàéâåðà
|
||||
; Global type for Gfx-driver capabilities
|
||||
Type GfxDriverCapsEx_Type
|
||||
Field BrushBlendsSrc%
|
||||
Field BrushBlendsDest%
|
||||
Field TextureCaps%
|
||||
Field TextureBlends%
|
||||
Field TextureMaxStages%
|
||||
Field TextureMaxWidth%
|
||||
Field TextureMaxHeight%
|
||||
Field TextureMaxAspectRatio%
|
||||
Field ClipplanesMax%
|
||||
Field LightsMax%
|
||||
Field Bump%
|
||||
Field BumpLum%
|
||||
Field AnisotropyMax%
|
||||
End Type
|
||||
Global GfxDriverCapsEx.GfxDriverCapsEx_Type = New GfxDriverCapsEx_Type
|
||||
|
||||
|
||||
|
||||
|
||||
Type Matrix3D
|
||||
Field m11#, m12#, m13#, m14#
|
||||
Field m21#, m22#, m23#, m24#
|
||||
Field m31#, m32#, m33#, m34#
|
||||
Field m41#, m42#, m43#, m44#
|
||||
End Type
|
||||
|
||||
|
||||
|
||||
|
||||
; library system vars
|
||||
Global FE_PivotSys% = 0
|
||||
Global FE_InitExtFlag% = 0
|
||||
Global FE_InitPostprocessFlag% = 0
|
||||
Global FE_PostprocessTexture1% = 0
|
||||
Global FE_PostprocessTexture2% = 0
|
||||
Global FE_PostprocessTexture3% = 0
|
||||
Global FE_PostprocessTexture4% = 0
|
||||
Global FE_PostprocessTexture5% = 0
|
||||
|
||||
|
||||
|
||||
; ãëàâíàÿ ôóíêöèÿ èíèöèàëèçàöèè áèáëèîòåêè, îáÿçàòåëüíî çàïóñêàåòñÿ ïîñëå êîìàíäû Graphics3D
|
||||
; Main function for library initialising, must call after command Graphics3D
|
||||
|
||||
Function InitExt% ()
|
||||
If FE_VERSION<>ExtVersion() Then
|
||||
RuntimeError "ERROR! FastExstension library - Incorrect versions for FastExt.dll (v"+ExtVersion()+") And FastExt.bb (v"+FE_VERSION+")"
|
||||
Else
|
||||
DebugLog "Init FastExtension library v"+FE_VERSION+"successful"
|
||||
EndIf
|
||||
If FE_InitExtFlag=0 Then
|
||||
FE_InitExtFlag = 1
|
||||
FE_PivotSys = CreatePivot()
|
||||
DeInitPostprocess()
|
||||
InitExt_ ( SystemProperty("Direct3DDevice7"), BackBuffer(), GfxDriverCapsEx )
|
||||
EndIf
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
; ôóíêöèÿ äëÿ ðåíäåðèíãà îäíîãî åíòèòè (âñå åãî ÷èëäû òîæå áóäóò îòðåíäåðåíû, åñëè íå ñêðûòû)
|
||||
; Function for render single entity or entity with childrens
|
||||
Function RenderEntity% (entity%, camera%, clearViewport%=0, tween#=1.0)
|
||||
Return RenderEntity_ (entity, camera, tween, clearViewport, FE_PivotSys)
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
; ôóíêöèÿ äëÿ ðåíäåðèíãà ãðóïïû åíòèòåé (âñå åãî ÷èëäû òîæå áóäóò îòðåíäåðåíû, åñëè íå ñêðûòû)
|
||||
; Function for render group of entities (with childrens, if not hidden)
|
||||
Function RenderGroup% (group%, camera%, clearViewport%=0, tween#=1.0)
|
||||
Return RenderGroup_ (group, camera, tween, clearViewport, FE_PivotSys)
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Function TextureAnisotropy% (level%=0, index%=-1)
|
||||
Return TextureAnisotropy_ (level, index)
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Function TextureLodBias% (bias#=-0.2, index%=-1)
|
||||
Return TextureLodBias_ (bias, index)
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
; Äîïîëüíèòåëüíûå ôóíêöèè äëÿ ÊëèïÏëåéíîâ
|
||||
; Additional functions for ClipPlanes
|
||||
|
||||
Function CreateClipplane% (entity%=0, x1#=0, y1#=0, z1#=0, x2#=0, y2#=0, z2#=1, x3#=1, y3#=0, z3#=0)
|
||||
If entity<>0 Then
|
||||
TFormPoint 0, 0, 0,entity,0 : x1 = TFormedX() : y1 = TFormedY() : z1 = TFormedZ()
|
||||
TFormPoint 0, 0, 1,entity,0 : x2 = TFormedX() : y2 = TFormedY() : z2 = TFormedZ()
|
||||
TFormPoint 1, 0, 0,entity,0 : x3 = TFormedX() : y3 = TFormedY() : z3 = TFormedZ()
|
||||
EndIf
|
||||
Return CreateClipplane_ ( x1, y1, z1, x2, y2, z2, x3, y3, z3 )
|
||||
End Function
|
||||
|
||||
Function AlignClipplane% (plane%, entity%=0, x1#=0, y1#=0, z1#=0, x2#=0, y2#=0, z2#=1, x3#=1, y3#=0, z3#=0)
|
||||
If entity<>0 Then
|
||||
TFormPoint 0, 0, 0,entity,0 : x1 = TFormedX() : y1 = TFormedY() : z1 = TFormedZ()
|
||||
TFormPoint 0, 0, 1,entity,0 : x2 = TFormedX() : y2 = TFormedY() : z2 = TFormedZ()
|
||||
TFormPoint 1, 0, 0,entity,0 : x3 = TFormedX() : y3 = TFormedY() : z3 = TFormedZ()
|
||||
EndIf
|
||||
Return AlignClipplane_ ( plane, x1, y1, z1, x2, y2, z2, x3, y3, z3 )
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
|
||||
; Äîïîëüíèòåëüíûå ôóíêöèè äëÿ Êàìåðû
|
||||
; Additional functions for Camera
|
||||
|
||||
Global MirrorCameraLast% = 0
|
||||
Global MirrorCameraX# = 0
|
||||
Global MirrorCameraY# = 0
|
||||
Global MirrorCameraZ# = 0
|
||||
Global MirrorCameraAX# = 0
|
||||
Global MirrorCameraAY# = 0
|
||||
Global MirrorCameraAZ# = 0
|
||||
Global MirrorCameraParent% = 0
|
||||
|
||||
Function MirrorCamera% (camera%=0, entity%=0)
|
||||
If camera<>0 Then
|
||||
MirrorCameraLast = camera
|
||||
MirrorCameraX# = EntityX(camera,1)
|
||||
MirrorCameraY# = EntityY(camera,1)
|
||||
MirrorCameraZ# = EntityZ(camera,1)
|
||||
MirrorCameraAX# = EntityPitch(camera,1)
|
||||
MirrorCameraAY# = EntityYaw(camera,1)
|
||||
MirrorCameraAZ# = EntityRoll(camera,1)
|
||||
If entity<>0 Then
|
||||
MirrorCameraParent = ParentEntity(camera)
|
||||
EntityParent camera, entity, 1
|
||||
PositionEntity camera, EntityX(camera), -EntityY(camera), EntityZ(camera)
|
||||
RotateEntity camera, -EntityPitch(camera), EntityYaw(camera), -EntityRoll(camera)
|
||||
EntityParent camera,0,1
|
||||
Else
|
||||
PositionEntity camera, MirrorCameraX, -MirrorCameraY, MirrorCameraZ, 1
|
||||
RotateEntity camera, -MirrorCameraAX, MirrorCameraAY, -MirrorCameraAZ, 1
|
||||
EndIf
|
||||
EndIf
|
||||
End Function
|
||||
|
||||
Function RestoreCamera% (camera%=0)
|
||||
If camera=0 Then camera=MirrorCameraLast
|
||||
If camera<>0 Then
|
||||
PositionEntity camera, MirrorCameraX, MirrorCameraY, MirrorCameraZ, 1
|
||||
RotateEntity camera, MirrorCameraAX, MirrorCameraAY, MirrorCameraAZ, 1
|
||||
If MirrorCameraParent<>0 Then EntityParent camera, MirrorCameraParent, 1
|
||||
EndIf
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
|
||||
; ñòàðûå ôóíêöèè òåïåðü ñ íîâûìè âîçìîæíîñòÿìè
|
||||
; Old functions with NEW capabilities
|
||||
|
||||
Function SetBuffer% (buffer%)
|
||||
Return SetBuffer_ (buffer)
|
||||
End Function
|
||||
|
||||
Function GetBuffer% ()
|
||||
Return SetBuffer_ (-1)
|
||||
End Function
|
||||
|
||||
Function ClsColor% (red%, green%, blue%, alpha%=$FF, zValue#=1.0)
|
||||
Return ClsColor_ (red, green, blue, alpha, zValue)
|
||||
End Function
|
||||
|
||||
Function Cls% (clearColor%=1, clearZBuffer%=1)
|
||||
Return Cls_ (clearColor, clearZBuffer)
|
||||
End Function
|
||||
|
||||
Function WireFrame% (enable%=0)
|
||||
Return Wireframe_ (enable)
|
||||
End Function
|
||||
|
||||
Function Bump% (enable%=-1)
|
||||
Return Bump_ (enable)
|
||||
End Function
|
||||
|
||||
Function FreeTexture% (texture%)
|
||||
If texture<>0 Then
|
||||
Return FreeTexture_ (texture, TextureBuffer(texture))
|
||||
Else
|
||||
Return 0
|
||||
EndIf
|
||||
End Function
|
||||
|
||||
Function ColorFilter% (red%=1, green%=1, blue%=1, alpha%=1)
|
||||
Return ColorFilter_ (red, green, blue, alpha)
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
|
||||
Function TextureBlend% (texture%, blend%)
|
||||
TextureBlend_ texture, blend
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
; íîâûå ôóíêöèÿ äëÿ çàäàíèÿ ÑÂÎÈÕ òåêñòóðíûõ ñìåøèâàíèé (èñïîëüçóéòå òîëüêî D3DTOP_* êîíñòàíòû, ñì. èõ íèæå)
|
||||
; New function for custom texture blending (use D3DTOP_* constans only, see below)
|
||||
|
||||
Function TextureBlendCustom% (texture%, color_operation%, alpha_operation%=0, projection_flag%=0)
|
||||
If color_operation>24 Then color_operation=24
|
||||
If color_operation<1 Then color_operation=1
|
||||
If alpha_operation>24 Then alpha_operation=24
|
||||
If alpha_operation<0 Then alpha_operation=0
|
||||
projection_flag = projection_flag And $7
|
||||
TextureBlend texture, (projection_flag Shl 16) Or (color_operation Shl 8) Or alpha_operation
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
; íîâûå ôóíêöèè äëÿ ñîçäàíèÿ ÑÂÎÈÕ ñìåøèâàíèé ïðè ðåíäåðå îáúåêòîâ (èñïîëüçóéòå òîëüêî D3DBLEND_* êîíñòàíòû, ñì. èõ íèæå)
|
||||
; New functions for custom entity (brush) blending (use D3DBLEND_* constans only, see below)
|
||||
|
||||
Function EntityBlendCustom% (entity%, source_blend%=1, destination_blend%=1, alphablending_enable%=0)
|
||||
If source_blend>13 Then source_blend=13
|
||||
If source_blend<1 Then source_blend=1
|
||||
If destination_blend>13 Then destination_blend=13
|
||||
If destination_blend<1 Then destination_blend=1
|
||||
If alphablending_enable<>0 Then alphablending_enable=1
|
||||
EntityBlend entity, (alphablending_enable Shl 16) Or (source_blend Shl 8) Or destination_blend
|
||||
End Function
|
||||
|
||||
Function BrushBlendCustom% (brush%, source_blend%=1, destination_blend%=1, alphablending_enable%=0)
|
||||
If source_blend>13 Then source_blend=13
|
||||
If source_blend<1 Then source_blend=1
|
||||
If destination_blend>13 Then destination_blend=13
|
||||
If destination_blend<1 Then destination_blend=1
|
||||
If alphablending_enable<>0 Then alphablending_enable=1
|
||||
BrushBlend brush, (alphablending_enable Shl 16) Or (source_blend Shl 8) Or destination_blend
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Function ExecAndExit% (file$="", command$="", workingDir$="")
|
||||
ExecAndExit_ file, command, workingDir
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
|
||||
Function InitPostprocess% ()
|
||||
Local CurrentBuffer%, smallWidth%, smallHeight%
|
||||
If FE_InitPostprocessFlag=0
|
||||
smallWidth = GraphicsWidth()/3 : smallHeight = GraphicsHeight()/3
|
||||
FE_PostprocessTexture1 = CreateTexture ( GraphicsWidth(), GraphicsHeight(), 1 + 256 + FE_ExSIZE + FE_RENDER + FE_ZRENDER )
|
||||
FE_PostprocessTexture2 = CreateTexture ( smallWidth, smallHeight, 1 + 256 + FE_ExSIZE + FE_RENDER )
|
||||
FE_PostprocessTexture3 = CreateTexture ( 16, 16, 1 )
|
||||
FE_PostprocessTexture4 = CreateTexture ( smallWidth, smallHeight, 1 + 256 + FE_ExSIZE + FE_RENDER )
|
||||
FE_PostprocessTexture5 = CreateTexture ( GraphicsWidth(), GraphicsHeight(), 1 + 256 + FE_ExSIZE ) ; comment this string if MotionBlur not needed (not used)
|
||||
|
||||
CurrentBuffer = SetBuffer (TextureBuffer(FE_PostprocessTexture3))
|
||||
ClsColor 255,255,255 : Cls : SetBuffer BackBuffer()
|
||||
If InitPostprocess_ (BackBuffer(), TextureBuffer(FE_PostprocessTexture1), TextureBuffer(FE_PostprocessTexture2), TextureBuffer(FE_PostprocessTexture3), TextureBuffer(FE_PostprocessTexture4), TextureBuffer(FE_PostprocessTexture5))<>0 Then
|
||||
FE_InitPostprocessFlag = 1
|
||||
Else
|
||||
If FE_PostprocessTexture1<>0 Then FreeTexture FE_PostprocessTexture1
|
||||
If FE_PostprocessTexture2<>0 Then FreeTexture FE_PostprocessTexture2
|
||||
If FE_PostprocessTexture3<>0 Then FreeTexture FE_PostprocessTexture3
|
||||
If FE_PostprocessTexture4<>0 Then FreeTexture FE_PostprocessTexture4
|
||||
If FE_PostprocessTexture5<>0 Then FreeTexture FE_PostprocessTexture5
|
||||
EndIf
|
||||
SetBuffer CurrentBuffer
|
||||
EndIf
|
||||
Return FE_InitPostprocessFlag
|
||||
End Function
|
||||
|
||||
Function DeInitPostprocess% ()
|
||||
If FE_InitPostprocessFlag<>0 Then
|
||||
If FE_PostprocessTexture1<>0 Then FreeTexture FE_PostprocessTexture1
|
||||
If FE_PostprocessTexture2<>0 Then FreeTexture FE_PostprocessTexture2
|
||||
If FE_PostprocessTexture3<>0 Then FreeTexture FE_PostprocessTexture3
|
||||
If FE_PostprocessTexture4<>0 Then FreeTexture FE_PostprocessTexture4
|
||||
If FE_PostprocessTexture5<>0 Then FreeTexture FE_PostprocessTexture5
|
||||
FE_InitPostprocessFlag = 0
|
||||
EndIf
|
||||
End Function
|
||||
|
||||
Function RenderPostprocess% (flags%=0, x%=0, y%=0, width%=0, height%=0)
|
||||
If InitPostprocess()<>0 Then RenderPostprocess_ flags, x, y, width, height
|
||||
End Function
|
||||
|
||||
Function CustomPostprocessDOF% (near#=10.0, far#=100.0, direction%=1, level%=3, blurRadius#=0.35, quality%=1)
|
||||
CustomPostprocessDOF_ near, far, direction, level, blurRadius, quality
|
||||
End Function
|
||||
|
||||
Function CustomPostprocessGlow% (alpha#=1.0, darkPasses%=2, blurPasses%=4, blurRadius#=0.35, quality%=1, red%=255, green%=255, blue%=255, alphaTexture%=0)
|
||||
CustomPostprocessGlow_ alpha, darkPasses, blurPasses, blurRadius, quality, red, green, blue, alphaTexture
|
||||
End Function
|
||||
|
||||
Function CustomPostprocessBlur% (alpha#=1.0, blurPasses%=4, blurRadius#=0.35, quality%=1, red%=255, green%=255, blue%=255, alphaTexture%=0)
|
||||
CustomPostprocessBlur_ alpha, blurPasses, blurRadius, quality, red, green, blue, alphaTexture
|
||||
End Function
|
||||
|
||||
Function CustomPostprocessInverse% (alpha#=1.0, red%=255, green%=255, blue%=255, alphaTexture%=0)
|
||||
CustomPostprocessInverse_ alpha, red, green, blue, alphaTexture
|
||||
End Function
|
||||
|
||||
Function CustomPostprocessGrayscale% (alpha#=1.0, brightness#=1.0, inverse%=0, alphaTexture%=0)
|
||||
CustomPostprocessGrayscale_ alpha, brightness, inverse, alphaTexture
|
||||
End Function
|
||||
|
||||
Function CustomPostprocessContrast% (alpha#=1.0, method%=0, red%=255, green%=255, blue%=255, alphaTexture%=0)
|
||||
CustomPostprocessContrast_ alpha#, method, red, green, blue, alphaTexture
|
||||
End Function
|
||||
|
||||
Function CustomPostprocessBlurDirectional% (angle#=0, alpha#=1, blurPasses%=4, blurRadius#=0.35, quality%=1, red%=255, green%=255, blue%=255, alphaTexture%=0)
|
||||
CustomPostprocessBlurDirectional_ angle, alpha, blurPasses, blurRadius, quality, red, green, blue, alphaTexture
|
||||
End Function
|
||||
|
||||
Function CustomPostprocessBlurZoom% (x#=0.5, y#=0.5, zoomFactor#=105, alpha#=1, blurPasses%=4, quality%=1, red%=255, green%=255, blue%=255, alphaTexture%=0)
|
||||
CustomPostprocessBlurZoom_ x, y, zoomFactor, alpha, blurPasses, quality, red, green, blue, alphaTexture
|
||||
End Function
|
||||
|
||||
Function CustomPostprocessBlurSpin% (x#=0.5, y#=0.5, spinAngle#=4, alpha#=1, blurPasses%=4, quality%=1, red%=255, green%=255, blue%=255, alphaTexture%=0)
|
||||
CustomPostprocessBlurSpin_ x, y, spinAngle, alpha, blurPasses, quality, red, green, blue, alphaTexture
|
||||
End Function
|
||||
|
||||
Function CustomPostprocessBlurMotion% (alpha#=0.9, originX#=0, originY#=0, handleX#=0.5, handleY#=0.5, scaleX#=100, scaleY#=100, angle#=0, blend%=0, red%=255, green%=255, blue%=255, alphaTexture%=0)
|
||||
CustomPostprocessBlurMotion_ alpha, originX, originY, handleX, handleY, scaleX, scaleY, angle, blend, red, green, blue, alphaTexture
|
||||
End Function
|
||||
|
||||
Function CustomPostprocessOverlay% (alpha#=0.5, blend%=0, red%=255, green%=255, blue%=255, alphaTexture%=0)
|
||||
CustomPostprocessOverlay_ alpha, blend, red, green, blue, alphaTexture
|
||||
End Function
|
||||
|
||||
Function CustomPostprocessRays% (centerX#=0.5, centerY#=0.5, zoomFactor#=105, alpha#=1, darkPasses%=2, blurPasses%=4, quality%=1, red%=255, green%=255, blue%=255, alphaTexture%=0)
|
||||
CustomPostprocessRays_% (centerX, centerY, zoomFactor, alpha, darkPasses, blurPasses, quality, red, green, blue, alphaTexture)
|
||||
End Function
|
||||
|
||||
|
||||
Function DeInitExt% ()
|
||||
If FE_InitExtFlag<>0 Then
|
||||
FE_InitExtFlag = 0
|
||||
SetBuffer BackBuffer()
|
||||
FreeEntity FE_PivotSys
|
||||
DeInitPostprocess
|
||||
DeInitExt_
|
||||
EndIf
|
||||
End Function
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,122 @@
|
||||
Const ImpostorVariant = 0
|
||||
|
||||
Type Impostor
|
||||
Field Frames%
|
||||
Field FrameWidth%, FrameHeight%
|
||||
Field PitchFrames%, PitchMin#, PitchMax#
|
||||
Field YawFrames%, YawMin#, YawMax#
|
||||
Field Sheet%
|
||||
|
||||
Field Pivot%, Parent%
|
||||
Field Mesh%, Surface%
|
||||
|
||||
Field YawStep#, PitchStep#
|
||||
End Type
|
||||
|
||||
Function Impostor_Init.Impostor(Parent%=0)
|
||||
Local Instance.Impostor = New Impostor
|
||||
Instance\Pivot = CreatePivot(Parent)
|
||||
Instance\Mesh = CreateMesh(Instance\Pivot)
|
||||
Instance\Surface = CreateSurface(Instance\Mesh)
|
||||
Local V0,V1,V2,V3
|
||||
V0 = AddVertex(Instance\Surface, -1, 1, 0, 1, 0, 0)
|
||||
V1 = AddVertex(Instance\Surface, 1, 1, 0, 0, 0, 0)
|
||||
V2 = AddVertex(Instance\Surface, -1, -1, 0, 1, 1, 0)
|
||||
V3 = AddVertex(Instance\Surface, 1, -1, 0, 0, 1, 0)
|
||||
AddTriangle Instance\Surface, V0, V2, V1
|
||||
AddTriangle Instance\Surface, V1, V2, V3
|
||||
Return Instance
|
||||
End Function
|
||||
|
||||
Function Impostor_Load.Impostor(Path$, Flags%=1+4+16+32+256+512, Parent%=0)
|
||||
If FileType(Path) <> 1 Then
|
||||
RuntimeError "Impostor: Given <Path$> is not a file."
|
||||
Else
|
||||
Local Stream = ReadFile(Path)
|
||||
If Stream = 0 Then
|
||||
RuntimeError "Impostor: Unable to open given <Path$>."
|
||||
Else
|
||||
Local Instance.Impostor = Impostor_Init(Parent)
|
||||
|
||||
Instance\FrameWidth = ReadShort(Stream)
|
||||
Instance\FrameHeight = ReadShort(Stream)
|
||||
Instance\PitchFrames = ReadByte(Stream)
|
||||
Instance\PitchMin = ReadFloat(Stream)
|
||||
Instance\PitchMax = ReadFloat(Stream)
|
||||
Instance\YawFrames = ReadByte(Stream)
|
||||
Instance\YawMin = ReadFloat(Stream)
|
||||
Instance\YawMax = ReadFloat(Stream)
|
||||
|
||||
Local BaseName$ = Impostor_StripExtension(Path)
|
||||
Instance\Sheet = LoadAnimTexture(BaseName + "png", Flags, Instance\FrameWidth, Instance\FrameHeight, 0, Instance\PitchFrames * Instance\YawFrames)
|
||||
If Instance\Sheet = 0 Then RuntimeError "Impostor: Unable to open texture for given <Path$>."
|
||||
|
||||
Instance\YawStep = (Instance\YawMax - Instance\YawMin) / Instance\YawFrames
|
||||
Instance\PitchStep = (Instance\PitchMax - Instance\PitchMin) / Instance\PitchFrames
|
||||
|
||||
Return Instance
|
||||
EndIf
|
||||
EndIf
|
||||
End Function
|
||||
|
||||
Function Impostor_Create.Impostor(Mesh%, Diffuse%)
|
||||
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
Function Impostor_Update(Camera%)
|
||||
Local Instance.Impostor = Null
|
||||
For Instance = Each Impostor
|
||||
Impostor_UpdateSingle(Camera, Instance)
|
||||
Next
|
||||
End Function
|
||||
|
||||
Function Impostor_UpdateSingle(Camera%, Impostor.Impostor)
|
||||
; Calculate current Yaw frame and Pitch frame.
|
||||
PointEntity Impostor\Mesh, Camera, 0
|
||||
|
||||
Local Yaw# = Impostor_Math_MaxMin(EntityYaw(Impostor\Mesh), Impostor\YawMax, Impostor\YawMin) - Impostor\YawMin
|
||||
Local Pitch# = Impostor_Math_MaxMin(EntityPitch(Impostor\Mesh), Impostor\PitchMax, Impostor\PitchMin) - Impostor\PitchMin
|
||||
|
||||
Local YawFrame = Int(Yaw / Impostor\YawStep)
|
||||
Local PitchFrame = Floor(Pitch / Impostor\PitchStep)
|
||||
DebugLog YawFrame
|
||||
EntityTexture Impostor\Mesh, Impostor\Sheet, PitchFrame * Impostor\YawFrames + YawFrame, 0
|
||||
EntityFX Impostor\Mesh, 16
|
||||
RotateEntity Impostor\Mesh, Impostor\PitchMin - PitchFrame * Impostor\PitchStep, 180 + Impostor\YawMin + YawFrame * Impostor\YawStep, 0
|
||||
End Function
|
||||
|
||||
Function Impostor_StripExtension$(Path$)
|
||||
Local RPath$ = Path$
|
||||
For temp_Pos = Len(Path)-1 To 1 Step -1
|
||||
If Mid(Path, temp_Pos, 1) = "."
|
||||
RPath = Left(Path, temp_Pos)
|
||||
Exit
|
||||
EndIf
|
||||
Next
|
||||
Return RPath
|
||||
End Function
|
||||
|
||||
Function Impostor_Math_MaxMin#(Value#, Max#, Min#)
|
||||
If Value> Max Then Return Max
|
||||
If Value < Min Then Return Min
|
||||
Return Value
|
||||
End Function
|
||||
Function Impostor_Math_Max#(Value#, Max#)
|
||||
If Value> Max Then Return Max
|
||||
Return Value
|
||||
End Function
|
||||
Function Impostor_Math_Min#(Value#, Min#)
|
||||
If Value < Min Then Return Min
|
||||
Return Value
|
||||
End Function
|
||||
Function Impostor_Math_Clip#(Value#, Low#, High#)
|
||||
Local Out#, Diff#
|
||||
Diff = High-Low:Out = Value-Low
|
||||
If (Out >= Diff) Then Out = Out - Floor(Out/Diff)*Diff
|
||||
If (Out < 0) Then Out = Out - Floor(Out/Diff)*Diff
|
||||
Return Low+Out
|
||||
End Function
|
||||
;~IDEal Editor Parameters:
|
||||
;~C#Blitz3D
|
||||
@@ -0,0 +1,18 @@
|
||||
[IDEal Project file]
|
||||
<Settings>
|
||||
Version="1"
|
||||
Expanded="True"
|
||||
Icon=""
|
||||
MainFile="CreateImpostorTextures.bb"
|
||||
Compiler="Blitz3D"
|
||||
CommandLine=""
|
||||
</Settings>
|
||||
<Folders>
|
||||
</Folders>
|
||||
<Files>
|
||||
AbsPath="\CreateImpostorTextures.bb" PrjFolder="" Line="0" Column="0" Tip="0" Visible="False"
|
||||
AbsPath="\Example01_Cube.bb" PrjFolder="" Line="0" Column="0" Tip="0" Visible="False"
|
||||
AbsPath="\FastExt.bb" PrjFolder="" Line="0" Column="0" Tip="0" Visible="False"
|
||||
AbsPath="\FreeImage.bb" PrjFolder="" Line="0" Column="0" Tip="0" Visible="False"
|
||||
AbsPath="\Impostor.bb" PrjFolder="" Line="0" Column="0" Tip="0" Visible="False"
|
||||
</Files>
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
@@ -0,0 +1,9 @@
|
||||
Impostor
|
||||
=======================
|
||||
|
||||
You know those distant objects that don't quite seem like a 3D object, but still turn with the view? That's an impostor, and this was supposed to be a Blitz3D implementation of that. Didn't work out as planned though, so here's the broken version that used FastExt to do its work.
|
||||
If you don't know where to get FastExt, google will help you.
|
||||
|
||||
License
|
||||
=======
|
||||
Impostor by Michael Fabian Dirks is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/.
|
||||
Reference in New Issue
Block a user