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.

Newcomers DBPro Corner / putting text in 3d

Author
Message
sjonny
17
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 1st Jan 2007 12:22
hello guys, i need to make a sign with text on it but it is in 3d. how can you print a text in 3d?
wildbill
18
Years of Service
User Offline
Joined: 14th Apr 2006
Location:
Posted: 1st Jan 2007 14:52
If you are trying to put it on the image texture its simple, just write the text on the image and texture the object.

If you want the text to change every so often, just make several images and re-texture the object.
steve c
20
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 1st Jan 2007 18:35
okay i thought he meant how do you make text 3d, and if so u cant print it whith a db command u have to make it in a 3d moddeling program, for instance milkshape 3d which also handily has a text generator.

you just put in what you want and it makes it 3d, you can also change the font. hope that helps.

if thats not what u meant just forget i posted.

no current projects starting db from scratch, so i can program stuff well, noob tutorials ime coming.

despite what it sais to the left joined 5 december 03
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 1st Jan 2007 19:30
If you actually want to make 3d text you can use Cloggy's d3d_func dll.

If you just want to put it as an image on the object just use get image.



sjonny
17
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 2nd Jan 2007 14:11
i want to print some text on a box like this:



how to do that? i tried the print and the text command but they only do x and y but not z
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 2nd Jan 2007 14:35
What you need to do is forget about the concept of 'Text' in 3D and start thinking of textures - in this case, 'pictures of text'.

When you create a 3D object like a box, you can paint it with a texture. All you need to do is turn the text into a texture.

You'll learn more if you work it out yourself so I won't put code here - just the method:

1. Create a second (hidden) bitmap (1) and use the Text command to print the required text.

2. Use Text Width() and Text Height() to find out the pixel width and height of the text you've printed and then use the values returned with the Get Image command to grab the text into an image.

3. Set the current bitmap back to 0 and delete the second bitmap.

4. Use the image to texture the 3D object.

That's it. The only drawback is that all of the object's sides will be textured. If you are using a box or cube and this isn't what you want, there's a simple work-around.

Create a 3D Plain the same dimensions as the object's surface you want the texture on and attach it to the object. Then, simply texture the plain - rather than the box.

TDK_Man

Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 2nd Jan 2007 15:00 Edited at: 2nd Jan 2007 15:04
This code allows you to put one piece of text onto an object.



Edit: Listen to TDK's advice and learn how this works. This isn't 3d text, this is text made into an image which is then put on the object. I wouldn't have posted the code here if I had seen TDK post, but I was writing this code when he did.

sjonny
17
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 4th Jan 2007 16:39
i'm sorry, but i'm not that good with bitmaps and functions. can you explain this a bit more? the examples in darkbasic itself aren't clear to me.
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 6th Jan 2007 00:08
Sorry, on my last post I got carried away and made my example unnecessarily complicated.

I am reposting my example but I have taken out the useless, and probably confusing, random word chage part of the code. I have also added plenty more comments to my code explaining almost every command.

The function is not perfect. It creates the image on the screen instead of in a bitmap like tdk suggests. Putting it on the screen means that for 1 loop the text is in the top left corner.



I am not sure how much you know, so please don't feel insulted if I explained commands which are already clear to you.

sjonny
17
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 6th Jan 2007 10:00 Edited at: 6th Jan 2007 10:01
this gives a syntax error ( function declaration has unknown parameter ) at my screen:

function text_object(text$,objnum,textcolor as dword,backcolor as dword)

im using darkbasic classic, so this could be working on DB pro.
sjonny
17
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 8th Jan 2007 09:19
please help me. i need a answer to this. i just want to put some text in a 3d game so it doesn't has to rotate or something.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Jan 2007 20:45
OK, here's how it's done:



As you can see, all six sides of the box are textured. You can't specify just one side.

To get around this, you create a plain as well as the box and glue the plain on the front of the box. You then texture the plain - not the box.



Finally...

Quote: "i'm sorry, but i'm not that good with bitmaps and functions"


I get the feeling you are trying to run before you can walk. Bitmaps and Functions are just part of the fundamentals of programming and in my opinion, you need to know things like that before you start working in 3D. If you don't you'll only come unstuck later on.

