GLBasic forum

Main forum => GLBasic - en => Topic started by: Kyo on 2014-May-13

Title: Camera and Polyvector
Post by: Kyo on 2014-May-13
It's possible to use x_camera and polyvector???

hopefully you can give me an example of code?

thanks  :good:

Title: Re: Camera and Polyvector
Post by: MrTAToad on 2014-May-13
POLYVECTOR can only be used in a 2D environment, so after using 3D you need to use X_MAKE2D.  Something like :

Code: GLBasic [Select]
X_MAKE3D 0.1,1000.0,45.0
X_CAMERA 0.0,0.0,0.0,0.0,0.0,100.0
X_MAKE2D
STARTPOLY -1 // Bitmap = No.0
  POLYVECTOR  0,   0,  0,  0, RGB(255, 255, 255)
  POLYVECTOR   0, 300,  0, 64, RGB (255, 255, 255)
  POLYVECTOR 300, 300, 64, 64, RGB(255, 255, 255)
  POLYVECTOR 250,  50, 64,  0, RGB(  0, 255,   0)
 ENDPOLY
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-13
yes, but in this way the polyvector does not move when I move the camera.  ::)
Title: Re: Camera and Polyvector
Post by: aonyn on 2014-May-13
Hi Kyo,

It sounds like you may want to use the X_Obj commands.
http://www.glbasic.com/xmlhelp.php?lang=en&id=113&action=view (http://www.glbasic.com/xmlhelp.php?lang=en&id=113&action=view)

These make polys in 3d space instead of 2d.
Usage example is in the link.

Or... you may be able to use X_Sprite
http://www.glbasic.com/xmlhelp.php?lang=en&id=140&action=view (http://www.glbasic.com/xmlhelp.php?lang=en&id=140&action=view)

Regards,
David

edit... You may also look at this option.
http://www.glbasic.com/forum/index.php?topic=7992.0 (http://www.glbasic.com/forum/index.php?topic=7992.0)
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-13
Hi Kyo,

It sounds like you may want to use the X_Obj commands.
http://www.glbasic.com/xmlhelp.php?lang=en&id=113&action=view (http://www.glbasic.com/xmlhelp.php?lang=en&id=113&action=view)

These make polys in 3d space instead of 2d.
Usage example is in the link.

Or... you may be able to use X_Sprite
http://www.glbasic.com/xmlhelp.php?lang=en&id=140&action=view (http://www.glbasic.com/xmlhelp.php?lang=en&id=140&action=view)

Regards,
David

edit... You may also look at this option.
http://www.glbasic.com/forum/index.php?topic=7992.0 (http://www.glbasic.com/forum/index.php?topic=7992.0)

hanks for the help!
How I can do the flip (mirror??) of a X_Sprite?
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-13
You cant, but you can fake it by using a mirrored sprite/texure.

BTW. maybe you also want to have a look at my X_SPRITE replacement here: www.glbasic.com/forum/index.php?topic=7992
Since you can flip texture coordinates, you can easily mirror your sprites with it.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-13
You cant, but you can fake it by using a mirrored sprite/texure.

BTW. maybe you also want to have a look at my X_SPRITE replacement here: www.glbasic.com/forum/index.php?topic=7992
Since you can flip texture coordinates, you can easily mirror your sprites with it.

Great! It Work fine!  :nw:
How to make camera translation in X and Y... (not move camera or i change the angle of view)?

And it's possible to change colour at the texture with your system?????
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-14
I dont understand what you mean with your question about camera translation, but you can alter the color of the sprite: search for the line
Code: GLBasic [Select]
libSPRITE::glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
this one sets the color for all following sprites to white, but you can change it to an other color...
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-14
thanks  :nw:
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-14
I do not understand why in Windows mode works fine, but in full screen creates a line that goes from top to bottom! (as if he was distorting the screen).
It happens with your system, but also with polyvector or drawsprite!
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-14
Does this happen on every single GLBasic project that you create or only this one? Please try some really basic ones, maybe you can find out what commands are causing this.
Title: Re: Camera and Polyvector
Post by: MrTAToad on 2014-May-14
A screenshot will help too.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-14
No no with all Project and in all PC.
I will try to make a screenshot or a video!

One other question, is there a way to parent the Quad (created with libsprite) to X_camera? To create a Hud!

Solved!
----------------------------------------------------
How to reutrn X or Y position of a 3D object????
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-15
No no with all Project and in all PC.
I will try to make a screenshot or a video!
Ok, then it must be a problem with one of the commands, or you do something wrong. Can you try to track it down a bit more?

One other question, is there a way to parent the Quad (created with libsprite) to X_camera? To create a Hud!

Solved!
Hmm wouldnt 2D draws like Polyvectore etc. be perfect for a HUD?

How to reutrn X or Y position of a 3D object????
I dont understand this, when you draw a 3D object, you tell it where to draw, so you already know its position! Or do you mean the X and Y position on screen? Then yes, you can transform world coordinates to screen coordinates with the command X_WORLD2SCREEN.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-20
No no with all Project and in all PC.
I will try to make a screenshot or a video!
Ok, then it must be a problem with one of the commands, or you do something wrong. Can you try to track it down a bit more?

One other question, is there a way to parent the Quad (created with libsprite) to X_camera? To create a Hud!

Solved!
Hmm wouldnt 2D draws like Polyvectore etc. be perfect for a HUD?

How to reutrn X or Y position of a 3D object????
I dont understand this, when you draw a 3D object, you tell it where to draw, so you already know its position! Or do you mean the X and Y position on screen? Then yes, you can transform world coordinates to screen coordinates with the command X_WORLD2SCREEN.


Sorry for my absence ...

In full screen mode not it's possible to make video or screen shot and in window mode it's work fine!

When I move the sprite on the screen, above the sprite, it creates a wave (similar to warp or image torn)...

I use your system kannonet, but i have the same problem with Z-Project ......

