DK_PETER , i will use one of the Comtois programs which produced a waving flag shape. but look when we use a sphere thinned slightly, it is automatically become a 2D flat surface which its vertices can move up/down if it is scaled like this something like this: ScaleEntity(0, 3, 0.5, 3) with the code inside UpdateMatrix(), but not like this ScaleEntity(0, 3, 0, 3) in the second case it will be flat but we can't move its vertices up/down. this needs more investigation or i miss something or the case will change if we use a costumed sphere. in any case i think the problem of a circular plane are solved
press 'W' to see the circular liquid mesh in wireframe and will see that it is really flat 2D
Code: Select all
Enumeration
#mainwin = 10
#mat
#sphere
#sphereMat
#mirror
EndEnumeration
Structure Vector3
x.f
y.f
z.f
EndStructure
Define.Vector3 Normal, v1, v2, v3
#CameraSpeed = 1
#NbX=30
#NbZ=30
Define.f KeyX, KeyY, MouseX, MouseY
Global Dim MeshData.PB_MeshVertex(0)
Global Dim MeshDataInd.PB_MeshFace(0)
Declare UpdateMatrix()
If InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops()
OpenWindow(#mainwin, 0, 0, DesktopWidth(0), DesktopHeight(0), "press W for wire frame, press S for Solid ,____ move by keyboard and mouse", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#mainwin), 0, 0, DesktopWidth(0), DesktopHeight(0)-60, 0, 0, 0)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Packs/skybox.zip", #PB_3DArchive_Zip)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(".", #PB_3DArchive_FileSystem)
Parse3DScripts()
CreateMaterial(6,LoadTexture(6,"ground_diffuse.png"))
CreatePlane(3,1000,1000,50,50,10,10)
CreateEntity(3,MeshID(3), MaterialID(6), 0,0,0)
CreateMaterial(4, LoadTexture(4, "snow_1024.jpg"))
;-Camera
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0,0,220,180, #PB_Absolute)
CameraLookAt(0, 0, 90, 0)
CameraBackColor(0, RGB(90, 0, 0))
;-Light
CreateLight(0, RGB(255, 255, 255), 5, 15, 5)
AmbientColor(RGB(255, 255, 255))
CameraBackColor(0, RGB(0,100,100))
CreateMesh(0, #PB_Mesh_TriangleList, #True)
CreateSphere(0,20,30,30)
CreateEntity(0, MeshID(0), MaterialID(4), 0,100,0)
ScaleEntity(0, 3, 0.5, 3)
GetMeshData(0,0, MeshData(), #PB_Mesh_Vertex, 0, MeshVertexCount(0, 0)-1)
;GetMeshData(0,0, MeshDataInd(), #PB_Mesh_Face, 0, MeshIndexCount(0, 0)-1)
CreateMaterial(5,LoadTexture(5,"Geebee2.bmp"))
MaterialCullingMode(5, #PB_Material_NoCulling )
CreateCylinder(2,60,75, 16,0,0) ; the teacup
CreateEntity(2,MeshID(2), MaterialID(5), 0,100,0 )
Repeat
If ExamineKeyboard()
If KeyboardReleased(#PB_Key_W)
MaterialShadingMode(4, #PB_Material_Wireframe)
ElseIf KeyboardReleased(#PB_Key_S)
MaterialShadingMode(4, #PB_Material_Solid)
ElseIf KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
;Debug(MeshVertexCount(0, 0))
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
If ExamineMouse()
MouseX = -(MouseDeltaX()/10)
MouseY = -(MouseDeltaY()/10)
EndIf
MoveCamera (0, KeyX, 0, KeyY)
RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
; Waves
UpdateMatrix()
AngleVague = AngleVague+WaveFrequency
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
Else
MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
End
Procedure UpdateMatrix()
Protected a, b, c, i, j
Protected N.Vector3, V1.Vector3, V2.Vector3, V3.Vector3
Protected.f magSq, oneOverMag
dtime.f=ElapsedMilliseconds()/600 ; reduce 600 to get speedier animation
For b=0 To #Nbz
For a=0 To #NbX
xa.f=MeshData(c)\x
zb.f=MeshData(c)\z
;yy.f= MeshData(c)\y
;new y vertex coordinates
MeshData(c)\y=Cos(dtime + (Sqr(Pow(0.5*xa,2)+Pow(0.5*zb,2))))*2
c + 1 ; vertex number
Next a
Next b
SetMeshData(0,0, MeshData(), #PB_Mesh_Vertex | #PB_Mesh_Normal, 0, MeshVertexCount(0, 0)-1)
EndProcedure