Page 5 of 11
Posted: Mon Aug 22, 2005 3:04 pm
by Fred
Comtois: now, there is only 2 calls possible for SetMeshData() like below:
Code: Select all
SetMeshData(0, #PB_Mesh_Vertex | #PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate, ?CubeData2, 8)
SetMeshData(0, #PB_Mesh_Face, ?CubeDataIndex, 12)
In the first call, #PB_Mesh_Vertex must be always specified (obviously) and 1 of the 3 others as well. The data for each vertex shoud always respect this order: Vertex, Color, Normal, UVCoordinate. So a call with setdata and #PB_Mesh_UVCoordinate alone isn't accepted anymore.
THCM: I'm looking for the Antialiasing/filtering. edit: MaterialFiltering() allows you to change the filtering method for each texture/material. After looking at OGRE doc, Antialiasing is only available in the DX9 drivers. Also, the drivers panels (ATI/NVidia) often have an option to turn on FSAA etc.
Posted: Mon Aug 22, 2005 3:10 pm
by Comtois
ok thank's Fred. Now it's clear for me

Posted: Mon Aug 22, 2005 3:11 pm
by THCM
That's indeed good news Fred. Since Ogre is getting more mature over the time, it's even more interesting for Purebasic.
Posted: Mon Aug 22, 2005 3:34 pm
by dige
Comtois wrote:ok thank's Fred. Now it's clear for me :)
Could you fix your nice example please? :)
thx dige
Posted: Mon Aug 22, 2005 4:35 pm
by Comtois
dige wrote:Comtois wrote:ok thank's Fred. Now it's clear for me

