New TransformSprite3D() !

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Ypser
User
User
Posts: 19
Joined: Wed Jun 18, 2003 9:13 am
Location: Germany
Contact:

New TransformSprite3D() !

Post 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!
Image

I think that there will be more games written in with PureBasic, if this command works in a usefull way!
Last edited by Ypser on Fri Jan 02, 2004 12:53 am, edited 2 times in total.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Hi, could you provide a bit of code displaying the odd result above please?
--Kale

Image
User avatar
Ypser
User
User
Posts: 19
Joined: Wed Jun 18, 2003 9:13 am
Location: Germany
Contact:

Post 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)
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post 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)
--Kale

Image
User avatar
Ypser
User
User
Posts: 19
Joined: Wed Jun 18, 2003 9:13 am
Location: Germany
Contact:

Post 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!
BalrogSoft
Enthusiast
Enthusiast
Posts: 203
Joined: Sat Apr 26, 2003 6:33 pm
Location: Spain
Contact:

Post 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...
User avatar
Ypser
User
User
Posts: 19
Joined: Wed Jun 18, 2003 9:13 am
Location: Germany
Contact:

Post 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!!!

Image

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 () !!
BalrogSoft
Enthusiast
Enthusiast
Posts: 203
Joined: Sat Apr 26, 2003 6:33 pm
Location: Spain
Contact:

Post 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.
Image
User avatar
Ypser
User
User
Posts: 19
Joined: Wed Jun 18, 2003 9:13 am
Location: Germany
Contact:

Post 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:
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Post 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!
cya,
...Danilo
...:-=< http://codedan.net/work >=-:...
-= FaceBook.com/DaniloKrahn =-
User avatar
Ypser
User
User
Posts: 19
Joined: Wed Jun 18, 2003 9:13 am
Location: Germany
Contact:

Post by Ypser »

@Danilo:
Great! That TransformSprite3D works perfectly!!!!
How can I use that in my program??????? (*deutsch:hechel,hechel!* :wink: )
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Post 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!
cya,
...Danilo
...:-=< http://codedan.net/work >=-:...
-= FaceBook.com/DaniloKrahn =-
User avatar
Ypser
User
User
Posts: 19
Joined: Wed Jun 18, 2003 9:13 am
Location: Germany
Contact:

Post 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.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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).
Post Reply