SpriteControl problems
Blitz3D Forums/Blitz3D Programming/SpriteControl problems
| ||
Hi! This is for users that are familiar with SpriteControl (http://www.blitzbasic.com/codearcs/codearcs.php?code=456) :-)
Include "Sprite Control.bb"
Graphics3D 640,480
SetBuffer BackBuffer()
treasureMapSize = GraphicsHeight() ;based on the graphicsheight, I will also size the map to
;the screenwidth, since width is always bigger than height.
pieceSize = treasureMapSize / 4
Type kaartstukje
Field entity
Field id
End Type
mycamera=CreateCamera()
myspritecam = CreateSpriteCamera()
kaart = LoadImage3D ("kaart.jpg",1)
palen = LoadImage3D ("vb.png",2)
HandleImage3D kaart,-1,-1
DrawImage3D kaart,0,0
ResizeImage3D kaart,treasureMapSize,treasureMapSize
HandleImage3D palen,-1,-1
DrawImage3D palen,0,0
ResizeImage3D palen,treasureMapSize,treasureMapSize
RenderWorld
Flip
kaart_id=1
; chop the images in pieces
For y=0 To 3
For x=0 To 3
k.kaartstukje = New kaartstukje
k\entity = GrabImage3D(x*pieceSize, y*pieceSize, pieceSize, pieceSize)
k\id = kaart_id
kaart_id=kaart_id+1
Next
Next
; remove the big images, no need for them anymore
FreeEntity kaart
FreeEntity palen
;FlushKeys
;WaitKey
; draw them again
x=0 : y=0
For k.kaartstukje = Each kaartstukje
HandleImage3D k\entity,-1,-1
DrawImage3D k\entity, x*pieceSize+2, y*pieceSize+2
x = x + 1
If x > 3
x = 0
y = y + 1
End If
Next
RenderWorld
Flip
WaitKey
End
Now what this code does: chop two displayed images into 16 pieces, and show them again (draw each chopped piece). Weird enough piece #7 is also piece #5. And the loop is correct! I checked which coordinates are grabbed, and displayed again, so this shouldn't be possible! First question: Someone knows what going on? Second question: it grabs what is displayed on screen, but I do not want the user to see this. I tried hideEntity and cameraProjMode 0 but then the result is that nothing gets grabbed (because it is hidden). How can I NOT show what's going on but still grab the image? Thank you! |
| ||
| I would add a couple more fields to kaartstukje type to store the x and y position on screen for display. That way there is no confusion on destination drawing position. When you render a scene it usually renders to the backbuffer, so why not grab it from the backbuffer and remove the need to flip the buffers. |
| ||
| I can't really see whats going on as some functions are missing. What does GrabImage3d do? Oh, are you using turtles userlib/ddl thingy? |
| ||
| >are you using turtles userlib/ddl thingy? The link says it's by Syntax Error. >When you render a scene it usually renders to the backbuffer, so why not grab it from the backbuffer and remove the need to flip the buffers That would work, but it depends on how GrabImage3d is coded - Jeroen might need Syntax Error's permission to change his code. |
| ||
| Hi Jeroen, Try this example with the *new* updated SpriteControl. ; GrabImage3D test
tilesX=5 : tilesY=4
; the include file
Include "Sprite Control.bb"
; set up the 3d display
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
img=LoadImage("f:\640x480.jpg")
DrawImage img,0,0
cam=CreateCamera()
piv=CreateSpritePivot(cam,0.0002)
Dim s(1000)
iw=640/tilesX : ih=480/tilesY
For x=0 To (tilesX-1)
For y=0 To (tilesY-1)
num=num+1
s(num)=GrabImage3D(x*iw,y*ih,iw,ih)
HandleImage3D s(num),-1,-1
DrawImage3D s(num),x*iw,y*ih
Next
Next
RenderWorld
Flip
WaitKey
EndShould be fine now. To grab the images without the user 'seeing' them do as Sainfohi suggests. GrabImage3D() works on the current buffer. Just grab your stuff without Flipping and do a cls to clear the buffer. Example: ; GrabImage3D test2
; the include file
Include "Sprite Control.bb"
; set up the 3d display
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
cam=CreateSpriteCamera()
img=LoadImage("f:\640x480.jpg")
DrawImage img,0,0
sprite=GrabImage3D(20,40,128,128)
Cls
Repeat
Cls
DrawImage3D sprite,MouseX(),MouseY()
RenderWorld
Flip
Until KeyHit(1)
End |
| ||
| Hey guys, Thanks for all the help. I implemented the example above and now it works like a charm! |