Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / object/screen coords || more image stuffs

Author
Message
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 19th May 2005 21:24
I have a bit of a conumdrum, the answer is either going to involve some sort of object/screen coord thing or a new imaage function (thus the topc )

In my game im using textured plains for various gui things like menu screens. The reason i needed image-to-image from the other post was to beable to generate some of the textures for these screens manually. I can now do that, the last step is adding the text to these menus.

Obviously when you make a plain you set its size in dbp units and not pixels. As such, I cant gurantee that my plain is the exact size on screen as my image would be pasted. With images this isnt a problem, I just paste my images into the texture image and it will automatically be stretched. But what is the best way to draw text?

if i know that x * 32, y*32 is a location for itemX -inside my image- and the same thing but with y+10 is where i want to draw some text for the item, how would i translate that to the screen based off where the textured plain was positioned (its locked to the screen) and its size? Or am I stuck with trial and error writing absolute co-ordinates for the text and running it until it looks right then doing the same for the various screen resolutions? :/

Alternitivly, and possiably even better, would be a dbTextInImage() function which would be the same as dbText except it draws to an image instead of a bitmap. Is this possiable? I dont even know where i would start writing something like that one! But if i could i guess that would be pretty cool.

I dunno, recommendations please?

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 19th May 2005 21:44 Edited at: 19th May 2005 21:54
Is there a reason you didn't just use sprites for your locked plains?

If you couldn't then I guess that drawing text to a texture-based surface is the same as drawing text to any other surface in DX ... however that is done.

Alternatively, you already seem comfortable with low-level surface manipulation - you could display your text to a standard DBPro bitmap, and copy from that surface to the texture surface.

[edit]

Actually, it seems to be pretty simple

http://www.two-kings.de/tutorials/d3d09/d3d09.html
You should only need to make a few changes to get it working with DGSDK

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 19th May 2005 22:23
the main reason for not using sprites was so i could use the Basic3d command set to do stuff like rotate the gui on its Y axis and stuff allowing me to perform various special effects for the menu's. I could do anything i liked with ghost object etc, but im mainly in it for the Y axis rotation atm so I can kinda turn my menu around when you select a new screen and basically by the time its finished a complete turn the new menu is on it and other such spinny goodness.

I dont belive thats possiable using just the normal sprite command set.. is it? x_X

There is also the fact that the plain will be automatically adjusted and always look "right" even if screen resolutions change

Looking at that text thing. Only took a quick glance but it doesnt appear to show you how you can make it render to a surface or change the surface it renders to, just normal text drawn on a screen?

Will look more througherly after i have eaten something ^^

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th May 2005 05:33
With you needing the rotation, then there's not really another way to do it.

As for how the D3DXFont object know which surface to render upon, if you combine that tutorial with this one too (http://www.two-kings.de/tutorials/d3d16/d3d16.html) you can render to any surface you want, including a texture surface.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 25th May 2005 23:17 Edited at: 25th May 2005 23:20
It appears not. The thing is i want to render to already existing images (textures) rather than creating a new one. and to render to the texture it HAS to be created with the D3DUSAGE_RENDERTARGET flag :/ and I expect it probably has to be in the default memory pool as well, im learning to hate directX.

I came up with this function:


You'll notice its not quite the same technique as in the tutorial you linked me to, but thats because it seems the tutorial contains old and outdated information that caused errors with my build of directx. I had to look up the functions in the help file to see what structs etc it really wanted.

Oddly, it does draw text. But it draws it to the screen and not the image. d3d debug output states:



so i'm a bit buggered I think. Unless someone has some -really- clever ways around this the only possiable alternitive i can think of is to try and make a new, blank, image using the internal command dbMakeUsage(), specifying it as a render target, filling it with a transparent colour, drawing my text to it, making a SECOND gui plain and positioning it just slightly infront of my current one, texturing it with my new image and then turning transparancy on. But I dont like that. I dont like that one bit.

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
walaber
20
Years of Service
User Offline
Joined: 22nd Oct 2003
Location: Los Angeles, CA
Posted: 26th May 2005 17:39
I think "RenderTarget" is only necessary if you want to render 3D polys to the image (aka render a camera view to a texture).

in the past when I made a menu system from textured plains, I just calculated the proper distance away from the camera so that a plane of size (800,600) filled the screen perfectly. then I just locked it to the camera so it was drawn over all other objects. from then on, you can place your other plains with standard DB space units, but they are equal to pixels.

as for the images stuff, I made a simple bitmap font, and then used memblock commands to create images on the fly by pasting the letter images together into one final image that was then textured on a plain. worked great for Snowball Fight, and Ragdoll Monkey Bowling, both of which use it.

I think i still have the source around it you want to look how I aligned the planes on the screen.

Go Go Gadget DBPRO!

Athlon XP 2400+ || DDR-SDRAM 1GB || Nvidia GeForce 4 Ti4200 AGP 8x 128MB
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 26th May 2005 20:08
I would indeed be very interested in seeing how you calculate their distance from the camera, thanks

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
walaber
20
Years of Service
User Offline
Joined: 22nd Oct 2003
Location: Los Angeles, CA
Posted: 26th May 2005 20:33
I'll look for the source, but in the meantime it's pretty easy to calculate using trig if you know the camera FOV.

basically the FOV/2 is the angle of a right triangle, and the opopsite side is the your desired screen width/2. then you solve for the adjacent side, and that's the distance to position it away from the camera.

in other words, plane distance from camera "D" can be calculated like this:



then place a plane the same size as your screen at that distance from the camera, and you have a full-screen plane.

Go Go Gadget DBPRO!

Athlon XP 2400+ || DDR-SDRAM 1GB || Nvidia GeForce 4 Ti4200 AGP 8x 128MB
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 26th May 2005 22:16
I am having a bit of a problem with it, walaber :/

It isnt filling the screen how i expected and its making the plane tint white X_x I tried rotating it 180 on the Y axis to see if that was the colour problem, but it wasnt.

take a look at this screenshot:
http://melted.com/spectural/storage/Shisaku/plainintheass.jpg
(excuse the file name, my humour isnt at its best )

heres the code I used to make and position it:



where did I go wrong? :/

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
walaber
20
Years of Service
User Offline
Joined: 22nd Oct 2003
Location: Los Angeles, CA
Posted: 27th May 2005 20:31
you should be dividing the FOV by 2... I don't think your FOV is set at 130 degrees, is it?

try that and see if it helps.

Go Go Gadget DBPRO!

Athlon XP 2400+ || DDR-SDRAM 1GB || Nvidia GeForce 4 Ti4200 AGP 8x 128MB
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 27th May 2005 20:55
It is being divided by 2?

dbPositionObject(MENU_PLAIN, 0, 0, (dbScreenWidth()/2) / (dbTan(61.9621391296 / 2)));
?

or do you mean
dbTan((61.9621391296 / 2) / 2))?

.. well i tried that just incase and it just made the plane disapear completly

and i have no idea what the FOV is, I havnt changed it manually through code at any point so i searched these forums for the default and they said 61.9621391296 was the default fov.

I'm being dumb somewhere arnt I?

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
walaber
20
Years of Service
User Offline
Joined: 22nd Oct 2003
Location: Los Angeles, CA
Posted: 30th May 2005 17:44
a! never mind, dividing by 2 once is right. but you need to do atan() not tan()!

Go Go Gadget DBPRO!

Athlon XP 2400+ || DDR-SDRAM 1GB || Nvidia GeForce 4 Ti4200 AGP 8x 128MB

Login to post a reply

Server time is: 2024-03-28 10:15:50
Your offset time is: 2024-03-28 10:15:50