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.

DarkBASIC Discussion / Problem texturing .x model

Author
Message
Comrade Robski
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location:
Posted: 22nd Feb 2007 19:23
I'm trying to import a model of a sphere from 3d canvas (the free version that came with DBC) and texture it.

The problem I'm having is that the object is not texturing properly. After some experimentation I have discovered that when I texture object, the whole object is textured with the colour of the 0,0 pixel in the texture image. I have tried scaling the texture, scrolling the texture, with no effect - the whole object is only ever textured with one pixel.

I have tried exactly the same code with sphere I created using MAKE OBJECT SPHERE and it textures the object properly, no problems.

So what's going on? I've searched the forums and I can't find any reference to this, so it must be someting I'm doing wrong. Any ideas?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 23rd Feb 2007 02:27
Is the object a .x file? If it is and it is in the ascii format (i.e. if you open it in notepad you can actually read it), if you post it, I may be able to see if it's a problem in the .x file itself. But instead of a sphere for the example, make a cube (it has less vertices to work with and will be easier to look through the file).

Enjoy your day.
Comrade Robski
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location:
Posted: 24th Feb 2007 15:58
Yes it is a .x model but it looks like garbage in notepad, so I guess it's not ascii. I have the same problem with a cube or any other object I make in 3d canvas and load.

Any ideas anyone?
NanoGamez guy
18
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 24th Feb 2007 18:23
what do you mean it looks like garbage?

I can see you...
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th Feb 2007 13:33
@Comrade

Well, I ran a few tests using a binary x file and an ascii x file and there is a template that controls the UV mapping (how the texture is stretched on the object) called MeshTextureCoords. And this can be absent in a directx file and causes the symptoms that you describe. It's not very easy to create UV mapping in DarkBASIC, so that leads me back to 3d Canvas. I haven't used that program much at all. I would suggest reviewing the export options and see if there is anything that allows you to choose whether or not to export Texture Coordinates.

The other thing, If the texture created in 3d Canvas is not exported as a bitmap file that is tied to your object, then your object will just inherit the color of the material (usually the Difuse color). Also, DBC is based on directx 7 and successful directx files have bitmaps as textures (not jpegs, png, gifs, etc) and the file names of the textures are in the 8.3 format (max 8 characters for the name and 3 characters for the extension).

The bitmap also has to reside in the same directory as the model.

You can however load a jpeg or other picture file type as an image directly into DBC and then texture an object inside of DBC with that. This is because the file is converted to a DIB image that directx can use as a texture. And when you create an object in DBC like MAKE OBJECT SPHERE, it will texture correctly because when you create it, it is being created with UV coordinates.

If you could still post the object you are creating in 3d canvas, I figured out for the most part how to translate a binary directx file and can take a peek to see if it is including texture coordinates - or even a reference to your texture file.

Enjoy your day.
Comrade Robski
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location:
Posted: 26th Feb 2007 19:07
Thanks very much for all your help with this Latch.

I'm using a bitmap texture that I loaded into DB using LOAD IMAGE - the texture didn't originate from 3d canvas. And it is in the same directory as the model (and the DB project).

I'll post the .x file tomorrow (at work at the moment). I'll also play around with 3d canvas tonight and see if I can find an option to export texture coordinates like you describe.

Again, thanks for your help with this!
Comrade Robski
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location:
Posted: 27th Feb 2007 19:09
Here's the file (planet.x). Didn't have time to mess around with 3d canvas but I'll give it a shot tonight.

Attachments

Login to view attachments
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Feb 2007 22:02
I took a look at your file. All of the Texture Coordinates are set to zero. So your texture isn't stretched across the mesh. That would explain the monotone color. I'm guessing there are some export options within 3d canvas. If there aren't any for Directx, see if it has the option to export to 3ds. If not, try Anim8or or Deled Lite. Both are free and relatively easy to use. If you want a challenge, try Blender. I wrote an export script specifically for DarkBASIC Classic if you go the Blender route.

Enjoy your day.

Login to post a reply

Server time is: 2025-05-29 07:08:06
Your offset time is: 2025-05-29 07:08:06