ClipSprite3D()
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
ClipSprite3D()
That would be quite handy for the isometric tile engine i'm making because it would then support sprite3d, and then I could create nice effects like alphablended walls and stuff...
I like logic, hence I dislike humans but love computers.
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
Nope, and that's not what I want to do.
Last edited by Joakim Christiansen on Tue Sep 20, 2005 8:56 pm, edited 1 time in total.
I like logic, hence I dislike humans but love computers.
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
I wrote such a function, some time ago.
Code: Select all
Structure DDPIXELFORMAT
dwSize.l
dwFlags.l
dwFourCC.l
dwRGBBitCount.l
dwRBitMask.l
dwGBitMask.l
dwBBitMask.l
dwRGBAlphaBitMask.l
EndStructure
Structure DDCOLORKEY
dwColorSpaceLowValue.l
dwColorSpaceHighValue.l
EndStructure
Structure DDSCAPS2
dwCaps.l
dwCaps2.l
dwCaps3.l
dwCaps4.l
EndStructure
Structure DDSURFACEDESC2
dwSize.l
dwFlags.l
dwHeight.l
dwWidth.l
lPitch.l
dwBackBufferCount.l
dwRefreshRate.l
dwAlphaBitDepth.l
dwReserved.l
lpSurface.l
ddckCKDestOverlay.DDCOLORKEY
ddckCKDestBlt.DDCOLORKEY
ddckCKSrcOverlay.DDCOLORKEY
ddckCKSrcBlt.DDCOLORKEY
ddpfPixelFormat.DDPIXELFORMAT
ddsCaps.DDSCAPS2
dwTextureStage.l
EndStructure
Structure D3DTLVERTEX
sx.f
sy.f
sz.f
rhw.f
color.l
specular.l
tu.f
tv.f
EndStructure
Structure PB_Sprite3D
Texture.IDirectDrawSurface7 ; DirectDrawSurface7
Vertice.D3DTLVERTEX[4] ; The 4 vertices for the rectangle sprite
Width.w ; width set with ZoomSprite3D()
Height.w ; height set with ZoomSprite3D()
unknown.l
EndStructure
Procedure ClipSprite3D(Sprite3D,ClipX,ClipY,ClipWidth,ClipHeight)
*Sprite3D.PB_Sprite3D=IsSprite3D(Sprite3D)
If *Sprite3D=0:ProcedureReturn 0:EndIf
*DDS.IDirectDrawSurface7=*Sprite3D\Texture
DDSDESC.DDSURFACEDESC2
DDSDESC\dwSize=SizeOf(DDSURFACEDESC2)
Result=*DDS\GetSurfaceDesc(DDSDESC)
If Result:ProcedureReturn 0:EndIf
*Sprite3D\Vertice[0]\tu=ClipX/DDSDESC\dwWidth
*Sprite3D\Vertice[0]\tv=ClipY/DDSDESC\dwHeight
*Sprite3D\Vertice[1]\tu=(ClipX+ClipWidth)/DDSDESC\dwWidth
*Sprite3D\Vertice[1]\tv=ClipY/DDSDESC\dwHeight
*Sprite3D\Vertice[2]\tu=ClipX/DDSDESC\dwWidth
*Sprite3D\Vertice[2]\tv=(ClipY+ClipHeight)/DDSDESC\dwHeight
*Sprite3D\Vertice[3]\tu=(ClipX+ClipWidth)/DDSDESC\dwWidth
*Sprite3D\Vertice[3]\tv=(ClipY+ClipHeight)/DDSDESC\dwHeight
ProcedureReturn 1 ; return success
EndProcedure
;Example:
InitSprite()
InitSprite3D()
InitKeyboard()
OpenScreen(1024,768,32,"Clip sprite3D")
CreateSprite(1,256,256,#PB_Sprite_Texture)
StartDrawing(SpriteOutput(1))
Box(0,0,256,256,#Blue)
Box(0,0,50,50,#Yellow)
Box(50,50,50,50,#Red)
StopDrawing()
CreateSprite3D(1,1)
ClipSprite3D(1,0,0,100,100)
Repeat
ClearScreen(0,0,0)
Start3D()
RotateSprite3D(1,1,1)
DisplaySprite3D(1,200,200)
Stop3D()
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
* BUMP *
@S.M.:
Is it safe to clip a Sprite3D to a non-proportional size? E.g. like 120x177 or has to be in 2^N format?
@S.M.:
Is it safe to clip a Sprite3D to a non-proportional size? E.g. like 120x177 or has to be in 2^N format?
I think your you refering to the aspect ratio. The sprite will be clipped with this code but it gets sized to. After you clipped a sprite you need to use zoomSprite3D() using the same dimensions you used when clipping it. At least if you want a pixel-perfect display.Joakim Christiansen wrote:EDIT:
It messed up the graphix... weird...
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
How much I need to pay to Fantaisie Software to implement this command which 100% compatible with DirectX7 and the DirectX9 subsystem ASAP?
Don't think I'm kidding here, I mean business. This command is so essential to game development like the air to breath and I'm puzzled it's still not implemented after all these years.
Don't think I'm kidding here, I mean business. This command is so essential to game development like the air to breath and I'm puzzled it's still not implemented after all these years.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
I don't care how it's called or implemented. I just want this feature to be added natively ASAP and I am willing to pay for it.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Re: ClipSprite3D()
ClipSprite3D is needed for all formats to make game programming easier (and the drawing faster). It can be done from code on the forum for DirectX - but can it be done for OpenGl (Mac/Linux)?
Also, the DirectX starup needs to be modified so that the back of a texture is displayed - so you can do h and v flips - if possible this should be done on OpenGl too (for Mac/Linux).
Hopefully the ability to set the sprite3D drawing destination buffer will come back (drawing a texture to a texture) - this way we can create some nice effects.
In general the Sprite3D library needs beefing up so you don't have to go to Ogre to get these abilities.
Also, the DirectX starup needs to be modified so that the back of a texture is displayed - so you can do h and v flips - if possible this should be done on OpenGl too (for Mac/Linux).
Hopefully the ability to set the sprite3D drawing destination buffer will come back (drawing a texture to a texture) - this way we can create some nice effects.
In general the Sprite3D library needs beefing up so you don't have to go to Ogre to get these abilities.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system