Single Surface Pixel Perfect 3D, How?

Blitz3D Forums/Blitz3D Programming/Single Surface Pixel Perfect 3D, How?

Techlord(Posted 2005) [#1]
I'm looking for an explanation on Single Surface Pixel Perfect that can help me devise a new style of 3D GUI Lib.

The first milestone in the Library is to produce a set of 3D functions that can replace Blitz 2D Image and Graphic Drawing Commands. The first goal in the milestone is to create a function in which you pass a Surface Handle, Image Handle, StartCoords,Rect_X,Rect_Y,rect_width,rect_height. With these parameters the function should be able to create a Pixel Perfect Sprite on the surface appropiatelty distanced from the camera.

So far I've identified a set variables involved with creating a Single Surface Pixel Perfect Sprite:

Screen_Width, Screen_Height
Viewport_Width, Viewport_Height
Sprite_Width, Sprite_Height (Common Surface)
Texture_Width, Texture_Height (Divisible by 2)
VertexTexCoords_U(0-3), VertexTexCoords_V(0-3)
Sprite_ To_Camera_Distance

It would seem that with this set of variables one could formulate in infallible Single Surface Pixel Perfect Sprite Solution (formula, algorithm, etc). I've examined several Freely available Pixel Perfect Sprite systems. But the Solution isnt as obvious as I would like. I know the solution is within the set of variables. I 'm stumped!

Any help from the Blitz Gurus would be appreciated.


skidracer(Posted 2005) [#2]
I'm happy to answer any questions you have about my Pixies code:

http://www.blitzbasic.com/codearcs/codearcs.php?code=773


Techlord(Posted 2005) [#3]
skidracer,

Thanks. I don't know I overlooked it. I'm play with it and follow up.


Shambler(Posted 2005) [#4]
There are a few examples in the code archives, one of the better ones is

http://www.blitzbasic.com/codearcs/codearcs.php?code=1152


GW(Posted 2005) [#5]
You should definitly check out SpriteMasterPro by syntax error. Its full featured, very easy to use and its free!!


Techlord(Posted 2005) [#6]
@skidracer - Your 'pixie' code is very close to what I'm looking for. The 'pixiespace' code is throwing me off a tad. I'm not sure what the purpose of this portion of the code is for.

The code works very well for a single texture. But a little more work would be required for a single surface Sprites using a several images in a single texture. I know some VertexTexCoord manipulation is needed. If you have an idea of achieving this my ears are open:)

@Shambler - Thanks. If I can recall correctly you had written some very good 3D lifttype code. Were you able to implement it in a FPS engine? Project PLASMA FPS is still looking for a few good coders;)

@GW - Thanks. I'm very familiar with ImagePacker and SpriteMasterPro. In fact, these applications sparked my interest in this subject. Unfortunately, the formula for producting 3D Single Surface Pixel Perfect Sprites is not very obvious. Finding the most simple solution to achieve these results is my goal.


Damien Sturdy(Posted 2005) [#7]
create a quad the size of the screenx in width, and screeny in height. Distance it at screenwidth/2.0 away from the camera. Face it at the camera.

The "hard" bit is the UV coordinates... you need to set the quad's UV Co-ords so that only a portion of the texture that is the shape of the screen is used. Its not that difficult, though im a tad busy at work with databases and spreadhseets to think properly.

If you are unable to get it working by saturday evening, message me on saturday eve.


Techlord(Posted 2005) [#8]
Running some test with skidracer's pixie code. The code doesnt handle odd shaped textures and I did not expect it to. Textures must be a multiple of 2 (16x8, 128x16, 256x256, etc), thus, I would have to compensate by rounding off to nearest multiples of 2. This is not a problem.

The pixie code is a good start. It also takes viewport size in consideration (which I overlooked). I've managed to reduced the pixie code down to this:


Next is figuring out VertexTexCoord manipulation with Quads.

Cygnus - any assistance you offer will be great.


Damien Sturdy(Posted 2005) [#9]
Quick pop up:

x=0-640,x=0-1
y=0-480,y=0-?

y=(640/480) ;)

Texture your quad with this, and use a 640x480 texture. it *should* work.

[edit]
your texture will need to be 640x640 i beleive... and theres a problem;

640x640 will likely get put up to 1024x1024, so....

x=0-texturewidth/640
y=0-textureheight/480


bah i dont have blitz here or my source code. Oh well ;/

I can't guarantee that will work. just thinking out loud. I HAVE done it in code though it is on my home 'puter.


jfk EO-11110(Posted 2005) [#10]
I tried to find Spritemaster Pro, without success (I tried this URL: http://homepage.ntlworld.com/config/imagepacker/spritemaster/index.htm ) Any ideas?


Shambler(Posted 2005) [#11]

@Shambler - Thanks. If I can recall correctly you had written some very good 3D lifttype code. Were you able to implement it in a FPS engine?



Yes it was/is in the SARE Engine and works better than ever ;)


Techlord(Posted 2005) [#12]
ImagePacker & SpriteMasterPro


Techlord(Posted 2005) [#13]
@Cygnus - Good Try.

@Shambler - Thats great.


jfk EO-11110(Posted 2005) [#14]
Thanks Frank, I wasn't aware of SpritemasterPro is part of the ImagePacker Download.