Could you fix your nice example please?
thx dige
yes , but Normles for next time
Code: Select all
;**********************************************
;** Comtois ** 22/08/05 ** Matrice / Vagues **
;**********************************************
;Modifications and additions by Psychophanta
;-Initialisation
bitplanes.b=32:RX.w=1024:RY.w=768
If InitEngine3D()=0 Or InitSprite()=0 Or InitKeyboard()=0
MessageRequester("Error","Something fails to open Screen for 3D. This requires Engine3D.dll",0)
End
EndIf
While OpenScreen(RX.w,RY.w,bitplanes.b,"DemoMatrice")=0
If bitplanes.b>16:bitplanes.b-8
ElseIf RY.w>600:RX.w=800:RY.w=600
ElseIf RY.w>480:RX.w=640:RY.w=480
ElseIf RY.w>400:RX.w=640:RY.w=400
ElseIf RY.w>240:RX.w=320:RY.w=240
ElseIf RY.w>200:RX.w=320:RY.w=200
Else:MessageRequester("VGA limitation","Can't open Screen!",0):End
EndIf
Wend
Structure Vertex
x.f
y.f
z.f
;Nx.f
;Ny.f
;Nz.f
;Cx.f
;Cy.f
;Cz.f
u.f
v.f
EndStructure
Structure DoubleFace
f1.w
f2.w
f3.w
f4.w
f5.w
f6.w
f7.w
f8.w
f9.w
f10.w
f11.w
f12.w
EndStructure
;-Constantes
#NbX=30 ; nombre de facettes
#NbZ=30 ; nombre de facettes
#DegConv=3.14159265/180
#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
DataSection
Image:IncludeBinary "purebasiclogoNew.png"
EndDataSection
;-Variables Globales
Global AngleVague.f,WaveFrequency.f,WavePeriodX.f,WavePeriodZ.f,WaveAmplitude.f
Global xrot.f,yrot.f,zrot.f
Global CamLocateX.l,CamLocateY.l,CamLocateZ.l,CamLookAtX.l,CamLookAtY.l,CamLookAtZ.l
Global Mode.b
circle.l=360
AngleVague=Random(circle)
WaveFrequency=3;=waves/second
WavePeriodX=5;=1/Wave lenght
WavePeriodZ=9;=1/Wave lenght
WaveAmplitude=2
xrot=-0.3:yrot=-0.4:zrot=0.2
CamLocateX.l=0:CamLocateY.l=0:CamLocateZ.l=50
CamLookAtX.l=0:CamLookAtY.l=0:CamLookAtZ.l=0
;-Procédures
Procedure Matrice(*Vertex.Vertex,*Face.DoubleFace,FX.l,FZ.l)
*Ptr.Vertex=*Vertex
For b=0 To FZ
For a=0 To FX
*Ptr\x= a-FX/2
*Ptr\y=0
*Ptr\z=b-FZ/2
*Ptr\u=a/FX
*Ptr\v=b/FZ
*Ptr + SizeOf(Vertex)
Next a
Next b
*PtrF.DoubleFace=*Face
Nb=FX+1
For b=0 To FZ-1
For a=0 To FX-1
P1=a+(b*Nb)
P2=P1+1
P3=a+(b+1)*Nb
P4=P3+1
;Face 1
*PtrF\f1=P3 : *PtrF\f2=P2 : *PtrF\f3=P1
*PtrF\f4=P2 : *PtrF\f5=P3 : *PtrF\f6=P4
;Face 2
*PtrF\f7=P1 : *PtrF\f8=P2 : *PtrF\f9=P3
*PtrF\f10=P4 : *PtrF\f11=P3 : *PtrF\f12=P2
*PtrF + SizeOf(DoubleFace)
Next
Next
EndProcedure
Procedure vagues(*Vertex.Vertex)
; Modification sur l'axe des Y
*Ptr.Vertex=*Vertex
For z=0 To #NbZ
For x=0 To #NbX
*Ptr\y=Sin(#DegConv*(AngleVague+x*WavePeriodX+z*WavePeriodZ))*WaveAmplitude
*Ptr + SizeOf(Vertex)
Next
Next
SetMeshData(0,#PB_Mesh_Vertex | #PB_Mesh_UVCoordinate,*Vertex,(#NbX+1)*(#NbZ+1))
EndProcedure
Procedure.b ShowTextAndKeyTest(hidetext.b)
If hidetext.b=0
StartDrawing(ScreenOutput())
DrawingMode(1)
FrontColor(20,180,115)
Locate(0,0)
DrawText("[F1] => Toggle Mode affichage")
Locate(0,20)
DrawText("[PageUp] / [PageDown] => Wave Amplitude : "+StrF(WaveAmplitude))
Locate(0,40)
DrawText("[Up Arrow] / [Down Arrow] => Wave Period on Z axis : "+Str(WavePeriodZ))
Locate(0,60)
DrawText("[Right Arrow] / [Left Arrow] => Wave Period on X axis : "+Str(WavePeriodX))
Locate(0,80)
DrawText("[Home key] / [End key] => Wave speed : "+Str(WaveFrequency))
Locate(0,100)
DrawText("[F2] / [Shift+F2] => X rotation speed : "+StrF(xrot))
Locate(0,120)
DrawText("[F3] / [Shift+F3] => Y rotation speed : "+StrF(yrot))
Locate(0,140)
DrawText("[F4] / [Shift+F4] => Z rotation speed : "+StrF(zrot))
Locate(0,160)
DrawText("[F5] / [Shift+F5] => X Camera location : "+Str(CamLocateX))
Locate(0,180)
DrawText("[F6] / [Shift+F6] => Y Camera location : "+Str(CamLocateY))
Locate(0,200)
DrawText("[F7] / [Shift+F7] => Z Camera location : "+Str(CamLocateZ))
Locate(0,220)
DrawText("[F8] / [Shift+F8] => X Camera look at : "+Str(CamLookAtX))
Locate(0,240)
DrawText("[F9] / [Shift+F9] => Y Camera look at : "+Str(CamLookAtY))
Locate(0,260)
DrawText("[F10] / [Shift+F10] => Z Camera look at : "+Str(CamLookAtZ))
Locate(0,280)
DrawText("[F11] => Show or hide text")
Locate(0,300)
DrawText("[Space] => Halt")
StopDrawing()
EndIf
If KeyboardReleased(#PB_Key_F1)
If Mode.b:Mode=0:CameraRenderMode(0,#PB_Camera_Textured):Else:Mode=1:CameraRenderMode(0,#PB_Camera_Wireframe):EndIf
EndIf
If KeyboardReleased(#PB_Key_PageUp):WaveAmplitude+0.1:EndIf
If KeyboardReleased(#PB_Key_PageDown):WaveAmplitude-0.1:EndIf
If KeyboardReleased(#PB_Key_Up):WavePeriodZ+1:EndIf
If KeyboardReleased(#PB_Key_Down):WavePeriodZ-1:EndIf
If KeyboardReleased(#PB_Key_Left):WavePeriodX-1:EndIf
If KeyboardReleased(#PB_Key_Right):WavePeriodX+1:EndIf
If KeyboardReleased(#PB_Key_Home):WaveFrequency+1:EndIf
If KeyboardReleased(#PB_Key_End):WaveFrequency-1:EndIf
If KeyboardReleased(#PB_Key_F2)
If KeyboardPushed(#PB_Key_LeftShift) Or KeyboardPushed(#PB_Key_RightShift):xrot-0.1:Else:xrot+0.1:EndIf
EndIf
If KeyboardReleased(#PB_Key_F3)
If KeyboardPushed(#PB_Key_LeftShift) Or KeyboardPushed(#PB_Key_RightShift):yrot-0.1:Else:yrot+0.1:EndIf
EndIf
If KeyboardReleased(#PB_Key_F4)
If KeyboardPushed(#PB_Key_LeftShift) Or KeyboardPushed(#PB_Key_RightShift):zrot-0.1:Else:zrot+0.1:EndIf
EndIf
If KeyboardPushed(#PB_Key_F5)
If KeyboardPushed(#PB_Key_LeftShift) Or KeyboardPushed(#PB_Key_RightShift):CamLocateX-1:Else:CamLocateX+1:EndIf
EndIf
If KeyboardPushed(#PB_Key_F6)
If KeyboardPushed(#PB_Key_LeftShift) Or KeyboardPushed(#PB_Key_RightShift):CamLocateY-1:Else:CamLocateY+1:EndIf
EndIf
If KeyboardPushed(#PB_Key_F7)
If KeyboardPushed(#PB_Key_LeftShift) Or KeyboardPushed(#PB_Key_RightShift):CamLocateZ-1:Else:CamLocateZ+1:EndIf
EndIf
If KeyboardPushed(#PB_Key_F8)
If KeyboardPushed(#PB_Key_LeftShift) Or KeyboardPushed(#PB_Key_RightShift):CamLookAtX-1:Else:CamLookAtX+1:EndIf
EndIf
If KeyboardPushed(#PB_Key_F9)
If KeyboardPushed(#PB_Key_LeftShift) Or KeyboardPushed(#PB_Key_RightShift):CamLookAtY-1:Else:CamLookAtY+1:EndIf
EndIf
If KeyboardPushed(#PB_Key_F10)
If KeyboardPushed(#PB_Key_LeftShift) Or KeyboardPushed(#PB_Key_RightShift):CamLookAtZ-1:Else:CamLookAtZ+1:EndIf
EndIf
If KeyboardReleased(#PB_Key_F11):hidetext.b!1:EndIf
While KeyboardPushed(#PB_Key_Space):ExamineKeyboard():Wend
ProcedureReturn hidetext.b
EndProcedure
;-Mémoires Mesh
*VertexID=AllocateMemory((#NbX+1)*(#NbZ+1)*SizeOf(vertex))
*FaceID=AllocateMemory(#NbX*#NbZ*4*SizeOf(DoubleFace))
Matrice(*VertexID,*FaceID,#NbX,#NbZ)
;-Mesh
CreateMesh(0)
SetMeshData(0,#PB_Mesh_Vertex | #PB_Mesh_UVCoordinate,*VertexID,(#NbX+1)*(#NbZ+1))
SetMeshData(0,#PB_Mesh_face,*FaceID,(#NbX)*(#NbZ)*4)
;-Texture
UsePNGImageDecoder()
;LoadTexture(0,"purebasiclogoNew.png")
CatchImage(0,?Image)
CreateTexture(0,256,256)
StartDrawing(TextureOutput(0))
DrawImage(UseImage(0),0,0)
DrawingMode(4)
Box(i,i,254,254,$FFFFFF)
StopDrawing()
;- MAterial
CreateMaterial(0,TextureID(0))
MaterialFilteringMode(0,#PB_Material_Trilinear)
;-Entity
CreateEntity(0,MeshID(0),MaterialID(0))
;-Camera
CreateCamera(0,0,0,100,100)
AmbientColor($FFFFFF);<- Essential for clarity
;-Boucle principale
Repeat
ClearScreen(0,0,0)
ExamineKeyboard()
CameraLocate(0,CamLocateX,CamLocateY,CamLocateZ)
CameraLookAt(0,CamLookAtX,CamLookAtY,CamLookAtZ)
;Calculate (AngleVague+WaveFrequency)%360: (coz % operand doesn't accept floats)
!fild dword[v_circle]
!fld dword[v_AngleVague]
!fadd dword[v_WaveFrequency]
!fprem
!fstp dword[v_AngleVague]
!fstp st1
vagues(*VertexID)
RotateEntity(0,xrot,yrot,zrot)
RenderWorld()
hidetext.b=ShowTextAndKeyTest(hidetext.b)
FlipBuffers():Delay(7)
Until KeyboardPushed(#PB_Key_Escape)
Posted: Mon Aug 22, 2005 5:03 pm
by dige
Thanks Comtois :D
looks good now! ... whats about a cool Shadow example????
Posted: Mon Aug 22, 2005 5:10 pm
by dracflamloc
There is the one fred made already? Or do you want something cooler =P
Posted: Mon Aug 22, 2005 5:15 pm
by dige
I need a selfmade shadow example for learning purposes...
freds example use meshes, so I can see how it works ...
Posted: Mon Aug 22, 2005 5:35 pm
by Fred
Comtois: looks very good

.
dige: what do you mean by non-mesh shadow ? for now, only mesh can cast shadow IIRC. If you mean manual created mesh (like Comtois one), you can take a look in the Shadow.pb i put in the archive, the plan is a manual mesh (which can reflect shadows).
Posted: Mon Aug 22, 2005 8:15 pm
by kawasaki
Super!.. Thanks!
Any chance of getting an update on the command reference or the help files please?
Posted: Mon Aug 22, 2005 9:38 pm
by oakvalley
Createtexture causes a crash everytime
Just creating a blank one and I get a severe error crash.
AppName: purebasic122138296.exe AppVer: 0.0.0.0 ModName: kernel32.dll
ModVer: 5.1.2600.2180 Offset: 0001eb33
Also reloading a texture on top of a existing texture don't replace it as
it should, and everything crash again.
Please check this command?
Verified on two different computers, one with GeForce4400 and 6800
Ogre v1.0.3 Beta
Posted: Mon Aug 22, 2005 11:19 pm
by SoulReaper
Hello
I think that there is an error in CameraBackColor(#Camera, Color)
if I try CameraBackColor(0,-1)
I dont recieve any errors & the background is transparent but the mesh is distorted, some wierd scuwing effect.
if the -1 value is set to zero or higher then it is fine...and still transparent
I just thought that I would let you know
one last thing while I am here in cyberspace,
will the light commands be changed later ?
Spotlights we have now

but will there be point lights and cone lights added later I am sure others have already talked about this
machine specs
xp1800, Radeon 9800 pro, win2000 pro
Keep up the good work
thankyou for your time
Kevin
Posted: Tue Aug 23, 2005 6:56 pm
by THCM
@Fred: Since ID released the Quake 3 source under gpl it would be possible to use q3 maps in commercial products. Do you have any plans reintegrating q3 bsp mapsupport?
Posted: Tue Aug 23, 2005 7:06 pm
by dracflamloc
Once he gives us the source for the pb ogre, why not just add it yourself?
Posted: Tue Aug 23, 2005 7:20 pm
by THCM
Good point, but why do you think I am using Purebasic? If I could add such things myself, I wouldn't be using Purebasic at all! I have zero C, C++ or C# coding skills! I'm just an old motorola (6502 & 680X0 assembler) boy who found a new home using Purebasic!