Posted: Sat Jan 29, 2005 1:18 am
Same here 

http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
S3DR_SetCameraRangeAndFOV(Near.f,Far.f,FOV.f) ;FOV is in degree
S3DR_SetDiffuseColors(Color1,Color2,Color3,Color4)
Code: Select all
InitSprite()
InitSprite3D()
InitKeyboard()
OpenScreen(800,600,16,"Example for S3DR_SetCameraRangeAndFOV() and S3DR_SetDiffuseColors()")
S3DR_CreateZBuffer()
CreateSprite(1,64,64,#PB_Sprite_Texture)
StartDrawing(SpriteOutput(1))
Box(0,0,64,64,#white)
StopDrawing()
Start3D()
S3DR_BeginReal3D()
S3DR_SetCullMode(#S3DR_NONE)
S3DR_MoveCamera(0,5,0)
S3DR_EndReal3D()
Stop3D()
Repeat
ExamineKeyboard()
Start3D()
S3DR_BeginReal3D()
S3DR_ClearScreenAndZBuffer(RGB(220,220,255))
S3DR_SetCameraRangeAndFOV(1,1000,120) ;FOV is in degree
S3DR_SelectTexture(1)
S3DR_SetDiffuseColors(#red,#green,#white,#blue)
For c=0 To 9;Draws a Cylinder
a1.f=c/10*ACos(-1)*2
a2.f=(c+1)/10*ACos(-1)*2
T1.f=c/10
T2.f=c/10+1/10
S3DR_SetTextureCoordinates(T1,0,T2,0,T1,1,T2,1)
X1.f=Sin(a1)*100
Y1.f=50
Z1.f=Cos(a1)*100
X2.f=Sin(a2)*100
Y2.f=50
Z2.f=Cos(a2)*100
X3.f=Sin(a1)*100
Y3.f=0
Z3.f=Cos(a1)*100
X4.f=Sin(a2)*100
Y4.f=0
Z4.f=Cos(a2)*100
S3DR_Draw3D(X1.f,Y1.f,Z1.f,X2.f,Y2.f,Z2.f,X3.f,Y3.f,Z3.f,X4.f,Y4.f,Z4.f)
Next
S3DR_SetTextureCoordinates(0,0,1,0,0,1,1,1)
If KeyboardPushed(#PB_Key_Left):S3DR_RotateCamera(-0.02,0,0):EndIf
If KeyboardPushed(#PB_Key_Right):S3DR_RotateCamera( 0.02,0,0):EndIf
If KeyboardPushed(#PB_Key_Up):S3DR_MoveCamera(0,0,1):EndIf
If KeyboardPushed(#PB_Key_Down):S3DR_MoveCamera(0,0,-1):EndIf
S3DR_SetDiffuseColors(#green,0,0,#green)
For x=-100 To 100 Step 20
For z=-100 To 100 Step 20
S3DR_Draw3D(-10+x, 0, 10+z, 10+x, 0, 10+z,-10+x, 0,-10+z, 10+x, 0,-10+z)
Next
Next
S3DR_EndReal3D()
Stop3D()
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
S3DR_FreeZBuffer()
Sorry, it is not intended for now.Any possiblilty of a linux version?
Code: Select all
tu.f=X.l/SpriteWidth.l
tv.f=Y.l/SpriteHeight.l
Code: Select all
#SpriteWidth=256
#SpriteHeight=256
InitSprite()
InitSprite3D()
InitKeyboard()
OpenScreen(800,600,16,"Texture coordinates")
S3DR_CreateZBuffer()
CreateSprite(1,#SpriteWidth,#SpriteHeight,#PB_Sprite_Texture)
StartDrawing(SpriteOutput(1))
Box(0,0,256,256,#green)
Circle(128,128,128,#red)
StopDrawing()
Repeat
Start3D()
S3DR_BeginReal3D()
S3DR_ClearScreenAndZBuffer(#blue)
S3DR_SelectTexture(1)
X1=10
Y1=10
X2=256-10
Y2=10
X3=10
Y3=256-10
X4=256-10
Y4=256-10
;convert the pixel-coordinates to texture-coordinates.
TU1.f=X1/#SpriteWidth
TV1.f=Y1/#SpriteHeight
TU2.f=X2/#SpriteWidth
TV2.f=Y2/#SpriteHeight
TU3.f=X3/#SpriteWidth
TV3.f=Y3/#SpriteHeight
TU4.f=X4/#SpriteWidth
TV4.f=Y4/#SpriteHeight
; tu1,tv1 tu2,tv2
; +---------+
; | |
; | |
; | |
; | |
; | |
; +---------+
; tu3,tv3 tu4,tv4
S3DR_SetTextureCoordinates(TU1.f,TV1.f,TU2.f,TV2.f,TU3.f,TV3.f,TU4.f,TV4.f)
; X1 Y1 Z1 X2 Y2 Z2 X3 Y3 Z3 X4 Y4 Z4
S3DR_Draw3D( -1, 1, 5, 1, 1, 5, -1, -1, 5, 1, -1, 5);draws the selected sprite
S3DR_EndReal3D()
Stop3D()
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
S3DR_FreeZBuffer()
Code: Select all
#SpriteWidth=256
#SpriteHeight=256
InitSprite()
InitSprite3D()
InitKeyboard()
OpenScreen(800,600,16,"Texture coordinates")
S3DR_CreateZBuffer()
CreateSprite(1,#SpriteWidth,#SpriteHeight,#PB_Sprite_Texture)
StartDrawing(SpriteOutput(1))
Box(0,0,256,256,RGB(255,255,255))
StopDrawing()
Repeat
Start3D()
S3DR_BeginReal3D()
S3DR_ClearScreenAndZBuffer(#blue)
S3DR_SelectTexture(1)
S3DR_SetDiffuseColors(RGB(0,255,0),RGB(255,0,0),RGB(0,0,255),RGB(0,0,0))
X1=10
Y1=10
X2=256-10
Y2=10
X3=10
Y3=256-10
X4=256-10
Y4=256-10
;convert the pixel-coordinates to texture-coordinates.
TU1.f=X1/#SpriteWidth
TV1.f=Y1/#SpriteHeight
TU2.f=X2/#SpriteWidth
TV2.f=Y2/#SpriteHeight
TU3.f=X3/#SpriteWidth
TV3.f=Y3/#SpriteHeight
TU4.f=X4/#SpriteWidth
TV4.f=Y4/#SpriteHeight
; tu1,tv1 tu2,tv2
; +---------+
; | |
; | |
; | |
; | |
; | |
; +---------+
; tu3,tv3 tu4,tv4
S3DR_SetTextureCoordinates(TU1.f,TV1.f,TU2.f,TV2.f,TU3.f,TV3.f,TU4.f,TV4.f)
; X1 Y1 Z1 X2 Y2 Z2 X3 Y3 Z3 X4 Y4 Z4
S3DR_Draw3D( -1, 1, 5, 1, 1, 5, -1, -1, 5, 1, -1, 5);draws the selected sprite
S3DR_EndReal3D()
Stop3D()
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
S3DR_FreeZBuffer()
You've right, it looks very ugly.I think this is correct, I merged the two codes above, the resulting code is pasted below. Had to change the #<color> values to the actual rgb values because this library would black out everything that was not green. So when I replaced those constants, the colors actually show on the texture However, when running the following code, you will notice the reg and blue values pixelate the texture horribly. making huge chunky blocks of different colors, instead of a smooth gradient I'm going to test it up against an actual textured picture to see how it looks ...
Code: Select all
S3DR_UseDither(#S3DR_TRUE)
That's true, but you need to create the sprite with the flag #PB_Sprite_Texture.Also, I noticed that there is no need to create a 3Dsprite from a 2dsprite if using this library .... ... sweet!
Yes, i will add this feature.I notice you add S3DR_FreeZBuffer() function at the end of all progs.
Can you do that it is made automatically when program ending is reached?
Code: Select all
InitSprite()
InitSprite3D()
InitKeyboard()
OpenScreen(800,600,16,"Texture coordinates")
S3DR_CreateZBuffer()
LoadSprite(1,"base1.bmp",#PB_Sprite_Texture)
Repeat
Start3D()
S3DR_BeginReal3D()
S3DR_ClearScreenAndZBuffer(#blue)
S3DR_SelectTexture(1)
S3DR_Draw3D( -1, 1, 5, 1, 1, 5, -1, -1, 5, 1, -1, 5)
S3DR_EndReal3D()
Stop3D()
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
S3DR_FreeZBuffer()
No , the most time I use the print-key for snapshots. :roll:Hmm, do you know of a full screen screenshot program that works with windows xp, sp2? With SP2, microsoft was dumb enough to remove the ability to take screenshots of directx screens (both windows and full screen), so for those tons of screeshot programs (like fraps), that rely on the OS to take screenshots, are broken with SP2.
Code: Select all
InitSprite()
InitSprite3D()
InitKeyboard()
OpenWindow(1,0,0,640,480,#PB_Window_ScreenCentered,"Snapshot")
OpenWindowedScreen(WindowID(),0,0,640,480,0,0,0)
S3DR_CreateZBuffer()
LoadSprite(1,"base1.bmp",#PB_Sprite_Texture)
Start3D()
S3DR_BeginReal3D()
S3DR_ClearScreenAndZBuffer(#blue)
S3DR_SelectTexture(1)
S3DR_Draw3D( -1, 1, 5, 1, 1, 5, -1, -1, 5, 1, -1, 5)
S3DR_EndReal3D()
Stop3D()
GrabSprite(2,0,0,640,480)
SaveSprite(2,"snapshot.bmp")
S3DR_FreeZBuffer()