it also happens on Android (I do not know if even on iOS) ... but it's orrible to view ....

I think it's a GL_Basic rendering problem.

I don't use sprite (texture) powerX2 (64*64,128*128 ecc).

I test various resolutions but the problem persists

The updates of GL_Basic are stop for long time!

I hope Gernot can fix this problem or is useless for me to continue to use GL_B!  :( :'(
 
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-20
But if it really was a GLBasic issue, it should be there in every project, right? I think that you are doing something in a wrong/unintended way, especially since I have never seen anyone reporting such a problem. I think if you track it down a bit more, you have a high chance to fix it.

The last Update of GLBasic is not that old, V12.096 was released just a few months ago.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-20
I have the last version ....  :(

A question how to use your system in scale 1:1????

And how to use rectangular image (120x30) ???
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-20
For 3D stuff in GLBasic you should only use square textures, so my libSPRITE was only coded with this in mind. To use it with non-square sprites, it would need a bigger rewrite. Best workaround for you could be to add transparent parts to your texture so it becomes a square (preferable with the power of 2 like 128x128), but this would mean, that you wast a bit of memory, sorry.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-20
it's possible that is a problem with VSync??
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-21
I tested 512x512 Sprite but the problem reamins ...

Please can someone try this demo and tell me if have the same problem in fullscreen?

 :nw: :nw: :nw: :nw:

P.S.: Use arrow keys to move Left and Right....
Title: Re: Camera and Polyvector
Post by: erico on 2014-May-21
What is the problem suppose to be? I didn´t quite understand by reading the topic.

I get a controllable Ryu that moves sideways in a black background.
The sprite is bicubic scaled.

EDIT: If you mean a weird wave effect over the sprite, I don´t see anything.
Are you using a laptop or maybe an old monitor, or old gfx card+strange open GL?
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-21
The only issue that I can see is vsync related IMHO. If you move such a big sprite with so much speed (I mean 5 pixel per frame) then you will probably get some vsync artifacts. You can enable vsync with
Code: GLBasic [Select]
LIMITFPS x, TRUE
but in my test that I just did it did not change anything, so Im not sure if this is your problem and if GLBasic vsync is broken.

BTW you dont need a CLEARSCREEN at the beginning of your rendering loop, SHOWSCREEN automatically does this for you.
Title: Re: Camera and Polyvector
Post by: erico on 2014-May-21
I did get an occasional stutter too. But I did not look into the code, just ran the .exe.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-21
I test with  LIMITFPS x, TRUE
I remove CLEARSCREEN
but the problem remains .....

I have 2 notebook:
TOSHIBA Satellite L850-1PD
Core i7
4 GB RAM
Svga Ati Radeon 7670

Acer Aspire 5520g:
AMD Turion 64 X2 Dual Core
4 GB RAM
NVIDIA GEFORCE 8400M

The problem is with the SVGA notebooks?


I make a test with the same sprite with Unity and Multimedia Fusion at the same resolution (I do not know how to use them but I managed to move the sprite to the right and left) and work perfectly!
I tried with this engine, because I doubt that it was a problem of my SVGA.

I do not know why I do this line that runs down the sprite .... :(
Title: Re: Camera and Polyvector
Post by: MrTAToad on 2014-May-21
PRINT SCREEN should still work in full screen - or you could try something like Fraps
Title: Re: Camera and Polyvector
Post by: erico on 2014-May-21
Yep it would be nice to see a screen shot.

I don´t think the problem is related to the laptops, I only asked because I had one here that had a gfx board that could not do open gl properly.
I got all sort of weird things from it.

But it dosen´t seem to be your case, your machines look modern enough.
Title: Re: Camera and Polyvector
Post by: MrTAToad on 2014-May-21
Could be a graphics driver setting - perhaps AA is active.
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-21
I still think its a vsync issue, but playing with my driver settings did not change anything. Does someone know if GLBasic vsync option is bugged or not?
Title: Re: Camera and Polyvector
Post by: MrTAToad on 2014-May-21
This is what mine looks like in fullscreen :

It looks like you aren't using SMOOTHSHADING FALSE
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-21
I make a video with fraps and also in screen shot ... but the warp don't appear in them ....  :S

I test with SMOOTHSHADING FALSE and TRUE ... the result does not change.

I'm using Windows 8 could be the problem?

I use driver ATi ver.: 13.35.1005 (Latest Beta).

In Ati catalyst control panel the AA is set to: Use application settings .....

Now I make a video with the camera ... wait ....
Title: Re: Camera and Polyvector
Post by: MrTAToad on 2014-May-21
I'm using Windows 8.1, and AMD Graphics card too.  Drivers are 14.10
Title: Re: Camera and Polyvector
Post by: erico on 2014-May-21
I think it may be a setting on the gfx card. I´m curious to see what the glitch looks like.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-21
See the error ...

Title: Re: Camera and Polyvector
Post by: erico on 2014-May-21
If I got it correct, it looks like tearing.
So it is a VSYNC issue.

Other then limit fps, take a look at the setting of you gfx card, it usually overides everything including GLB here in my computer.
See if you find anything related:

-double or triple buffer and leave that always on.
-vertical sync and leave that always on too.

Try a mix, the triple buffer might not be needed.
Your laptop monitor has a drive and is a 60hz right?

Hope it all helps
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-21
I install the latest version of catalyst driver 14.4 ... the problem remains...

I found the triple buffer in catalyst option and I active but ... the problem remains...

The VSync option in catalyst not exist ....

Yes my internal monitor it's 1366x768 60 hz and I have test with external TV/Monitor Samsung '42 with HDMI (in various resolution 1280x700 up to  1900x1200)  but ....   the problem remains...

 :giveup: :giveup: :giveup: :giveup:
Title: Re: Camera and Polyvector
Post by: erico on 2014-May-21
There is no way (IMO) vertical sync not existing into settings of a gfx card on PC.
It must be hidden with a different name.

See if this helps:
Quote
Open the amd vision engine control center, click the gaming tab along the left side, click 3d application settings and scroll down until you see the words "wait for vertical refresh".

For nvidea, it is control panel>manage 3d settings>vertical sync
triple buffer is there too.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-21
There is no way (IMO) vertical sync not existing into settings of a gfx card on PC.
It must be hidden with a different name.

See if this helps:
Quote
Open the amd vision engine control center, click the gaming tab along the left side, click 3d application settings and scroll down until you see the words "wait for vertical refresh".

For nvidea, it is control panel>manage 3d settings>vertical sync
triple buffer is there too.

Yesssssssssssssss it Work ....  :good:  :booze:  :nw:

But the problem it's for all PC  that have the same configuration .... GL_B can not activate this thing automatically???
Title: Re: Camera and Polyvector
Post by: erico on 2014-May-21
I wondered about that a long ago too.
But I don´t know, each card installs in a different fashion and I´m one to mess with it first install.

I don´t know which settings a gfx card installs first time.
I had similar problems with AA on my machines at the time, but all other computers I tried did not have a problem.
Title: Re: Camera and Polyvector
Post by: MrTAToad on 2014-May-21
You wont always get perfect VYSNC on a multi-tasking computer.  However, it would be much better if you set "Wait for Vsync Refresh" to "on" in the graphics card settings.  I'll post a video of it soon.  Filming will also affect what you see too.

Video : http://www.dailymotion.com/video/x1vz2v8_test-2014-05-21-22-25-20-51_tech

You wont be able to do anything about the anti-aliasing, by the way, as the sprite itself is anti-aliased :)
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-21
No i don't want to use AA i use a point sprite.  :P

But it's important it would be important that GL_B activate these functions automatically, so others persons (especially  who buy a game made in GL_B) may have this problem!
Title: Re: Camera and Polyvector
Post by: MrTAToad on 2014-May-22
No, it has to be done by the programmer as there are many processor speeds - you need to rate it to the computer
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-22
I did a little test ...

The polyvector work with X_CAMERA, but the polyvector dont have the Z coordinate, and all sprites are overlapping.

If add the Z coordinate to polyvector and fix the X_Camera for the correct display, we would have a system identical to Unity 2D.

We would not need to use any external libraries (ZProject etc.), and we may use in 2D games: Progressive Zoom, auto resize on various screen resolution etc ....

Why not add this GREAT features?

For me it's important to make serious 2D games!

Please, Gernot, reply to my request!


 :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw: :nw:
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-22
VSync has nothing to do with processor speed, its an option on the graphic card and a program can choose to use it or not (if the driver allows this selection). VSync in GLBasic seems to be bugged, at least it did not work for me, I could not even force it by enabling it in the graphic driver, it still got ignored.

Kyo I dont really know what feature you demand, do you mean something like my libSPRITE, but with the additional option to make non square rectangle sprites? Or something totally different?
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-22
Your system use quad and I use rectangular image ... (120x300 etc)

It's also difficult to use with scale 1:1 !

The polyvector use the image size to be created and it's fantastic ...

On the Polyvector i use a Pivot for correct the image position (X and Y).

But with Polyvector i have to move all screen for simulate a scrolling and it's not good!

For Zoom (with Polyvector) I have to scale all'image and I can't choose the point to Zoom (Like a Camera).

You have to test Unity 2D for understanding what I'm saying!  ;)
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-22
My editor work with this system:

(http://i61.tinypic.com/2vhtyrc.png)

But  Polyvector have several limitations:

If i want to make Zoom a specific zone, with Polyvector it's impossible:

(http://i59.tinypic.com/s4uj2r.png)

Another problem with polyvector:
when i move the Player on X, in reality I move the stages (and all objects) on the -X axis, so if an enemy is coming towards me, with the  speed X: -4 (correct speed) and background locked it's work well, but, when the background is moving (X: -2), I have to compensate the speed of the enemy (or seems to move very fast)!

it's frustrating to move the stages with all object, items, enemy etc....
is the Camera that follow the player ...

Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-22
kanonet, it's possible to adapt your libsprite to my needs? 
:nw: :nw: :nw: :nw:
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-22
I think I did understand your needs now - but I would not do it with 3D commands. I think all that you want to do can easily be done with 2D commands, and they will better fit your needs. IIRC there was side scrolling tutorial somewhere in the forum, this could show you what you need to know. I would encapsulate everything in some extended types with some helper functions, so you only do the job once, and adding new items or enemies means almost no additional work. A good engine is a great help!
Title: Re: Camera and Polyvector
Post by: erico on 2014-May-22
If you are looking at zooms like art of fighting, can be done with the 2d commands finelly.
The hotspot could be programmed too.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-22
I think I did understand your needs now - but I would not do it with 3D commands. I think all that you want to do can easily be done with 2D commands, and they will better fit your needs. IIRC there was side scrolling tutorial somewhere in the forum, this could show you what you need to know. I would encapsulate everything in some extended types with some helper functions, so you only do the job once, and adding new items or enemies means almost no additional work. A good engine is a great help!

I don't need to use IIRC, I've created a complete (complex) game with GLB (and Polyvector)!
A beat em'up with: multi parallax (2 rear, 1 front and 1 where the player walks), Tile manager, management of enemies with complex animations and status changes (ready_stance, Walk, Run, etc. the characters have up to 25 animations), special effects, particles, music, sfx etc. ...

I have created an editor that handles:
1) Characters: animation, collision zones, pivot for position, pivot for effects, etc.
2) Stages: Tile Editor, zone collision , placestatic and dynamic objects, etc. ..
3) Particles

It work fine (and speed) on android e ios ....
And for this I know the limits of GL_Basic (in 2D) ....

But for my next game, I need a few features!

If you are looking at zooms like art of fighting, can be done with the 2d commands finelly.
The hotspot could be programmed too.

Art of fighting it's old school, Today no one would use a system of 2D sprites to make a HD Fighting Game (see: Skullgirl, BeastFury, KOF XIII, Chain Saw, etc ...)

For peoples who use GL_Basic for the first time, thanks to the Basic language is really easy to use, but in the long time, miss a lot of features that make it competitive with current 2D engine!

I start to use GL_B 5 years ago, and in 5 years, has had a small minor changes and the addition of HTML 5 (which I did not understand if it works and if someone is using it)  but GL_B has always remained the same ...

This is the reason why in this Forum write only a dozen of people??? (maybe less)

I do not want to polemic, but I want to make games, not demos techniques or use it as a hobby.
Title: Re: Camera and Polyvector
Post by: erico on 2014-May-22
I see, there isen´t much I can help you with.
By what you have done you are certainly a better coder then me.

Some revamp on 2d and sound on GLB would come nice, last I recall there was SDL changes coming where I hope it will address your needs (and mine to).
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-22
I don't know if there will be changes (additions, improvements, bug fixes, see the audio on android etc) in a short time GL_B, but I'm considering other possibilities for my next game.

I tested Unity (I know C #) and for certain things is easy (see the management of the sprite and pivot) but I don't love the Animator system.

The system of scripts is cool, but I prefer to do the code from the beginning!

Title: Re: Camera and Polyvector
Post by: Slydog on 2014-May-22
I quickly reread this thread to get an idea of your problem.  But I still don't get what you are asking.
Why can't you use 3D quads (using perhaps a custom 3d sprite library to handle the low level details)?
They scale and pan with the camera.  They can be any size, any proportion, flipped, coloured, z-ordered, etc.

But then you said you wouldn't use a 2D system for a fighting game (and I agree!).
You'd have to have a sprite for every possible 'pose' for every action for every character.
In 3D, you could use a 3d model character with pre-wired animations embedded to call / activate by name ("walk", "jump", etc).
You would do all your animations inside your modelling app, or a specialized model animation app.  Or buy your animations ready to use.
You could set the camera to orthographic projection to make it look 2D.

Can GLBasic play embedded 3d model animations?
This is fairly easy using Unity (in 3D mode, using an orthographic camera perhaps).
I've never used Unity's animation system myself, so have nothing to add there.

And I also like to code from the beginning.  In Unity, I wrote wrappers for all my UI code (using Daikon Forge's UI library as a base).  I have methods to generate my UI on the fly using commands like UI.AddButton("name", x, y, w, h, etc).  My scene hierarchy is fairly blank as most of my objects are created / initialized in code.  I converted my 3d maze game to Unity in about 2 weeks.  I was running into GLBasic language limitations (I need my OOP!) and 3d graphics commands were too low level (and still missing features without working directly with OpenGL code which is an option).  And GLBasic was still only using OpenGL 1.1 (or maybe only OpenGLES 1.1 was limited?).  Plus no built-in physics (for future games!).  Unity did have a bigger learning curve.  Ha, I'm still learning.
Title: Re: Camera and Polyvector
Post by: erico on 2014-May-23
I quickly reread this thread to get an idea of your problem.  But I still don't get what you are asking.
Why can't you use 3D quads (using perhaps a custom 3d sprite library to handle the low level details)?
They scale and pan with the camera.  They can be any size, any proportion, flipped, coloured, z-ordered, etc.
...

I kind of don´t get either. It seems you are asking for features without showing what you are using it for. So without prior understandment of what you have, it becomes difficult to understand the problem. I agree with what Slydog stated as I seem to understand as he did.

Quote
But then you said you wouldn't use a 2D system for a fighting game (and I agree!).

This, of course, I fully disagree. :rant: ;)
Title: Re: Camera and Polyvector
Post by: erico on 2014-May-23
...
This is the reason why in this Forum write only a dozen of people??? (maybe less)
I do not want to polemic, but I want to make games, not demos techniques or use it as a hobby.

Quality and quantity does not come on the same package. :P :D
Title: Re: Camera and Polyvector
Post by: Slydog on 2014-May-23
Quote
But then you said you wouldn't use a 2D system for a fighting game (and I agree!).
This, of course, I fully disagree. :rant: ;)

Ha, forgot which forum I was in!  Please don't kick me out!  :giveup:  Ok, using 2D sprites is the 'traditional' method, old school, and fairly 'simple' programming wise.  (Well, both kinda are, depends on what you find 'difficult'.)

But, I'm no artist.  I can't imagine drawing/animating soooo many sprites and keeping them organized!  And for all movement combinations, and perhaps movement transitions (flying kick, plus then a downward punch half way through!).  With a 3d model this is all done for you, and you can very easily blend animations (while walking, have the upper body rotate left then look up, without missing a step). 

But, as I said I'm not an artist, and I would still need one to create my character model with all those built-in animations.  Actually, it would be a great way to generate a bunch of 2d animation sprites, use 3d for the posing, then 'snap' pictures in sequence to record the movement.  Then you have a sprite sheet ready to use. 

But, gotta give credit to anybody doing it the 2d spritesheet method.  I remember animating a simple 16x16 C64 sprite of a guy walking left-right. At that moment, I realized I should stick to programming!

[Edit]  Does it ever get quiet here when Europe logs off!  All the discussion is over before I wake up!  Or it just seems. :bed:
Title: Re: Camera and Polyvector
Post by: erico on 2014-May-23
A fighting game MUST be 2d on my books ;)

