Page 1 of 1
New TransformSprite3D() !
Posted: Tue Dec 30, 2003 6:31 pm
by Ypser
Hello.
I would like to have a usefull version of the
TransformSprite3D ()-Command in PB. So you could write your own
small 3D-engine for a game (i.e. a car race etc)
To see what i mean:
When you transform sprite
1, the result must be sprite
3, but not, as it is today, sprite
2!
I think that there will be more games written in with PureBasic, if this command works in a usefull way!
Posted: Tue Dec 30, 2003 8:45 pm
by Kale
Hi, could you provide a bit of code displaying the odd result above please?
Posted: Wed Dec 31, 2003 12:05 am
by Ypser
You can see the effect in the PureRacerDemo. The street texture and the borders look terrible.
Simple test:
Code: Select all
InitSprite (): InitSprite3D (): InitKeyboard ()
OpenScreen (800, 600, 32, "")
CreateSprite (0, 256, 256, #PB_Sprite_Texture)
StartDrawing (SpriteOutput (0))
Box (0, 0, 256, 256, RGB (0, 0, 100))
For I = 0 To 250 Step 10
Box (I, 0, 5, 256, RGB (60, 80, 255))
Next
StopDrawing ()
CreateSprite3D(1, 0)
Repeat
ExamineKeyboard ()
Start3D ()
ClearScreen (0, 0, 0)
TransformSprite3D (1, 0, 0, 256, 0, 256, 256, 0, 256) ;Standard
DisplaySprite3D (1, 0, 0)
TransformSprite3D (1, 255, 0, 455, 0, 712, 150, 0, 150) ;Transformed
DisplaySprite3D (1, 0, 305, 255)
Stop3D ()
FlipBuffers ()
Delay (20)
Until KeyboardPushed (#PB_Key_Escape)
Posted: Wed Dec 31, 2003 3:08 am
by Kale
AH! i see. hmmm... this isn't really the desired result, its obviously because the 3d sprite is made up of 2 triangles. Hopefully this is going to be addressed.
Another example to show this ugly effect:
Code: Select all
InitSprite () : InitSprite3D() : InitKeyboard ()
Global Size
OpenScreen (800, 600, 32, "")
CreateSprite (0, 256, 256, #PB_Sprite_Texture)
StartDrawing (SpriteOutput (0))
Box (0, 0, 256, 256, RGB (0, 0, 100))
For I = 0 To 250 Step 10
Box (I, 0, 5, 256, RGB (60, 80, 255))
Next
StopDrawing ()
CreateSprite3D(1, 0)
Repeat
ExamineKeyboard()
Start3D()
ClearScreen (0, 0, 0)
TransformSprite3D (1, Size, 0, 256 - Size, 0, 256, 256, 0, 256)
DisplaySprite3D (1, (800/2)-(256/2), (600/2)-(256/2), 255)
Stop3D()
StartDrawing(ScreenOutput())
FrontColor(255, 255, 255)
DrawingMode(1)
DrawText("Use the left and right key to adjust the sprite.")
Locate(0, 20)
DrawText("Value: " + Str(Size))
StopDrawing()
FlipBuffers()
If KeyboardPushed(#PB_Key_Right)
Size + 1
EndIf
If KeyboardPushed(#PB_Key_Left)
Size - 1
EndIf
Delay(1)
Until KeyboardPushed(#PB_Key_Escape)
Posted: Wed Dec 31, 2003 4:57 pm
by Ypser
Ok, i hope that this can be done for the next update. It is VERY IMPORTANT for me, as i am writing a 3D-engine
for a car race game. And i think that more people will code games using the Sprite3D-commands,
when this "bug" is fixed. I am wondering, for what this command was included, it is absolutely useless

in this form!
Posted: Fri Jan 02, 2004 1:49 pm
by BalrogSoft
hi... from my point of view, its not totally necesary solve it, it would be nice, but not necesary to make a 3d engine with this command, i write a 3d engine with this function, and only shows this perspective error on some cases, i saw this perspective error on commercial PSX games...
Posted: Fri Jan 02, 2004 2:49 pm
by Ypser
Not necessary??? Then you should take a closer look!
Or take a look on this screenshot of the race game i'm working on! The
street looks terrible!!!
It is absolutely necessary, and it would be a great argument, to new PB users, if we can show them some results.
But not with THIS TransformSprite3D () !!
Posted: Fri Jan 02, 2004 3:39 pm
by BalrogSoft
Your problem can be solved a little if you make more polygon detail to the road, this perspective error usually appears with bigger polygons near the camera.
Take a look to the road of my 3d engine, the road its formed by 4 polygons each segment of road.

Posted: Fri Jan 02, 2004 4:42 pm
by Ypser
And how does the road look, if you use a texture with road marks?
Ok that could make it better, but still not good. And this method will slow the game down!
There must be a way to get a better function to do these effects and to make games look good! :roll:
Posted: Fri Jan 02, 2004 6:37 pm
by Danilo
Ypser:
Please try this:
TransformSprite3D.
The bug is that rhw isnt calculated, its always set to 1.
I´m not sure if my formula always works correct, so it would
be nice when some 3D gurus could take a look please and
tell what they think. Its the best forrmula i could find atm.
Maybe Codemonger and others can test it too... thanks guys!
Posted: Fri Jan 02, 2004 6:59 pm
by Ypser
@Danilo:
Great! That TransformSprite3D works perfectly!!!!
How can I use that in my program??????? (*deutsch:hechel,hechel!*

)
Posted: Fri Jan 02, 2004 9:18 pm
by Danilo
Added a procedure to change the texture-mapping. You can test
it with Cursor up-down in the example.
New version:
TransformSprite3D.
Ypser wrote:That TransformSprite3D works perfectly!!!!
How can I use that in my program???????
Use my procedures. You only need to call CorrectSprite3D(x)
after every transformation.
You could make your own transform like this:
Code: Select all
Procedure _TransformSprite3D(sprite,x1,y1,x2,y2,x3,y3,x4,y4)
TransformSprite3D(sprite,x1,y1,x2,y2,x3,y3,x4,y4)
CorrectSprite3d(sprite)
EndProcedure
So you can use it now and just remove the '_' when the
Sprite3D library is fixed.
Before fixing the Sprite3D library we want to hear from the 3D gurus
that it works correctly. Does it fix the problem with the racer game?
Thanks for testing!
Posted: Fri Jan 02, 2004 9:53 pm
by Ypser
@Danilo:
Sorry, i was to fast. It still doesn't fix the problem. You're on the right way. Please look at the Topic in the German forum.
Posted: Tue Jan 04, 2005 8:29 pm
by Shannara
Ref:
viewtopic.php?p=77360#77360
The source code you provided is not the same as the code used to create the EXE you provided. The exe works, the source code does not (only displays a blank texture).