no textures/milkshape3d

Started by
7 comments, last by CrystalClear 18 years, 9 months ago
hi @all! i have this problem: i downloaded the nehe sdk (very cool) and now wanted to make a pong-opengl-clone as a first program. i want to use a ms3d model as the ball, just for testing model loading. so i created this cool ball and put in some model loading code. but when i start the app, the ball has no textures! its just white! i saw something in milkshape.cpp that says only milkshape 1.3 and 1.4 models are supported. i have milkshape 1.7.4. does anyone know if there is some newer ms3d loading code? (i change the line from 1.4 to 1.7, now i have a kind of black brown ball, lol). plz help ^^
Advertisement
check if you have texturing enabled ( glEnable(GL_TEXTURE2D) etc)

also check to see if your textures are loaded
if your ball is textured, do you provide the texture image file with the model file? I mean, do you have the jpg (ar tga or whatever) in the same dir with the ms3d file?
I dont remeber if the texture filename is absolute or relative to the model..... you should check that also
i think i made everything right, because this cross model from nehe's lesson 31 tut is loaded properly. and yes, i put the teture in the right directory. for testing, i set the texturing to false and changed the material of the ball to a green color, it appears green too in the program, but if i set texturing to true, its almost invisible because of the black color. o already changed some of the diffuse, emmissive etc. colors but it stays black. any ideas?
Common texture errrors:

a) texture is not power of 2
b) texture not loaded
c) texture file not found
d) wrong texture parameters

Most of this can be cought if you check for errors after glBindTexture(). Also make sure that you check that there are no errors while reading the texturefile. If fopen() returns NULL, make sure to check the errno value.

if you have lighting enabled, you might also have set wrong lighting parameters. Try without.

Don't be lazy, check for errors, when there can be some. (this I learned the hard way :)
here is the modified source code of the model loading example from the nehe sdk:

<quote>
// example 7: model loading

#include "opengl.h"
#include "view.h"
#include "texture.h"
#include "text.h"
#include "md2.h"
#include "milkshape.h"
#include "model.h"

using namespace NeHe;

static bool init=true; // initialisation flag
static Texture tex; // the texture manager
static Model model; // the marine model
static Model kugel1; // the jeep model
static MD2 md2; // the MD2 model loader
static Milkshape milk; // milkshape model loader
static int numframes; // number of frames
static int frame=0; // present frame
static float framepos=0; // frame position
static View view; // the view controller
static Text2D txt; // 2d text handler
static int fps; // the last fps
static int fpsct=0; // fps counter


void InitScene(OpenGL *gl,ControlData *cont)
{
//
// Setup the font
//

// choose a font
TextType ttype;
ttype.name="Courier New";
ttype.size=12;
ttype.bold=true;
ttype.italic=false;
ttype.underline=false;
// setup the text handler
txt.Setup(gl,ttype);

// load the model file
if(!model.Load("data\\tris.md2",md2,tex))
cont->quit=true;

// load the jeep
if(!kugel1.Load("data\\test.ms3d",milk,tex))
cont->quit=true;

// get the number of frames
numframes=model.GetNumFrames();
}

void DrawScene(OpenGL *gl,ControlData *cont)
{
// initialize scene
if(init)
{
InitScene(gl,cont);
// do we need to quit?
if(cont->quit)
return;
init=false;
}

// draw the model
view.Translate(5.0f,0.0f,-50.0f);
view.Rotate(-90.0f,0.0f,1.0f,0.0f);
view.Scale(0.5f,0.5f,0.5f);
//model.DrawTimeFrame(0,framepos);
framepos+=cont->framelength*0.012f;
if(framepos>=198.0f)
framepos=0.0f;

// draw the jeep
view.Reset();
view.Translate(0.0,0.0,-80.0f);
view.Scale(0.2f,0.2f,0.2f);
//(cont->state)->SetLighting(true);
//(cont->state)->SetLight(0,true);
(cont->state)->SetTexturing(true);
kugel1.DrawFrame(0);
//(cont->state)->SetTexturing(true);
//(cont->state)->SetLighting(false);

// do we need to restart the animation?
if(frame>=numframes)
frame=0;
// check fps?
if(fpsct==0)
{
fps=cont->fps;
fpsct++;
}else if(fpsct>=cont->fps)
fpsct=0;
else
fpsct++;

// write out the FPS
(cont->state)->SetColour(Colour(1.0f,1.0f,1.0f)); // Write out in white
cont->state->SetTexturing(false);
view.Reset(); // reset the view
view.Translate(0.0f,0.0f,-0.11f); // translate back a little
view.Pos2D(-0.055f,0.035f); // move to top left
txt << "FPS:" << fps; // and write out the FPS
cont->state->SetTexturing(true);


}
</quote>
Hi,
if i remember correctly i had the same problem a while ago
i can't be sure, but i think the problem was that newer milkshape versions store texture filename differently than previuos versions (i cant remember how exactly)...
I suggest you to check where the filename of texture is extracted from milkshape file
Jnz86 is right, older Milkshape models used an absolute path but newer versions, possibly ones after 1.4 - I'm not 100% sure, use a relative path. You say you downloaded the SDK, which version did you download? There's a SDK for 1.7.x models I'm sure; yep here it is: clicky (51Kb).

If this doesn't fix your problem them nefthy's list of items to check is a very good place to start debugging your code.

Good luck :)
--
Cheers,
Darren Clark
thx for the suggestions, but i downloaded the NEHE-SDK not the ms3d sdk. well, i found out something funny: i merged my fancy ball with the old cross model from nehe's lesson 31 and applied the material of it to the ball. i saved it and started the program, and voila, the ball has a wood texture!
i think the file formats cause this "no textures"-bug. has anyone a loader for 1.7.xx files, or knows how to change the existing code?
Old problem this one, search the web for Brett Porters site REAL SOON , he has the updated 31 lesson which I downloaded and got to work since he wrote it in the first place


Later


CC

This topic is closed to new replies.

Advertisement