Ogre 1.0.3 Beta available for testing
Hi Jellybean,
You probably did this: Close and restart the IDE?
I had some problems initially. One was that I had engine3d.dll in a work folder where I compiled to exe. Removing that eliminated some probs (for code in that folder)
Also, I copied my PB folder to one called PureBasic394NewOgre, set up new ogre in that, and now run PB from that folder for new 3d engine stuff.
Not sure if either of those will help you.
Edit: Clutching at straws, but did you get the data from the zip on a post some posts down (post 11) from the 1st page of this thread?
You probably did this: Close and restart the IDE?
I had some problems initially. One was that I had engine3d.dll in a work folder where I compiled to exe. Removing that eliminated some probs (for code in that folder)
Also, I copied my PB folder to one called PureBasic394NewOgre, set up new ogre in that, and now run PB from that folder for new 3d engine stuff.
Not sure if either of those will help you.
Edit: Clutching at straws, but did you get the data from the zip on a post some posts down (post 11) from the 1st page of this thread?
@}--`--,-- A rose by any other name ..
I don't know what I'm doing wrong. I'll try again.
1) I made a copy of the whole PB folder with a new name (PureBasic OGRE).
2) I extracted the files in PureLibraries from the Ogre1.0.3.zip into the PureLibraries in my new PureBasic OGRE folder. I answered yes to all overwrite prompts.
3) I extracted the Engine3D dll and the other dll into the Compilers directory. I answered yes to overwrite the Engine3D dll.
4) I extracted the Shadow.pb into Examples\Sources.
5) Started PB
6) I try to run Shadow.pb with the debugger and debug outputting the result from
Debug LoadMesh (0, "Robot.mesh")
Debug LoadTexture(0, "r2skin.jpg")
They both return 0 of course.
7) I close PB
I extract the whole OgreData.zip into Examples\Sources\Data\ answering yes to overwrite files.
9) I try to run Shadow.pb again.
LoadMesh() now returns some long number (true(
LoadTexture() still returns 0.

1) I made a copy of the whole PB folder with a new name (PureBasic OGRE).
2) I extracted the files in PureLibraries from the Ogre1.0.3.zip into the PureLibraries in my new PureBasic OGRE folder. I answered yes to all overwrite prompts.
3) I extracted the Engine3D dll and the other dll into the Compilers directory. I answered yes to overwrite the Engine3D dll.
4) I extracted the Shadow.pb into Examples\Sources.
5) Started PB
6) I try to run Shadow.pb with the debugger and debug outputting the result from
Debug LoadMesh (0, "Robot.mesh")
Debug LoadTexture(0, "r2skin.jpg")
They both return 0 of course.
7) I close PB

9) I try to run Shadow.pb again.
LoadMesh() now returns some long number (true(
LoadTexture() still returns 0.

Strange. If LoadMesh( works ... ?
Try copying an old r2skin.jpg to the new data folder. Or any old jpg and call it r2skin.jpg
Might look strange.
BTW: Is the loadTexture looking for r2skin.jpg or r2skin.png. I dimly recall having a wrong extension or filename somewhere - but I think it was to do with terrain. Still. Another straw to clutch.
Sorry I can't be more help. I hope this gets sorted for you quickly.
Edit:
Are the other 3D examples working?
Try copying an old r2skin.jpg to the new data folder. Or any old jpg and call it r2skin.jpg

BTW: Is the loadTexture looking for r2skin.jpg or r2skin.png. I dimly recall having a wrong extension or filename somewhere - but I think it was to do with terrain. Still. Another straw to clutch.
Sorry I can't be more help. I hope this gets sorted for you quickly.
Edit:
Are the other 3D examples working?
@}--`--,-- A rose by any other name ..
It's not much you can do, we'll just have to wait for Fred to come back from holiday.
None of the examples works, but I tried to install it on another computer, and then everythings works. But this other computer is generally slower, so I don't usually use it.
EDIT: Ooops, a bit trouble with the accounts when switching computers... This should be from Jellybean.
None of the examples works, but I tried to install it on another computer, and then everythings works. But this other computer is generally slower, so I don't usually use it.
EDIT: Ooops, a bit trouble with the accounts when switching computers... This should be from Jellybean.

