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 / Problem with 2D background and 3D texturized object

Author
Message
Belzelcior
15
Years of Service
User Offline
Joined: 23rd Oct 2009
Location: Around here somewhere...
Posted: 28th Oct 2009 21:01 Edited at: 28th Oct 2009 22:34
Hi there,

Absolutely new to the art of basic programming, though I have coded x86 assembler (about 13 years ago), pascal (14 years ago) and some scripting (php, recently).

I'm facing a bit of a problem with my learning phase
The problem is that I've done the 3D rotating cube thingy (but I added a texture) and then tried to get a 2D background behind it...
The 2D background renders OK, but the 3D textured cube has suddenly become 2 cubes and they are both black.



I added my test catalogue to a .zip-file which I've attached if someone is interested to see which images I'm using.

Hope someone could help me, it'd be appreciated.
(btw, nice forum with what seems like nice people )

/Belzelcior (Sweden)


EDIT --
Found one of the problems (the texture were named wrong, should have been "backdrop.jpg" instead of "background.jpg"). The problem with two cubes remain though - haven't figured that one out yet.

Attachments

Login to view attachments
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 29th Oct 2009 06:03 Edited at: 29th Oct 2009 06:20
Offhand, I would say you don't need to make another camera. Maybe that's why you are seeing two cubes, because you have two cameras.

Anyway, I'll download your media and play with your code.

Rich

Edit: Also, is the Advanced image for the cube, or is the backdrop image for the cube? It seems logical that the backdrop image would be for the backdrop, but you have them reversed.

Taking out the code for the extra camera did indeed get rid of the extra cube.

Also, also... you don't really need a sprite, you can put the background image right on the backdrop. Here's your code, modified a bit...



Xyus
15
Years of Service
User Offline
Joined: 5th Sep 2009
Location:
Posted: 29th Oct 2009 07:46
Quote: "Also, also... you don't really need a sprite, you can put the background image right on the backdrop."


The Texture backdrop command is obsolete now, and I think it produces an error when you try to compile with it in the code (I just checked. It doesn't produce a compiler error, but it does produce an error during run-time, for me at least), so if he's using the newest version, I think the sprite thing works as a viable substitute.
Belzelcior
15
Years of Service
User Offline
Joined: 23rd Oct 2009
Location: Around here somewhere...
Posted: 30th Oct 2009 01:50
Thanks for the tip regarding the camera Rich - I thought that autocam was just for updating the camera automatically "This command will activate the auto camera which will reposition when a new object is loaded or created." but I must have misunderstood the meaning of the autocam command.

I took the autocam away since I wish to control my camera as much as possible to my abilities (and since I'm learning) and have found another problem.

The cube is created but when I start the program the cube texture is overlayed on my sprite background (thanks for the tip about texture backdrop Rich, even though I stayed with the sprite background for the moment I'll try the texture backdrop technique later when I've mastered this way of doing it).

I've made some adjustment to my code so it's easier (for me at least ) to read and relate to files (files are now renamed according to my naming scheme and added with the rest of my project as an attachment).



Could someone point me in the right direction regarding the used camera and why the background seems to get a snapshot of the created cube?

Attachments

Login to view attachments
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 30th Oct 2009 02:14
Quote: "The Texture backdrop command is obsolete now, and I think it produces an error when you try to compile with it in the code (I just checked. It doesn't produce a compiler error, but it does produce an error during run-time, for me at least), so if he's using the newest version, I think the sprite thing works as a viable substitute. "


I believe the Texture Backdrop command has been put back in, to keep DBPro compatible with a new plugin they are selling. Or something like that. I've had no trouble using it in several programs, no compiler errors, no runtime errors.

Oh, here are some relevant lines from the 7.4 Upgrade notes...

Quote: " * Added new TextureCameraBackdrop to SNIPPETS to show how to use TEXTURE BACKDROP"


and

Quote: "* Implemented the TEXTURE BACKDROP and related commands"


I'm guessing it was put in for the DarkClouds?

Rich

Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 30th Oct 2009 02:27 Edited at: 30th Oct 2009 02:55
Belzelcior, when I run your code, I get the Advance background, a non-spinning cube with the loading texture, and another cube with the loading texture... that is attached to my mouse cursor!

Very strange.

Oh! I see, you are having the mouse rotate the camera. Got it.

I see you are still creating a second camera. Unless you really need two cameras, it would be better to just use the default camera that is present when you start the program. Otherwise, your program is still showing two cubes, one for each camera. Here is your code without the second camera...



Now, with the above code, the camera rotates, not the cube, so as the camera turns, the cube is lost from view. I'm not sure if that is what you intended, but the code is working as it should.

If you absolutely MUST create that second camera, you can effectively "turn off" the default camera zero by pointing it away from the cube, or shrinking its view to 0,0,0,0.

Belzelcior
15
Years of Service
User Offline
Joined: 23rd Oct 2009
Location: Around here somewhere...
Posted: 30th Oct 2009 02:40
Oh, sorry, forgot to mention that I threw in camera control with freeflight (w and s for forward respectively backward navigation and mouse for looking around )

The extra cube seems to be only the cube texture pasted on the background, but how it got there is a mystery to me. That's the problem with the newest version of the code now that I've deleted the extra camera.

Any ideas?
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 30th Oct 2009 04:07
Quote: "Any ideas? "


Yes, the image is from Camera 0 (that's camera zero, the default camera that is always present). It looks like a pasted image because you do not move camera zero around, you only move camera 1 around.

If you work only with camera zero, and do not create camera 1, your problem with the extra image goes away. See the revised code I posted in my last message.

Xyus
15
Years of Service
User Offline
Joined: 5th Sep 2009
Location:
Posted: 30th Oct 2009 04:28
Quote: " I believe the Texture Backdrop command has been put back in, to keep DBPro compatible with a new plugin they are selling. Or something like that. I've had no trouble using it in several programs, no compiler errors, no runtime errors. "


Funny, I'm patched to 7.4, and still getting the runtime error.

Oh well, this isn't the place for that, I'll investigate later.
Belzelcior
15
Years of Service
User Offline
Joined: 23rd Oct 2009
Location: Around here somewhere...
Posted: 30th Oct 2009 21:30
Rich - thank you for the help and the explanation, I didn't realize that there was a default camera that was always present! (I noticed that my reply was faster than your edit, sorry that you had to explain yourself twice).

Really appreciate it. Thanks!

Login to post a reply

Server time is: 2024-11-24 01:08:35
Your offset time is: 2024-11-24 01:08:35