SetMeshData()
- Bananenfreak
- Enthusiast

- Posts: 519
- Joined: Mon Apr 15, 2013 12:22 pm
Re: SetMeshData()
Refering to this Topic, is it possible to use SetMeshData() with a entity which was loaded with LoadMesh()?
Re: SetMeshData()
It is no longer possible to create a mesh with SetMeshData () as before.Alexi wrote:Is it still usable to fill a mesh with a memory block? By using create mesh, it must contain at least one vertex to call FinishMesh. Without, SetMeshData won't work, but with it doesn't work too.
Is this feature removed? This could be a little Workaround to create huge geometries at realtime.
We must now use CreateMesh (). This command is more complete, it allows the addition of submesh, choose the type of mesh (point, line, triangle, etc.).
However SetMeshData () allows you to quickly modify an existing mesh, Have a look at example SetMeshData.pb
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
Re: SetMeshData()
Yes for a mesh loaded with LoadMesh().Bananenfreak wrote:Refering to this Topic, is it possible to use SetMeshData() with a entity which was loaded with LoadMesh()?
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
Re: SetMeshData()
this is making the "Barrell.mesh" more elongated. by doubling the Y
MeshData(c)\y = MeshData(c)\y * 2
i have used GetMeshData and SetMeshData
MeshData(c)\y = MeshData(c)\y * 2
i have used GetMeshData and SetMeshData
Code: Select all
Global Dim MeshData.PB_MeshVertex(0)
Global Dim MeshDataInd.PB_MeshFace(0)
Global ArrSize
Global zz.f
Enumeration
#mainwin
#mesh
#entity
#tex
#light
#camera
EndEnumeration
InitEngine3D()
InitSprite()
ExamineDesktops()
OpenWindow(#mainwin, 0, 0, DesktopWidth(0), DesktopHeight(0), "change mesh data .... press Up / Down to move camera", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#mainwin), 0, 0, DesktopWidth(0), DesktopHeight(0), 0, 0, 0)
InitKeyboard()
InitMouse()
SetFrameRate(60)
Add3DArchive(".", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Models", #PB_3DArchive_FileSystem)
CreateCamera(#camera, 0, 0, 100, 100)
MoveCamera(#camera, 0, 2, 24 )
CameraLookAt(#camera, 0, 0, 0)
CreateLight(#light,RGB(255,255,255),-100,40,30)
AmbientColor(RGB(255,255,255))
LoadTexture(#tex, "RustyBarrel.png")
CreateMaterial(#tex, TextureID(#tex))
;MaterialShadingMode(#tex, #PB_Material_Wireframe )
LoadMesh(#mesh, "Barrel.mesh")
CreateEntity(#entity, MeshID(#mesh), MaterialID(#tex))
GetMeshData(#mesh, 0, MeshData(), #PB_Mesh_Vertex, 0, MeshVertexCount(#mesh,0)-1)
ArrSize = ArraySize(MeshData())
Debug "ArraySize(MeshData()) = " + Str(ArrSize)
For c=0 To ArrSize
MeshData(c)\y = MeshData(c)\y * 2
Next c
SetMeshData(#mesh,0, MeshData(), #PB_Mesh_Vertex, 0, MeshVertexCount(#mesh,0)-1)
Repeat
Event = WindowEvent()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Down)
zz.f = 1
MoveCamera(#camera, 0, 0, zz)
ElseIf KeyboardPushed(#PB_Key_Up)
zz.f = - 1
MoveCamera(#camera, 0, 0, zz)
EndIf
yy + 1
RotateEntity(#entity, 0, yy, 0)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Event = #PB_Event_CloseWindow
- Bananenfreak
- Enthusiast

- Posts: 519
- Joined: Mon Apr 15, 2013 12:22 pm
Re: SetMeshData()
https://www.dropbox.com/sh/h4zdo3ncoi7t ... 38-JB6AGCa
There you can get a demo (It loads an one-face-mesh and bumps up every second vertexcoord).
EDIT:
Ahhh, I found something. If you start test2.pb, first call of two() works. If you comment that out and use the one in mainloop, it does nothing.
Why?
This code can only run with Cube.mesh, so download my Folder from dropbox
There you can get a demo (It loads an one-face-mesh and bumps up every second vertexcoord).
EDIT:
Ahhh, I found something. If you start test2.pb, first call of two() works. If you comment that out and use the one in mainloop, it does nothing.
Why?
This code can only run with Cube.mesh, so download my Folder from dropbox
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - SetMeshData
;
; (c) 2013 - Fantaisie Software
;
; ------------------------------------------------------------
;
IncludeFile #PB_Compiler_Home + "\Examples\3D\Screen3DRequester.pb"
#CameraSpeed = 1
#NbX=30
#NbZ=30
#Camera = 0
#Entity = 0
#Light = 0
#Material = 0
#Mesh = 0
Global.f AngleVague, WaveFrequency, WavePeriodX, WavePeriodZ, WaveAmplitude
WaveFrequency=3 ;=waves/second
WavePeriodX =9 ;=1/Wave length
WavePeriodZ =11 ;=1/Wave length
WaveAmplitude=3
Define.f KeyX, KeyY, MouseX, MouseY
Global Dim MeshData.PB_MeshVertex(0)
Declare two()
Declare CreateMatrix()
If InitEngine3D()
Add3DArchive(#PB_Compiler_Home + "\Examples\3D\Data/Textures", #PB_3DArchive_FileSystem)
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_3DArchive_FileSystem)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
;-Material
GetScriptMaterial(#Material, "Scene/GroundBlend")
MaterialCullingMode(#Material, 1)
;-Mesh
CreateMatrix()
;-Why this one makes it?
;RenderWorld()
;FlipBuffers()
;two()
;-Camera
CreateCamera(#Camera, 0, 0, 100, 100)
MoveCamera(#Camera, 0, 50, 80, #PB_Absolute)
CameraLookAt(#Camera, 0, 0, 0)
CameraBackColor(#Camera, RGB(90, 0, 0))
;-Light
CreateLight(#Light, RGB(255, 255, 255), 20, 150, 120)
AmbientColor(RGB(90, 90, 90))
;- Skybox
SkyBox("stevecube.jpg")
time0 = ElapsedMilliseconds()
Repeat
Screen3DEvents()
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
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 (#Camera, KeyX, 0, KeyY)
RotateCamera(#Camera, MouseY, MouseX, 0, #PB_Relative)
; Waves
;UpdateMatrix()
AngleVague = AngleVague+WaveFrequency
If ElapsedMilliseconds() > time0 + 2000
;-And this not?
Debug "Yeah"
two()
time0 = 9999999999999
EndIf
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
End
;-Procedures
Procedure CreateMatrix()
;CreateMesh(#Mesh)
LoadMesh(#mesh, "Cube.mesh")
;DrawMatrix()
;FinishMesh(#True)
SetMeshMaterial(#Mesh, MaterialID(#Material))
CreateEntity(#Entity, MeshID(#Mesh), #PB_Material_None)
ScaleEntity(#Entity, 20, 20, 20)
GetMeshData(#Mesh,0, MeshData(), #PB_Mesh_Vertex, 0, MeshVertexCount(#Mesh)-1)
EndProcedure
Procedure two()
Protected.i count
For count = 0 To MeshVertexCount(#Mesh)-1
If count = count /2 * 2
MeshData(count)\y = 3
EndIf
Next count
SetMeshData(#mesh, 0, MeshData(), #PB_Mesh_Vertex, 0, MeshVertexCount(#Mesh)-1)
EndProcedure