I seriously suggest that you spend some time reading some of the many tutorials before going any further. You won't regret it!

TDK_Man

sjonny
17
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 9th Jan 2007 09:00
thank you TDK_Man, i still need to adept it a bit but this is what i ment. i know i should go through more tutorials, but i'm still at school and i need to study as well. i'm making this for a project on school ( this is the subject i chose because it should bve something you are interest in ) and this needs to be finished in like two weeks. that's why i'm asking this on a forum. It would be better if there wasn't a deadline. i will learn more about it when i'm finished with the project.

sjonny
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 9th Jan 2007 12:09
No problem - good luck with the project!

TDK_Man

sjonny
17
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 10th Jan 2007 21:24 Edited at: 10th Jan 2007 21:27
i'm sorry TDK_man i need your help again how can i get the textured object not to spin and settle it in my game. i tried to position it, but this worked out in an error so could you please help me another time?
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Jan 2007 00:59
In the code I posted, in the main Do..Loop the line which rotates the object is:

YRotate Object 1,WrapValue(Object Angle Y(1)+1)

If you remove that line, it will no longer rotate.

TDK_Man

sjonny
17
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 11th Jan 2007 17:09
ok thanks that is what i got but how to position it in my game when it isn't moving?
sjonny
17
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 14th Jan 2007 09:29
can i please have a answer to this because this is pretty necessary in my game.
Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 14th Jan 2007 09:32
if all fails use UV mapping

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 14th Jan 2007 10:27
Quote: "ok thanks that is what i got but how to position it in my game when it isn't moving?"


Quote: "can i please have a answer to this because this is pretty necessary in my game."


I don't do much in 3D but when you create objects they stay right where you created them. You can reposition an object with the "position object" command.

Syntax:
position object ObjectNumber,X#,Y#,Z#

Once that command is used it goes right back to staying where you put it till you move it again with that same command. If objects didn't have this staying ability whole buildings would fall apart when you move.
sjonny
17
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 14th Jan 2007 11:05
no it isn't that but when i position it it doesn't work with tdk_man's code. i tried to figure it out but it doesn't work.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 14th Jan 2007 14:13
You just need to add some controls. The following uses TDKs code with the arrow keys, "Q", and "A" to move the object around the screen. It also shows the current x,y,z coordinates on the screen to show you just where that object is sitting in 3D space.

sjonny
17
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 18th Jan 2007 14:43
im sorry for this late reaction. i tried to fix this but how can i position it for example between my walls?
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 18th Jan 2007 15:55
It's difficult to help you further, because you've not posted any code for us to look at.

However, your 'walls' have been placed in 3D space using X,Y,Z co-ordinates. In DB, ALL objects when created are placed at X=0, Y=0, Z=0 and you move them to where you want them with the POSITION OBJECT ObjNum,X,Y,Z command.

Have you got a floor (matrix)? If so, and you were directly above it looking straight down, the bottom left corner would be at co-ordinate 0,0,0.

From that corner, increasing the X co-ordiante of an object would move it to the right and increasing the Z co-ordinate would move it up. Increasing the Y co-ordinate would increase the height of the object above the floor.

So, you need to get a pen and paper and draw on it where the walls are, along with their X and Z co-ordinates.

Only then will you be able to calculate what X,Y,Z values to use in order to position something in a specific location.

TDK_Man

sjonny
17
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 18th Jan 2007 16:33
i know where to place them but tdk_man i need to have it in your code that i can position the object which is used. so i need to combine this code:

tdk_mans code



and the position object ( texture )



i couldn't put it into your code for some reason maybe you can?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Jan 2007 18:10
Think about it a little.

First, you want to position the object. Well, you can't do that until you have created it can you? So now you know that you want to put that command after the object creation somewhere.

Next, once an object is positioned, it won't move until *you* position it somewhere else. That suggests that you don't need to repeatedly position the object, which in turn suggests that you don't want to put the command within the loop.

Now, how many places are there where the code can go, after the object has been created, but before the loop?

Login to post a reply

Server time is: 2024-09-25 15:24:19
Your offset time is: 2024-09-25 15:24:19