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 / i cant load an image

Author
Message
paint color
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 16th Sep 2008 03:26
for all you codemasters out there this should be a 'duh' question, but whenever i try to load a .jpg or .bmp image it dosnt work. i want to use them as textures if that helps.

here is what i type in DarkBASIC:

LOAD IMAGE "dbtxtr1.bmp",1,0
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th Sep 2008 09:22
Well, what do you do more than that line?
LOAD IMAGE just loads the image data into memory, it doesn't apply it (like show it, texture with it) or anything by itself.
Also, are you sure that the image is in the working directory, or you'll have to specify an absolute path (eg C:\images\img.bmp).

"I kören hörs de brummande busarna Björnligan och Gondolen"
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 16th Sep 2008 13:12
If you want to view the loaded image, call:



If you want to make the object a texture, do this:


(As Rudolpho says, the image will only load if it's found in the current working directory, i.e. the same folder as the source code. Otherwise, you'll need tio specify the full path).

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
paint color
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 16th Sep 2008 21:45 Edited at: 17th Sep 2008 01:50
that seems to be the right way to do the texture, but whenever i type that in it says this in an error window:

runtime error 506-could not load image at line 7

<edit> never mind, i didnt read rudolfs full post telling me to verify a complete path for the image. im making a solar sytem right now. but i have a question, say i have planet earth that is under the yrotate command. how could i make a moon that orbited the earth?
paint color
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 17th Sep 2008 01:54
this is off topic, but whenever i do a 3d application (i.e. the solar system i was working on) it always has a blue background. how could i change it to, say, a black background with stars.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 17th Sep 2008 02:28
Make sure the image is in the same folder as your code. The LOAD IMAGE command (as well as all other LOAD commands) starts out in the project folder, following the path you specify.

epithika
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: Music composer for games
Posted: 17th Sep 2008 05:09
if your image is in the exact same folder as your darkbasic file then using that code will work, if you have put your image in a folder then use:

load image "foldername/imagename.bmp",1,0

Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 17th Sep 2008 13:31 Edited at: 17th Sep 2008 13:42
Quote: "im making a solar sytem right now. but i have a question, say i have planet earth that is under the yrotate command. how could i make a moon that orbited the earth? "


Going off topic to answer your question, you could try one of two things. First (I think these commands are still in DBPro, I'm not sure as I'm in DBC mostly) you could try something like:

This should leave the Earth Object with the Moon as a"Sub-Object" or Limb. The moon will be located inside the earth until you call "Offset Limb 1, x, y, z" which will reposition the moon to be beside the Earth - exactly where depends on your choice of x,y,z. As you Y-rotate the Earth, the moon will move around the Earth. By calling "rotate Limb 1, 1, 0, y, 0", you can make the Moon rotate on its axis as well.

Unfortunately, it isn't terribly realistic (the moon orbits the Earth once every day instaed of once every month). If you want a better representation, you need to brush up on orbital mechanics (which I've never understood). Google is your friend and if you're really interested then something like this might be useful. The Maths looks a bit horrendous, so Good luck!

[Edit]
Just found this on the DGDK board. Haven't tried it, but it might be good if you port over to DBPro. It's not so horrendous as Kepler.
http://forum.thegamecreators.com/?m=forum_view&t=136959&b=22

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 17th Sep 2008 20:45 Edited at: 18th Sep 2008 22:19
It's simple enough to make a simple, circular orbit (actual planetary ones are more or less ecliptic, but let's assume we won't need to be all that precise here).

This is a small example in which object 2 will circle around object 1 at a radius of 750 units:


In this code, the value you increase t# with determines the centripetal velocity. 750 * the trigonometric functions is how far away from the centre (which here is 0, 0, 0) you want your sattelite to be. Just add constant values to these, should you want it to orbit some other point than the centre.
Example:

This will make object 2 orbit around (50, 0, 50) instead.
Hope that helped