Terrain Bug?
Hi Fred =)
Great News!
you dont know how long i ve been waitin for this =)
However, i may have found another Bug.
Try this:
Using my lil modified Terrain example.
Once running hit F1 to see the stats and TerrainHeight.
Note that if the Terrainheight exceeds 500 its set to 0
I also noted that the Format of CreateTerrain has changed for the ScaleY Parameter, which i think is related to this Bug.
Old:
New:
Heres the compiled Version to test it:
http://www.code5.ch/temp/Terrain.zip
1. Press F1
2. Just turn around and walk above Terrainheight 500.00000
Works fine with the old Lib (adjusting ScaleY).
Screen3DRequester.pb
Terrain.pb
While we re on it Fred...
When do you see Ogre.material script support implemented?
Keep up the Great work...
Thalius
Great News!
you dont know how long i ve been waitin for this =)
However, i may have found another Bug.
Try this:
Using my lil modified Terrain example.
Once running hit F1 to see the stats and TerrainHeight.
Note that if the Terrainheight exceeds 500 its set to 0
I also noted that the Format of CreateTerrain has changed for the ScaleY Parameter, which i think is related to this Bug.
Old:
Code: Select all
CreateTerrain("Terrain.png", MaterialID(0), 8, 0.7, 8, 8)
Code: Select all
CreateTerrain("Terrain.png", MaterialID(0), 8, 7, 8, 8)
http://www.code5.ch/temp/Terrain.zip
1. Press F1
2. Just turn around and walk above Terrainheight 500.00000
Works fine with the old Lib (adjusting ScaleY).
Screen3DRequester.pb
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - Common 3D functions
;
; (c) 2003 - Fantaisie Software
;
; Modified by: Thalius
; ------------------------------------------------------------
;
#WINDOW_Screen3DRequester = 0
#GADGET_FullScreen = 1
#GADGET_Windowed = 2
#GADGET_ScreenModesLabel = 3
#GADGET_WindowedModes = 4
#GADGET_Launch = 5
#GADGET_Cancel = 6
#GADGET_Logo = 7
#GADGET_Frame = 8
#GADGET_ScreenModes = 9
Global Screen3DRequester_FullScreen, Screen3DRequester_ShowStats
Procedure Screen3DRequester()
OpenPreferences("Demos3D.prefs")
FullScreen = ReadPreferenceLong ("FullScreen" , 1)
FullScreenMode$ = ReadPreferenceString("FullScreenMode" , "640 x 480")
WindowedScreenMode$ = ReadPreferenceString("WindowedScreenMode", "512 x 384")
If OpenWindow(#WINDOW_Screen3DRequester, 0, 0, 396, 205, #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_Invisible, "3D Engine")
If CreateGadgetList(WindowID())
Top = 6
ImageGadget (#GADGET_Logo, 6, Top, 0, 0, LoadImage(0,"Data\PureBasicLogo.bmp"), #PB_Image_Border) : Top+76
Frame3DGadget(#GADGET_Frame, 6, Top, 384, 80, "", 0) : Top+20
OptionGadget(#GADGET_FullScreen, 70, Top, 100, 20, "Fullscreen") : Top+25
OptionGadget(#GADGET_Windowed , 70, Top, 100, 20, "Windowed") : Top-25
ComboBoxGadget (#GADGET_ScreenModes , 190, Top, 150, 200) : Top+25
ComboBoxGadget (#GADGET_WindowedModes, 190, Top, 150, 200) : Top+45
ButtonGadget (#GADGET_Launch, 6, Top, 180, 25, "Launch", #PB_Button_Default)
ButtonGadget (#GADGET_Cancel, 200, Top, 190, 25, "Cancel")
If ExamineScreenModes()
While NextScreenMode()
Width = ScreenModeWidth()
Height = ScreenModeHeight()
If Width <> PreviousWidth Or Height <> PreviousHeight
If Depth <> 8
AddGadgetItem(#GADGET_ScreenModes, -1, Str(Width)+" x "+Str(Height))
EndIf
EndIf
PreviousWidth = Width
PreviousHeight = Height
Wend
EndIf
DesktopWidth = 1024 ; GetSystemMetrics_(#SM_CXSCREEN)
DesktopHeight = 768 ; GetSystemMetrics_(#SM_CYSCREEN)
NbScreenModes = 7
Restore WindowedScreenDimensions
Repeat
Read CurrentWidth
Read CurrentHeight
If CurrentWidth < DesktopWidth And CurrentHeight < DesktopHeight
AddGadgetItem(#GADGET_WindowedModes, -1, Str(CurrentWidth)+ " x "+Str(CurrentHeight))
NbScreenModes - 1
Else
NbScreenModes = 0
EndIf
Until NbScreenModes = 0
SetGadgetState(#GADGET_FullScreen, FullScreen)
SetGadgetState(#GADGET_Windowed , 1-FullScreen)
SetGadgetText (#GADGET_ScreenModes , FullScreenMode$)
SetGadgetText (#GADGET_WindowedModes, WindowedScreenMode$)
DisableGadget (#GADGET_ScreenModes , 1-FullScreen)
DisableGadget (#GADGET_WindowedModes, FullScreen)
HideWindow(#WINDOW_Screen3DRequester, 0)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadgetID()
Case #GADGET_Launch
Quit = 2
Case #GADGET_Cancel
Quit = 1
Case #GADGET_FullScreen
DisableGadget(#GADGET_ScreenModes , 0)
DisableGadget(#GADGET_WindowedModes, 1)
Case #GADGET_Windowed
DisableGadget(#GADGET_ScreenModes , 1)
DisableGadget(#GADGET_WindowedModes, 0)
EndSelect
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit > 0
FullScreen = GetGadgetState(#GADGET_FullScreen)
FullScreenMode$ = GetGadgetText (#GADGET_ScreenModes)
WindowedScreenMode$ = GetGadgetText (#GADGET_WindowedModes)
CloseWindow(#WINDOW_Screen3DRequester)
EndIf
EndIf
If Quit = 2 ; Launch button has been pressed
CreatePreferences("Demos3D.prefs")
WritePreferenceLong ("FullScreen" , FullScreen)
WritePreferenceString("FullScreenMode" , FullScreenMode$)
WritePreferenceString("WindowedScreenMode", WindowedScreenMode$)
If FullScreen
ScreenMode$ = FullScreenMode$
Else
ScreenMode$ = WindowedScreenMode$
EndIf
ScreenWidth = Val(StringField(ScreenMode$, 1, " "))
ScreenHeight = Val(Right(ScreenMode$, Len(ScreenMode$)-FindString(ScreenMode$, "x", 1)-1))
Screen3DRequester_FullScreen = FullScreen ; Global variable, for the Screen3DEvents
If FullScreen
Result = OpenScreen(ScreenWidth, ScreenHeight, 32, "3D Demos")
Else
If OpenWindow(0, 0, 0, ScreenWidth, ScreenHeight+MenuHeight(), #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "PureBasic - 3D Demos")
CreateMenu(0, WindowID())
MenuTitle("Project")
MenuItem(0, "Quit")
MenuTitle("About")
MenuItem(1, "About...")
Result = OpenWindowedScreen(WindowID(), 0, 0, ScreenWidth, ScreenHeight, 0, 0, 0)
EndIf
EndIf
EndIf
ProcedureReturn Result
EndProcedure
Procedure Screen3DEvents()
If Screen3DRequester_FullScreen = 0 ; Handle all the events relatives to the window..
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_Menu
Select EventMenuID()
Case 0
Quit = 1
Case 2
MessageRequester("Info", "Windowed 3D in PureBasic !", 0)
EndSelect
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
If Quit = 1 : End : EndIf ; Quit the app immediately
Until Event = 0
EndIf
If ExamineKeyboard()
If KeyboardReleased(#PB_Key_F1)
Screen3DRequester_ShowStats = 1-Screen3DRequester_ShowStats ; Switch the ShowStats on/off
EndIf
EndIf
EndProcedure
Procedure Screen3DStats()
If Screen3DRequester_ShowStats
If StartDrawing(ScreenOutput())
FrontColor(255, 255, 255)
DrawingMode(1)
Locate(0, 0) : DrawText(StrF(Engine3DFrameRate(0),1)+" FPS")
Locate(0, 20) : DrawText(Str(CountRenderedTriangles())+" Triangles "+"TerrainHeight: "+StrF(Height.f))
StopDrawing()
EndIf
EndIf
EndProcedure
DataSection
WindowedScreenDimensions:
Data.l 320, 240
Data.l 512, 384
Data.l 640, 480
Data.l 800, 600
Data.l 1024, 768
Data.l 1280, 1024
Data.l 1600, 1200
EndDataSection
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - Terrain
;
; (c) 2003 - Fantaisie Software
;
; ------------------------------------------------------------
;
#CameraSpeed = 5
Global Height.f ; Hack to Show Terrain-Height
IncludeFile "Screen3DRequester.pb"
DefType.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
Add3DArchive("Data\" , #PB_3DArchive_FileSystem)
Add3DArchive("Data\Skybox.zip", #PB_3DArchive_Zip)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
AmbientColor(RGB(255,255,255))
CreateMaterial (0, LoadTexture(0, "Terrain_Texture.jpg"))
AddMaterialLayer(0, LoadTexture(1, "Terrain_Detail.jpg"), 1)
CreateTerrain("Terrain.png", MaterialID(0), 8, 7, 8, 8)
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0, 128, 25, 128)
SkyDome("Clouds.jpg",10)
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)*#CameraSpeed/2
MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
EndIf
Height.f = TerrainHeight(CameraX(0), CameraZ(0))
RotateCamera(0, MouseX, MouseY, RollZ)
MoveCamera (0, KeyX, -CameraY(0)+Height+8, KeyY)
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End


Keep up the Great work...

Thalius
[French]
Fred pourrais-tu préciser comment fonctionne les couleurs ? je ne comprends pas .
Dans l'exemple MeshManual.pb , il y a
Pourquoi des flottants ?
Et surtout , j'ai beau modifier ces valeurs , ça n'a aucun effet sur le cube.
Que faut-il faire exactement pour voir quelque chose ?
J'ai aussi essayé en ajoutant une lumière , en vain.
[English]
Fred can you show me how work color ?
in the file MeshManual.pb i can see
Why float for color ? if i try to change values , nothing change .
Fred pourrais-tu préciser comment fonctionne les couleurs ? je ne comprends pas .
Dans l'exemple MeshManual.pb , il y a
Code: Select all
Data.f 1.0,0.0,0.0;, //0 colour
Et surtout , j'ai beau modifier ces valeurs , ça n'a aucun effet sur le cube.
Que faut-il faire exactement pour voir quelque chose ?
J'ai aussi essayé en ajoutant une lumière , en vain.
[English]
Fred can you show me how work color ?
in the file MeshManual.pb i can see
Code: Select all
Data.f 1.0,0.0,0.0;, //0 colour
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
hrm....
Out of some Reason i get 0 as Result calling:
ScreenModeWidth()
ScreenModeHeight()
ScreenModeDepth()
with the new ogre lib ...
( Using the Standard ScreenRequester.pb to test it )
EDIT: Just seems to appear on an ATI Gfx System.
EDIT2:
Was my Fault. I just realized ATI Cards deliver Screenresolutions a bit different. My Sorting Routine was the Prob =)
ps.
SkyBox() needs at least one more Parameter...
Some kind of switch to exclude the Skybox from the Fogrendering using fog() ...
Maybe some restructuring of the Render->Scene part.
ps. yeah yeah .. my english is terrible ...
pps. Merci le Comtois de son Collisionboxcode ( That's the example i learned how to use structs/LLists in PB properly) *g*
ppps. Yes, my french is even worse but eh... *g*
pppps. okok.. i used Babelfish =p
Ill keep coding ( Workin on porting some rather "complex" game-engine to ogre/pb ) - as soon as i have my tools done ( object converters / editors ) ill write some tutorials and perhaps will release some "free" versions to the pb community to have a more standarized and professional 3d Environment to play with..
pppps. Ogre is $$$ but if i would want to code all of this stuff in C++ , id be grey and old when its finished =)
btw Fred. Is there somewhere the beta modified source of 1.0.3 to DL, id like to check it out and fix some stuff etc. Alternativelly you can mail it to me =)
Thalius
Out of some Reason i get 0 as Result calling:
ScreenModeWidth()
ScreenModeHeight()
ScreenModeDepth()
with the new ogre lib ...
( Using the Standard ScreenRequester.pb to test it )
EDIT: Just seems to appear on an ATI Gfx System.
EDIT2:
Was my Fault. I just realized ATI Cards deliver Screenresolutions a bit different. My Sorting Routine was the Prob =)
ps.
SkyBox() needs at least one more Parameter...

Maybe some restructuring of the Render->Scene part.
ps. yeah yeah .. my english is terrible ...

pps. Merci le Comtois de son Collisionboxcode ( That's the example i learned how to use structs/LLists in PB properly) *g*

ppps. Yes, my french is even worse but eh... *g*

pppps. okok.. i used Babelfish =p
Ill keep coding ( Workin on porting some rather "complex" game-engine to ogre/pb ) - as soon as i have my tools done ( object converters / editors ) ill write some tutorials and perhaps will release some "free" versions to the pb community to have a more standarized and professional 3d Environment to play with..
pppps. Ogre is $$$ but if i would want to code all of this stuff in C++ , id be grey and old when its finished =)
btw Fred. Is there somewhere the beta modified source of 1.0.3 to DL, id like to check it out and fix some stuff etc. Alternativelly you can mail it to me =)
Thalius
Last edited by Thalius on Fri Oct 07, 2005 3:33 pm, edited 1 time in total.
I change fews lines in shadow.pb to show a problem.
I create a matrix : Entity(1).
Sometimes i cant see entity(1)
At start i cant see entity(1) , i need to press key [Down] to take altitude.
[Sorry , i cant say more in english ]
( Au démarrage du programme , on ne voit pas l'entity(1) ; il faut prendre de l'altitude avec la touche [BAS] tout en gardant en ligne de mire les robots ) , ensuite en se baladant , on perd d'un coup la matrice .
Je ne vois rien d'anormal dans mon code ? puisque la matrice s'affiche correctement parfois , je suppose que la définition des triangles est correcte.
Je me risque à un début d'explication , on dirait que la matrice disparait quand le bord haut gauche est hors de l'écran , c'est le sommet de coordonnées (0,0,0) .Pourquoi ? apparemment , ça ne le fait pas avec ton mesh .
[EDIT] je viens de faire des tests avec ton mesh ,et j'obtiens aussi un écran noir par moment.
Il suffit de se placer entre les robots , et faire tourner la scène avec la souris, un écran noir apparait brièvement .
C'est plus facile à mettre en évidence avec ma matrice.
_______________
I see you add new funtion EntityRenderMode(2, #PB_Entity_Wireframe)
Nice
But sometimes dont work well (On passe du mode fil de fer au mode plein quand on s'approche de l'entity en question).
I create a matrix : Entity(1).
Sometimes i cant see entity(1)

At start i cant see entity(1) , i need to press key [Down] to take altitude.
[Sorry , i cant say more in english ]
( Au démarrage du programme , on ne voit pas l'entity(1) ; il faut prendre de l'altitude avec la touche [BAS] tout en gardant en ligne de mire les robots ) , ensuite en se baladant , on perd d'un coup la matrice .
Je ne vois rien d'anormal dans mon code ? puisque la matrice s'affiche correctement parfois , je suppose que la définition des triangles est correcte.
Je me risque à un début d'explication , on dirait que la matrice disparait quand le bord haut gauche est hors de l'écran , c'est le sommet de coordonnées (0,0,0) .Pourquoi ? apparemment , ça ne le fait pas avec ton mesh .
[EDIT] je viens de faire des tests avec ton mesh ,et j'obtiens aussi un écran noir par moment.
Il suffit de se placer entre les robots , et faire tourner la scène avec la souris, un écran noir apparait brièvement .
C'est plus facile à mettre en évidence avec ma matrice.
_______________
I see you add new funtion EntityRenderMode(2, #PB_Entity_Wireframe)
Nice

Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - SHADOW
;
; (c) 2002 - Fantaisie Software
;
; ------------------------------------------------------------
;
#CameraSpeed = 10
IncludeFile "Screen3DRequester.pb"
DefType.f KeyX, KeyY, MouseX, MouseY
Structure Vertex
px.f
py.f
pz.f
nx.f
ny.f
nz.f
U.f
V.f
EndStructure
Structure Facette
P1.Vertex
P2.vertex
P3.Vertex
P4.Vertex
EndStructure
Structure Face
f1.w
f2.w
f3.w
f4.w
f5.w
f6.w
EndStructure
Declare MakeMatrice()
If InitEngine3D()
Add3DArchive("Data\", #PB_3DArchive_FileSystem)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
#PB_Shadow_None = 0
#PB_Shadow_Modulative = 1 ; Black shadow (fast)
#PB_Shadow_Additive = 2 ; Additive translucent shadow (more expensive with severl lights)
WorldShadows(#PB_Shadow_Additive) ; Set the shadow mode for the world
AmbientColor(RGB(128,128,128))
#PB_Mesh_Vertex = 1 << 0
#PB_Mesh_Color = 1 << 1
#PB_Mesh_Normal = 1 << 2
#PB_Mesh_UVCoordinate = 1 << 3
; Additionnnal flag to specify the faces
;
#PB_Mesh_Face = 1 << 4
; Create a plan, manually
MakeMatrice()
LoadMesh (0, "Robot.mesh")
LoadTexture(0, "r2skin.jpg")
CreateEntity (0, MeshID(0), CreateMaterial(0, TextureID(0)))
AnimateEntity(0, "Walk")
CopyEntity(0, 2)
AnimateEntity(2, "Walk")
MoveEntity(2, 100, 0, -100)
#PB_Entity_Solid = 0
#PB_Entity_Wireframe = 1 << 0
#PB_Entity_Plot = 1 << 1
#PB_Entity_CastShadow = 1 << 2
; EntityRenderMode(2, #PB_Entity_Wireframe)
CreateMaterial(1, LoadTexture(1, "Background.png"))
CreateEntity (1, MeshID(1), MaterialID(1))
EntityRenderMode(1, 0) ; Disable shadow casting for this entity as it's our plan
;ScaleEntity(1, 4000, 1, 4000)
MoveEntity(1, -500, 0, -500)
DisableMaterialLighting(1, #False)
;CreateLight(1, RGB(255,255,255), 100.0, 100, 0)
CreateLight(0, RGB(255,255,255))
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0,0,50,100)
Repeat
Screen3DEvents()
ClearScreen(0, 0, 0)
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)*#CameraSpeed/2
MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
EndIf
RotateEntity(0, 1, 0, 0)
RotateCamera(0, MouseX, MouseY, RollZ)
MoveCamera (0, KeyX, 0, KeyY)
LightLocate(0, CameraX(0)+50, CameraY(0), CameraZ(0))
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End
Procedure MakeMatrice()
CreateMesh(1)
NbFacetteX=50
NbFacetteZ=50
TailleFacetteX=40
TailleFacetteZ=40
*VBuffer=AllocateMemory(SizeOf(Facette) * NbFacetteX * NbFacetteZ )
*PtrV.Facette=*VBuffer
For b=0 To NbFacetteZ-1
For a=0 To NbFacetteX-1
;Point 1
;Position
*PtrV\P1\px=a * TailleFacetteX
*PtrV\P1\py=0
*PtrV\P1\pz=b * TailleFacetteZ
;Normale
*PtrV\P1\nx=0
*PtrV\P1\ny=1
*PtrV\P1\nz=0
;Coordonnées texture
*PtrV\P1\u =0
*PtrV\P1\v =0
;Point 2
;Position
*PtrV\P2\px=(a + 1) * TailleFacetteX
*PtrV\P2\py=0
*PtrV\P2\pz=b * TailleFacetteZ
;Normale
*PtrV\P2\nx=0
*PtrV\P2\ny=1
*PtrV\P2\nz=0
;Coordonnées texture
*PtrV\P2\u =1
*PtrV\P2\v =0
;Point 3
*PtrV\P3\px=(a + 1) * TailleFacetteX
*PtrV\P3\py=0
*PtrV\P3\pz=(b + 1) * TailleFacetteZ
*PtrV\P3\nx=0
*PtrV\P3\ny=1
*PtrV\P3\nz=0
*PtrV\P3\u =1
*PtrV\P3\v =1
;Point 4
*PtrV\P4\px=a * TailleFacetteX
*PtrV\P4\py=0
*PtrV\P4\pz=(b + 1) * TailleFacetteZ
*PtrV\P4\nx=0
*PtrV\P4\ny=1
*PtrV\P4\nz=0
*PtrV\P4\u =0
*PtrV\P4\v =1
*PtrV + SizeOf(Facette)
Next a
Next b
*IBuffer=AllocateMemory(SizeOf(Face) * NbFacetteX * NbFacetteZ * 2)
*PtrF.Face = *IBuffer
For b=0 To NbFacetteZ-1
For a=0 To NbFacetteX-1
P1=(a+(NbFacetteX*b))*4
P2=P1+1
P3=P2+1
P4=P3+1
;Face 1
*PtrF\f1=P4 : *PtrF\f2=P2 : *PtrF\f3=P1
*PtrF\f4=P2 : *PtrF\f5=P4 : *PtrF\f6=P3
*PtrF + SizeOf(Face)
Next
Next
SetMeshData(1, #PB_Mesh_Vertex | #PB_Mesh_Normal | #PB_Mesh_UVCoordinate, *VBuffer,NbFacetteX * NbFacetteZ * 4)
SetMeshData(1, #PB_Mesh_Face, *IBuffer, NbFacetteX * NbFacetteZ * 2)
EndProcedure
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
If i write
I get an error "Invalid memory access"
It's ok with this code
Code: Select all
CreateTexture(0,2,2)
StartDrawing(TextureOutput(0))
Plot(0,0,$ffffff)
Plot(0,1,$ff)
Plot(1,0,$ff00)
Plot(1,1,$ff0000)
StopDrawing()
It's ok with this code
Code: Select all
CreateTexture(0,2,2)
StartDrawing(TextureOutput(0))
Box(0,0,1,1,$ffffff)
Box(0,1,1,1,$ff)
Box(1,0,1,1,$ff00)
Box(1,1,1,1,$ff0000)
StopDrawing()
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
@Fred
I try to add this in the shadow.pb example :
i see nothing , how does it work ? can you show a example ?
Btw, a cameraProjection would be nice for projection 3D-2D or 2D-3D.
for example to to obtain the position of a entity on the screen
Or to select a entity with mouse.
I try to add this in the shadow.pb example :
Code: Select all
CameraProjection(0,#PB_Camera_Orthographic)
Btw, a cameraProjection would be nice for projection 3D-2D or 2D-3D.
for example to to obtain the position of a entity on the screen
Or to select a entity with mouse.
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/