Using 3d to help generate the 2d sprites is a great technik, you get to see it on KOF XIII, where the base of everything is 3d and then they got artists to pixel work over it.
Brilliant results! Altough I would have skipped the transparencies, I don´t like it either.

One good thing about using 3d, is that you can record a movement in video, track in 3d, and export the needed frames, saves some time. :good:

... [Edit]  Does it ever get quiet here when Europe logs off!  All the discussion is over before I wake up!  Or it just seems. :bed:

Feels the same way here ;)
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-23
When I said, now you do not make more fight game with 2D sprites, I did not mean 2D fight game, but I was referring to the system of management of sprites.

Today everyone uses quadmesh (as I wrote, see: KOF XII and XIII Skull GIrl etc ...) they use sprites rendered from 3D models retouched with Photoshop.

...
This is the reason why in this Forum write only a dozen of people??? (maybe less)
I do not want to polemic, but I want to make games, not demos techniques or use it as a hobby.

Quality and quantity does not come on the same package. :P :D

In 2 years if GL_B remains so, also the few quality peoples disappear! ;)
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-23
And why do you think this can not be done with GLBasic? Then 2D Commands are powerful and you can easily do exactly this. But this has be said before...
E.g. have a look at Karma Miwa (http://www.glbasic.com/forum/index.php?topic=9200.msg85319#msg85319), many of the figures have been created in 3D and transformed into sprites, its working nice and looking good!

Of cause creating those meshs is a very big work, especially for a fighting game, but this has nothing to do with the programming language, you do this in external tools, like 3D modellers and graphic programs, but once created its easy to use them in GLBasic and create your game.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-23
I know how to make a 2D game in prerendering ... I'm telling of the features of Engine.

Use Polyvector for a 2D fighting game, not as good as use QuadMesh!

Today, even the shoot'em up, platform, etc., are made with quadmesh.

The total absence of Tools in GL_B, does not make it commercial, but it's not a problem for me!

Surely the problems of GL_B (see the various audio problems on Android, etc), I can not solve them!

If I buy an engine is because I believe in its future development.

But if I have to add features (other exporter platform, etc), fix BUG (audio, etc) or for have certain features I have to use external wrapper, I do before to buy another engine!
 
I'm wrong?
Title: Re: Camera and Polyvector
Post by: erico on 2014-May-23
No, you are not wrong.

But why can´t you do just that in GLB with 3d? That is what I´m not getting.
Create 3d rectangular flat objects and map your sprite to it, wouldn´t it solve the issues with z?
Title: Re: Camera and Polyvector
Post by: Slydog on 2014-May-23
But why can´t you do just that in GLB with 3d? That is what I´m not getting.
Create 3d rectangular flat objects and map your sprite to it, wouldn´t it solve the issues with z?

That's how it's done in Unity, even with their new 2D mode.  Everything is a 3D object in a 3D world, and sprites are simple quads.
Layering / ordering is handled by the z value of the quad's vertices.  (The new method may (also?) use layers for this instead, not sure).

GLBasic's attraction isn't it's complete list of features.  I'd say it's the language itself.  Small learning curve.  You can get something mocked up and running quickly.  Plus it supports a lot of platforms, not just the top popular ones.  It allows you to program in a low level, even directly working in OpenGL if you desire.  You can create your own libraries to do basically whatever you want.  I just wish physics was built-in.  But you are free to add your own, or an existing library if you can make it GLBasic compatible.  Oh, and the dedicated community!  We are the best.  And most humble.  =D
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-23
I dont buy an engine because of its potential future development, I buy it because it does (in its current state) what I want it to do - and I believe that it will at least not become worse in the future. But this aside.

I dont think that 2D Polyvector is wrong for this kind of game, but as a developer its your choice, if you prefer to do it in 3D, you can. So why dont you simply create a quad with X_OBJSTART etc. and render and texture this? GLBasic has all the things that you need for this - and if you are not totally happy with this, then you can still easily expand this with C++ and native OpenGL.

Bugs are something totally different and hopefully those know ones will get fixed in a not-so-far-future.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-23
I'm trying to use X_OBJSTART, but I wish they would change the Quad normal size, depending on the size of the image.

but I can not.

It's possible or am I doing wrong????

Code: GLBasic [Select]
FUNCTION CreateQuad: id,num,scale,col=0xFFFFFF

GETSPRITESIZE num,w,h

    X_OBJSTART id
                X_OBJADDVERTEX   0*scale,    0*scale, 0,  0,1, col
                X_OBJADDVERTEX   0*scale,    h*scale, 0,  0,0, col
                X_OBJADDVERTEX   w*scale,    0*scale, 0,  1,1, col
                X_OBJADDVERTEX   w*scale,    h*scale, 0,  1,0, col
        X_OBJEND

ENDFUNCTION // sz

 

The texture not maintains the size of the Quad.....
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-23
You can use X_AUTONORMALS to define how it creates normals for the quad, or you use X_OBJADDVERTEX_NORMAL to set it manually. If you set it manually, keep in mind, that  (nx^2 + ny^2 + nz ^2) = 1 if you break this you can get wired results, since GLBasic does not automatically correct it (at least I think so).

BTW you could also just model the quad in external software and import it into GLBasic - but for a quad that does not really make sense. :P
Title: Re: Camera and Polyvector
Post by: Slydog on 2014-May-23
Maybe if you arbitrarily set a world unit to be so many pixels.
For example, say you want 64 pixels to be a world unit, so a 64x128 pixel sprite would appear 1x2 world units big.

Change your code to something like:

Code: GLBasic [Select]
FUNCTION CreateQuad: id, num, scale, col=0xFFFFFF
    LOCAL pixelsInWorldUnit# = 64;
    GETSPRITESIZE num, w, h
    w = w / pixelsInWorldUnit;
    h = h / pixelsInWorldUnit;
    X_OBJSTART id
                X_OBJADDVERTEX   0,    0, 0,  0,1, col
                X_OBJADDVERTEX   0,    h, 0,  0,0, col
                X_OBJADDVERTEX   w,    0, 0,  1,1, col
                X_OBJADDVERTEX   w,    h, 0,  1,0, col
        X_OBJEND
ENDFUNCTION

This should make the quad proportionally sized to your source sprite size.
(If I understood your question!)
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-23
A practical example, because the documentation only says:

Code: GLBasic [Select]
X_OBJADDVERTEX_NORMAL nx#, ny#, nz#
Sets the normal vectors for comming calls to X_OBJADDVERTEX if you previously set X_AUTONORMALS 0.
 

BTW you could also just model the quad in external software and import it into GLBasic - but for a quad that does not really make sense. :P

Nope, i want to change te size of the quad at runtime:
Title: Re: Camera and Polyvector
Post by: Slydog on 2014-May-23
Are you asking about vertice 'NORMALS'?
ie. a NORMAL is a vector pointing away from a single vertice, used generally to indicate which direction the vertice is considered to be 'facing', used for lighting, etc.
So for a quad, the normals should be facing away from the quad, towards the camera.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-23
I'have this image (w:198 h:291):


(http://s15.postimg.org/jpbjwrjrv/image.png)

If I use this code:

Code: GLBasic [Select]
X_OBJSTART num
                X_OBJADDVERTEX   -20*sz, -20*sz, 0,  0,1, col
                X_OBJADDVERTEX   -20*sz,  20*sz, 0,  0,0, col
                X_OBJADDVERTEX    20*sz, -20*sz, 0,  1,1, col
                X_OBJADDVERTEX    20*sz,  20*sz, 0,  1,0, col
        X_OBJEND
 

I get:
(http://s24.postimg.org/pwuxi9rp1/image.png)

The image is square, so it is deformed
if I Use this code:

Code: GLBasic [Select]
FUNCTION CreateQuad: id, num, scale, col=0xFFFFFF
    LOCAL pixelsInWorldUnit# = 64;
    GETSPRITESIZE num, w, h
    w = w / pixelsInWorldUnit;
    h = h / pixelsInWorldUnit;
    X_OBJSTART id
                X_OBJADDVERTEX   0,    0, 0,  0,1, col
                X_OBJADDVERTEX   0,    h, 0,  0,0, col
                X_OBJADDVERTEX   w,    0, 0,  1,1, col
                X_OBJADDVERTEX   w,    h, 0,  1,0, col
        X_OBJEND
ENDFUNCTION
 

I have this result:
(http://s29.postimg.org/in5erdszr/image.png)

The rectangle is correct, but the texture does not fill the rectangle.
Title: Re: Camera and Polyvector
Post by: Slydog on 2014-May-23
I wonder if it's an integer / float conversion round?
You could add a print to see what numbers you're getting:
Code: GLBasic [Select]
PRINT "w: "+ w + ", h:" + h, 0,0
They should have decimals at the end (unless your sprite *is* evenly divided into 64).

But either way this is strange, your UV mapping is from 0 to 1 (3rd and 2nd last values in the X_OBJADDVERTEX command).
So no matter what size your sprite texture is, it should stretch to fill the entire quad.  And no red areas.

[Edit] You could place that line before, then after the 'w = w / pixelsInWorldUnits' to see the before value to verify the actual sprite size in pixels is returned.
Title: Re: Camera and Polyvector
Post by: Slydog on 2014-May-23
Ha, I've been working with C# too much!

Try taking out the semi-colons ( ; ) at the end of the 3 lines I added! Oops! :-[
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-23
Like Slydog said normals are for lighting, since you program a fake 2D you wont use the 3D lighting at all - so you probably can ignore normals. X_AUTONORMALS 0 should be enough for your use case, if its not, try 2.

I would suggest that you just create a quad with the size of 1x1 and then when you want to render it, set the actual size that you need with X_SCALING. 3D Objects are like sprites, you load or create them one time (at program start) and then you can render and manipulate them hundreds of times. Do not create the quad at runtime, this is slow!

Try something like this:
Code: GLBasic [Select]
// at program start create the 1x1 quad:
GLOBAL quadID%
X_AUTONORMALS 0
X_OBJSTART quadID
    X_OBJADDVERTEX 0, 0, 0,  0,1,  RGB(255,255,255)
    X_OBJADDVERTEX 0, 1, 0,  0,0,  RGB(255,255,255)
    X_OBJADDVERTEX 1, 0, 0,  1,1,  RGB(255,255,255)
    X_OBJADDVERTEX 1, 1, 0,  1,0,  RGB(255,255,255)
X_OBJEND


// at render time you can draw it with this function:
FUNCTION DrawQuad%: spriteID%, x#,y#,z#
    LOCAL pixelsInWorldUnit# = 64, w#, h#;
    GETSPRITESIZE spriteID, w, h
    w = w / pixelsInWorldUnit;
    h = h / pixelsInWorldUnit;
   
        X_SCALING w,h,1
        X_SETTEXTURE spriteID, -1
        X_MOVEMENT x,y,z
        X_DRAWOBJ quadID, 1
ENDFUNCTION
Just a quick mockuo, sorry if its not 100% perfect. Personally i would not like that it automatically scales, but if its that what you need here you go. BTW its suggested that your sprites are quads of the power of 2 like 128x128 - but of cause this would break the automatically scaling.
(I borrowed your code Slydog  8) )

EDIT: so many new posts since I began to write this, you guys post to fast. :D
EDIT2: I just realized that it was me, that did introduce the talk about normals, I did just read your post about 'quad normal size' wrong. Sorry, but this post here should still help you.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-23
Don't work correctly ...
Download the test file and use 1 or 2 for zoom in e out..

if you look you see on top of the image and at the right of the image two red line, that are the correct size of the quad, but the texture does not fill it.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-24
Only with power^2 work the Quad Texture????
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-24
Yes seems like this problem is cause by your image being no square of the power of 2. I tried to create a little demo how to work around this:
Code: GLBasic [Select]
GLOBAL SpriteQuadG AS TQuadMesh
TYPE TQuadMesh
        id% = -1
        p2wX# = 64.0
        p2wY# = 64.0

        FUNCTION Init%: PixelsInWorldUnitX#, PixelsInWorldUnitY#
                X_AUTONORMALS 0
                self.id = GENX_OBJ()
                X_OBJSTART self.id
                        X_OBJADDVERTEX 0, -1, 0,  0,1,  RGB(255,255,255)
                        X_OBJADDVERTEX 0, 0, 0,  0,0,  RGB(255,255,255)
                        X_OBJADDVERTEX 1, -1, 0,  1,1,  RGB(255,255,255)
                        X_OBJADDVERTEX 1, 0, 0,  1,0,  RGB(255,255,255)
                X_OBJEND
                self.p2wX = PixelsInWorldUnitX#
                self.p2wY = PixelsInWorldUnitY#
        ENDFUNCTION
ENDTYPE

TYPE TQuadSprite
        id% = -1
        w#; h#
        QuadInPixel%
        pivotX#
        pivotY#

        FUNCTION Load%: path$
                LOCAL sprite% = GENSPRITE()
                LOADSPRITE path$, sprite
                GETSPRITESIZE sprite, self.w, self.h

                LOCAL u%, v%, t# = LOGN(self.w)/LOGN(2)
                u = t
                IF t<>u THEN INC u
                t = LOGN(self.h)/LOGN(2)
                v = t
                IF t<>v THEN INC v
                IF u<v THEN u=v
                u=POW(2,u)
                self.QuadInPixel = u
                IF u=self.w AND u=self.h
                        self.id = sprite
                ELSE
                        LOCAL screen% = GENSCREEN()
                        self.id = GENSPRITE()
                        CREATESCREEN screen, self.id, u,u
                        USESCREEN screen
                        STRETCHSPRITE sprite, 0,0, u,u
                        USESCREEN -1
                        CREATESCREEN screen, -1, 0,0
                        LOADSPRITE "", sprite
                ENDIF
               
                self.w = self.w / SpriteQuadG.p2wX
                self.h = self.h / SpriteQuadG.p2wY
        ENDFUNCTION
       
        FUNCTION Pivot%: PivX%, PivY%   // Input in Pixel on original sized image; (0,0) is top left
                self.pivotX = -PivX / SpriteQuadG.p2wX
                self.pivotY = PivY / SpriteQuadG.p2wY
        ENDFUNCTION

        FUNCTION Draw%: x#, y#, z#=0
                X_SETTEXTURE self.id, -1
                X_SCALING self.w, self.h, 1
                X_MOVEMENT x+self.pivotX, y+self.pivotY, z
                X_DRAWOBJ SpriteQuadG.id, 1
        ENDFUNCTION
       
        FUNCTION RotoDraw%: x#, y#, z#=0, phi#=0.0
                X_SETTEXTURE self.id, -1
                X_SCALING self.w, self.h, 1
                X_MOVEMENT x, y, z
                X_ROTATION phi,0,0,1
                X_PUSHMATRIX
                X_MOVEMENT self.pivotX/self.w, self.pivotY/self.h, 0
                X_DRAWOBJ SpriteQuadG.id, 1
                X_POPMATRIX
        ENDFUNCTION
       
        FUNCTION ZoomDraw%: x#, y#, z#=0, relx#=1.0, rely#=1.0
                X_SETTEXTURE self.id, -1
                X_SCALING self.w*relx, self.h*rely, 1
                X_MOVEMENT x+self.pivotX*relx, y+self.pivotY*rely, z
                X_DRAWOBJ SpriteQuadG.id, 1
        ENDFUNCTION
       
        FUNCTION RotoZoomDraw%: x#, y#, z#=0, phi#=0.0, relx#=1.0, rely#=1.0
                X_SETTEXTURE self.id, -1
                X_SCALING self.w*relx, self.h*rely, 1
                X_MOVEMENT x, y, z
                X_ROTATION phi,0,0,1
                X_PUSHMATRIX
                X_MOVEMENT self.pivotX/self.w, self.pivotY/self.h, 0
                X_DRAWOBJ SpriteQuadG.id, 1
                X_POPMATRIX
        ENDFUNCTION
       
ENDTYPE
How to use it:
Code: GLBasic [Select]
// 1st Initilize the system and tell it how many pixels you have in one world unit (x and y)
        SpriteQuadG.Init(64,64)

// now you can create as many sprites as you want (of cause you could also use arrays of this type):
        GLOBAL fighter1 AS TQuadSprite
        GLOBAL fighter2 AS TQuadSprite

// now its time to load the images:
        fighter1.Load("1/1.png")
        fighter2.Load("2/1.png")

// feel free to change the sprites pivot:
        fighter1.Pivot(50,0)

// like in 2D you can use/draw every sprite as often as you want:
        fighter1.Draw(5,0)
        fighter1.Draw(7,0)
        fighter1.ZoomDraw(7,2,0, 0.5,0.5)
        fighter2.RotoDraw(-2,0,0, 45)
        fighter2.RotoZoomDraw(-5,2,0, 78, 2.0)

This internally stretches your sprite to the next square of the power of two - please be aware, that this can cause visible artefacts, try of SMOOTHSHADING on or off is better for your needs. This was the best that I could get out fast with pure GLBasic, if we would use INLINE and native OpenGL results would be better and faster. But still maybe that helps you, even though its not commented.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-24
Requiered Power of 2 Texture??? (128x128 etc) ?
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-24
I ask this because, if I'm not mistaken, an image loaded into memory,have the same size as a BMP.

My png image is W: 317 H 493 and the png in HDD is 292 KB, but in memory the uncompressed size is: 421 KB

If I have to use Pfor2 Texture I have to use the size W: 512 and H: 512, and the uncompressed size in memory is: 768 KB (nearly the double)

I have to Loading over 800 Image in Memory, and Pfor2 it's good only for DXT S3 Texture Compression.

My calculations are wrong?
Title: Re: Camera and Polyvector
Post by: MrTAToad on 2014-May-25
On most handheld devices, and a fair few PC graphics cards, power of 2 bitmaps are needed, unfortunately.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-25
So why, you can not use Powerx2 Texture in Unity?
Title: Re: Camera and Polyvector
Post by: erico on 2014-May-26
I don´t know that answer.

But for what Mr. Tatoad said, I have my game currently going with multiple imgage file sizes in pixel, they are not 2x and some are not on the 1k, 2k or 4k square limit.
It has been working fine on everything I try, had no trouble with it yet.

I get from Space Fractal´s experience that it is wise to keep the 2k limit if you are going to target platforms that might have an issue with it

Also, I haven´t done 3d texture with those,should they may fail when so if hardware is not capable?
So far I´m using the 2d commands and some of it, if I recall correctly from Gernot, is software based and has no trouble with hardware.

I guess I should try some 3d soon to have a saying on the subject. ;)
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-26
So why, you can not use Powerx2 Texture in Unity?
Its a bit Offtopic, but: As far as I have read it, Unity strongly recommends that the textures are power of 2 and automatic scales it, if its needed on the device. So it does approximately the same that I have done in my last example, just a bit more sophisticated (I hope so).

See here, under Texture Sizes: https://docs.unity3d.com/Documentation/Manual/Textures.html


BTW because of this I tried none square power of 2 textures like 256x512 in GLBasic and it works just fine, so my earlier posted code could get updated to be a bit more memory friendly.
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-26
Yes for best compression memory (DXT), but Unity work fine also with not px2 texture.  ;)
Title: Re: Camera and Polyvector
Post by: erico on 2014-May-26
So does GLB on my end,

I don´t get the point of this discussion, I can´t seem to grasp the objective or what is on the way. Well I keep trying :zzz:
Title: Re: Camera and Polyvector
Post by: Kyo on 2014-May-26
has no reason to exist, this Thread ...  maybe .... :D
Title: Re: Camera and Polyvector
Post by: Slydog on 2014-May-26
For a *real* game, you wouldn't do sprite animations like this anyways.
This method, each animation frame would be one sprite, and therefore one opengl 'material', and therefore one draw call.
(I know you only show one frame at a time per animation, but each visible on-screen sprite will be an extra draw call, slowing things down gradually).

The answer is texture atlases aka sprite sheets.  Check out apps like TexturePacker that creates larger texture atlases composed of all of your sprites (or a portion if you have many sprites).  It outputs a text file telling you where every sprite it located by x and y coordinates, and the sprites name.  You just build an interpreter library for these files, and have commands such as Sprite.Draw("name", frameNumber) and your code will extract the x,y location (and size) from the text file, convert those values to uv coordinates to use in your X_OBJADDVERTEX commands (the examples floating around all go from 0 to 1, so only the entire sprite is displayed, not a fraction of one).  Your code could detect multiple frames by the file name, such as "walk01", "walk02", etc to detect animations automatically, and set their start / end limits.  TexturePacker outputs in ^2 sizes if requested too.

Search these forums for sample code for TexturePacker.  I think there are some glbasic libs that read it.  There is another called "DarkFunction" or similar I think.
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-26
Yes that is what I was thinking too, but here is the problem: in GLBasic you can not change the texture coordinates of an 3D object. This means in this project here, you would be either need to create one 3D quad for each texture, or create that rendering quad at render time. Obviously both of this has big drawbacks on memory consumption/ execution speed and is worse then using single textures, without atlas. Thats why I said we could achieve a better result if we would use native OpenGL, because there this would be no problem (see my libSPRITE).
Title: Re: Camera and Polyvector
Post by: Slydog on 2014-May-26
Yes, you can't change the texture coordinates.  You would have to generate a new quad every time the texture changes.  Or pre-generate the various animation frame quads and flip through them as needed.  I suppose this all depends on how many active sprites you have displayed at any one time, plus how many are animated.  I'm sure GLBasic can generate new quads for at least 20 sprites per frame.  I'd be surprised if not 50, but I've never ran this through any testing.  Just comparing to other SDKs such as Unity where this wouldn't be a bottleneck.

Using native OpenGL (and not GLBasic commands), you wouldn't need a new model for every sprite.  A model could be composed from many unconnected quads, and therefore contain all your sprites.  But this may be way worse if you can't update a specific sprite without regenerating all sprite quads.  I think one of Unity's original sprite libraries did it this way, but Unity used arrays to access and work with the vertices, so you knew which array indexes to update for each sprite.

I like the idea of creating a native OpenGL sprite library, and bypass GLBasic altogether.  Is that what your 'libSPRITE' is?
Title: Re: Camera and Polyvector
Post by: matchy on 2014-May-26
Although the OBJADDVERTEX texture coordinates can't be modified, X_SETTEXTUREOFFSET will allow for animation texture cells.  :-[
Title: Re: Camera and Polyvector
Post by: Slydog on 2014-May-26
matchy,
I was already thinking of that.  It would only work if the sprites were the exact same size: just find the new sprite texture location, and offset the texture by the difference.  You could do any sprites this way, just not animations.  Generating a bunch of generic quads at the start, and set to the set texture size (128x128 for example), and just modify the offset to display the proper sprite.  You could reuse quads for different sprites displayed at different times.  (object pooling) 

But every sprite would need to be offset per frame calling the offset texture command multiple times per frame, as opposed to having the texture quads precalculated and quads already setup properly.  Maybe a mixture of the two methods would work best?  (X_SETTEXTUREOFFSET for animations, and normal quad per sprite for non-animations).  Again, only if the source sprites share the same dimensions.  Your mileage may vary!
Title: Re: Camera and Polyvector
Post by: kanonet on 2014-May-27
Slydog libSPRITE is my X_SPRITE replacement that you find here: www.glbasic.com/forum/index.php?topic=7992

It would be easy to expand this to draw non square rectangles. Since its already possible to set texture coordinates (and colour but thats not documented), this would be perfect for these needs here.
But with a bit more work, we could go even farther, it would also be possible to make a 3D Polyvector 'replacement' (I mean draw non rectangles) or even completely abandon the 'turn to camera feature' and allow the fast construction of meshes at rendertime.