"I kören hörs de brummande busarna Björnligan och Gondolen"
paint color
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 18th Sep 2008 01:08
thank you both, rudolfo's code worked best for me because i could add it in to my already working app. yours was also helpful robert, since it was a little simpler. anyways, ill be making moons for more of my planets now. thank you.
paint color
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 18th Sep 2008 01:18
the moons rotation works fine but i cant seem to make earth yrotate, does this have something to do with the moon being attached to it?
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 18th Sep 2008 13:24
Quote: "Does this have something to do with the moon being attached to it?"

Not sure, I would actually hazard a guess that it's one of two things:

One (most likely) is that you're using "Set Camera to Follow", or some similar camera system, in which case no matter how you rotate the earth, the camera will always be positioned to the back of it. As a result, it may never appear to rotate.

Two (possible, but I doubt it) is that you are calling "YRotate Object Earth, 1" expecting it to increase the Y-angle each cycle. If that is the case, then you need to try calling this each loop:



Hope this helps!

@Rudolpho
Interesting method, and a lot neater than any of mine. I knew there was some way to split the equation for a circle down ino parametric equations, but I couldn't figure it out (and Google wasn't much help either).

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 18th Sep 2008 22:22
Hehe, been going on and on with the unity circle for the last year...
(For mathematical trigonometrical purposes, not so much programming, that is).

"I kören hörs de brummande busarna Björnligan och Gondolen"
paint color
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 19th Sep 2008 02:30
it didnt work, i think its because it has the moon moving around it or somthing, but the camera is not set to follow it
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 19th Sep 2008 21:03
Not sure why the code shouldn't be working - it ought to work fine. I've knocked up a sample program based on the code Rudolpho provided, and a (simplified) version of the YRotate object code I suggested. It's in the attached Zip, and involves everything you've been asking about (loading an image, texturing objects, and orbiting moons).

The program works fine in DBC, and I don't see any reasons why this shouldn't work in DBPro. Hope this helps!

(By the way, sorry about the quality of the planet texture. It was just something I knocked up in paint in about 20 seconds).

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."

Attachments

Login to view attachments
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 20th Sep 2008 14:15
@Rudolpho - As you presumably know, this could be generalised to do an elliptic orbit or simple harmonic motion, like so:

position object 2, (500 * sin(t#)) + 50.0, 0, (750 * cos(t#)) + 50.0

The optomist's right, The pessimist's right.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 20th Sep 2008 15:42
Haha, I didn't even think about that, calcyman.
Of course

"I kören hörs de brummande busarna Björnligan och Gondolen"
paint color
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 27th Sep 2008 00:43
aha! thank you rudolpho and robert, i have texture both earth and its moons, to make a pretty cool looking planet, ill post it in a second. also, by slowing the earths rotation to less than the moon, i can make them look a little more realistic, even though im not a space person. looks pretty cool to me, tell me what you think.
paint color
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 27th Sep 2008 01:09
thanks, heres the complete project with some textures i got off google.

Attachments

Login to view attachments
paint color
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 27th Sep 2008 17:03
and yet another question by the ultimate dbpro noob. the background is the standard blue color. is there a way i could change it to a starry night or somthing like that. i know i can make it just plain black, but could i add little white dots for stars or something?
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 27th Sep 2008 19:26
Depends how much you want to do. As you said, you could call "Colour backdrop 0" and that will make a black "sky".

Alternatively, you could load a night sky image, and call "Texture backdrop NightSkyImageNo".

The other ways introduce you to skyboxes and skyspheres. What you do is create an enourmous cube or sphere (maybe 13000 units, depends on how big your worlds are) only make it inside out:


When you apply a night sky texture to the object, it will only be visible when the camera is inside the object. You'll need to position the skybox at the location of the camera each screen refresh if your moving the camera (not sure if that's an issue, I haven't actually run your program yet - but it's just finished downloading! )

This is the code that Riftspace uses to generate the star backdrops (if you've played the game, then you'll notice the nebula clouds - these are (I think) .png files that are textured onto skyspheres). It comes from an example that Riftspace's creator releasesd explaining how to do lens flare.


(This uses an alternative method of making a large normal object, then scaling it using negative numbers - this also turns it inside out.)

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
paint color
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 27th Sep 2008 22:27 Edited at: 27th Sep 2008 22:28
thank you, ill soon be adding some stars to the solar system. i also added some camera commands so you can move around. like a spaceship. now, if you havnt notices, the earth and moon are not exactly smooth. they look sort of wirey. when i use the smooth object command it does nothing to help that. what am i doing wrong?
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 28th Sep 2008 13:51 Edited at: 28th Sep 2008 13:52
Quote: "the earth and moon are not exactly smooth. they look sort of wirey. "

By that, do you mean pixelated? (The objects seem to have jagged, squared-off edges?) If so, then the problem lies with screen resolution.

By default, DB sets the moniter to be 640x480 pixels and the image gets stretched over the screen to fit. Choose a higher resolution and the image will need less stretching/enlarging and so it will appear with "smoother" looking edges. You can increase the resolution by calling "Set Display Mode Width, Height, Depth". Try something like 1024, 768, 32. The 32 refers to the bit depth, which is a control over how many different colours can be shown on screen.

Set Object Smoothing will have no effect because it's controlling how the Object's normals are blended. Each object is made up of several points (vertices) connected by lines (edges). With no smoothing, the edge will appear as a hard crease like a folded card. With more smoothing, the edge gets softened until it becomes rounded like a gently curved piece of card. You get greater control of the edge properties in 3d editors like Anim8or, where you can set each individual edge to be hard surfaces or smoothly sculpted.

(By the way, I've been running your solar system program and i think it looks great!)

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
paint color
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 28th Sep 2008 15:02 Edited at: 28th Sep 2008 15:08
ok, so youre teling me that i cant get rid of the hard creased cards in dark basic. ok, i had downloaded amin8tor a few years ago, just to experiment with 3d stuff, and it seemed powerful enough. so i need to use one of those objects to run my darkbasic program with smooth edges?

and i decided that i couldent make a realistic game with all the planets in the solar system, i decided to make a more realistic earrth system, with the spacestation and and way bigger planets, im also adding a spacship model to the mix. ill see what comes out of it

i have run into yet another problem. i wish to use the a and d keys as controls in this game, would i have to use variables to give them commands? if so, could i get an example?

and thank you all, especially robert, for helping me with this
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 29th Sep 2008 22:13
You can get rid of the hard creased edges.
Compare the following:

Make Object Sphere 1, 100
Make Object Sphere 1, 100, 32, 16

The optomist's right, The pessimist's right.
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 29th Sep 2008 22:18 Edited at: 29th Sep 2008 22:19
Quote: "ok, so youre teling me that i cant get rid of the hard creased cards in dark basic."

I'm not actually sure I can see what you mean, the object's look quite smooth to me. Could you post a picture please that highlights these hard edges? (If you're not sure how to grab a screenshot, run the program, hit Print Screen(PrtSc) then close the program, load up MSpaint and press Ctrl+v. Save the image as a Jpg, and attach to your post )

Quote: "i have run into yet another problem. i wish to use the a and d keys as controls in this game, would i have to use variables to give them commands? if so, could i get an example?"


Simple enough:


This will work for lower case letters (i.e Shift not pressed). If you want to use Shift then you need to use something like this:



Quote: "and i decided that i couldent make a realistic game with all the planets in the solar system"

Oh I don't know - ever heard of Orbiter? (Not exactly a game, but just imagine what it'd be like with alien spacecraft to blow to smithereens!)

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
paint color
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 3rd Oct 2008 04:16
the reason you dont see the edges is because i have made huge changes to the program. its to big to load onto the forums here and im to laz to bother with that filedropper crap. but heres a screenshot with some artistics done in paint.

Attachments

Login to view attachments
paint color
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 3rd Oct 2008 04:22
pretty much, that game is about 300 mb in size. im still working on it, the reaon is i decided to make a realistic earth system. that involves the moon and earth being enormous. if i want the textures to look realistic, then i need big images.

these are the following improvments made to the program posted a few posts above:

camera controls including:
roll left and right
pitch cam. up/down/left/right
and move forward with space bar

i made larger planets and a sattelite
a nice skysphere textured with a starscape image.
and last but actually least a loading screen

Login to post a reply

Server time is: 2024-11-24 19:33:28
Your offset time is: 2024-11-24 19:33:28