Rick Posted October 26, 2010 Share Posted October 26, 2010 I've been out of the LE programming for to long I think I have an Actor class that takes a TTexture in it's ctor and stores it in a variable to be drawn later. I then derive other classes from Actor like Knight, Assassin, etc. I then have something like: Knight::Knight(TVec3 position, TVec3 rotation) : Actor(LoadMesh("abstract::Knight.gmf"), LoadTexture("abstract::KnightHeadShot.dds"), position, rotation) { } So I call LoadTexture() and depending on the class what it loads is different. Then in the Actor::Draw() class I draw the texture. The problem I have is that every draw is drawing the same texture. That TTexture isn't defined as static in Actor so why would I be getting all the same textures being drawn even though I load different textures per class? It's not making sense. Note that I do the same thing with LoadMesh() and that works. I get the correct model loaded. So that's even more confusing as to what is happening. Quote Link to comment Share on other sites More sharing options...
MasteR Posted October 26, 2010 Share Posted October 26, 2010 Post up the code for the Actor constructor. Quote AMD Athlon 64 X2 Dual Core 6000+ (3.0 GHz) 4 GB DDR2 RAM 2 x NVIDIA GeForce 9500 GT 512 MB (SLI 1.0 GB) Windows XP Pro Link to comment Share on other sites More sharing options...
Rick Posted October 26, 2010 Author Share Posted October 26, 2010 Actor::Actor(TEntity model, TTexture headShot, TVec3 position, TVec3 rotation) { _model = model; _headShot = headShot; PositionEntity(_model, position); RotateEntity(_model, rotation); } class Actor { private: bool _enabled; // if false they can't do an action TEntity _model; TTexture _headShot; }; Quote Link to comment Share on other sites More sharing options...
MasteR Posted October 26, 2010 Share Posted October 26, 2010 No initial problems here... I assume you're creating objects of the derived classes and that is where you're encountering the issues. What happens when you create objects of the base (actor) class, same result? Or a mix of both base and derived? Quote AMD Athlon 64 X2 Dual Core 6000+ (3.0 GHz) 4 GB DDR2 RAM 2 x NVIDIA GeForce 9500 GT 512 MB (SLI 1.0 GB) Windows XP Pro Link to comment Share on other sites More sharing options...
Rick Posted October 26, 2010 Author Share Posted October 26, 2010 Yeah I create them with: Actor* actor = new Assassin(pos, rot); Nothing is sticking out to me either. I've done stuff like this a hundred times. That's why I'm thinking it might be something with LE's TTexture or LoadTexture() is doing something funky. When I step through the code it's making it into each derived class so it's running each LoadTexture() correctly it seems. Interestingly enough the texture that it's showing for all of them is the Assassin's texture which is the first one loaded. Quote Link to comment Share on other sites More sharing options...
MasteR Posted October 26, 2010 Share Posted October 26, 2010 try: 'protected:' instead of 'private:' with the base class properties. try: TTexture* _headShot; //as the class property _headShot = new TTexture(LoadTexture(FileName.c_str())); //inside Actor constructor and simply pass "abstract::KnightHeadShot.dds" as a std::string argument Quote AMD Athlon 64 X2 Dual Core 6000+ (3.0 GHz) 4 GB DDR2 RAM 2 x NVIDIA GeForce 9500 GT 512 MB (SLI 1.0 GB) Windows XP Pro Link to comment Share on other sites More sharing options...
Rick Posted October 26, 2010 Author Share Posted October 26, 2010 I get the same issue with that. Actor::Actor(TEntity model, string headShot, TVec3 position, TVec3 rotation) { _model = model; _headShot = new TTexture(LoadTexture(headShot.c_str())); } Assassin::Assassin(TVec3 position, TVec3 rotation) : Actor(LoadMesh("abstract::Assassin.gmf"), "abstract::AssassinHeadShot.dds", position, rotation) { } void Actor::DrawHUD(int x, int y, TTexture background) { DrawImage((*_headShot), x, y, imageHeight, imageHeight); } Quote Link to comment Share on other sites More sharing options...
MasteR Posted October 26, 2010 Share Posted October 26, 2010 I can't reproduce it Rick, your implementation works for me. Could be some simple oversight like calling the wrong object Draw() method in your loop. Short of sending me your program (which I'd be happy to compile and look through) I'm at a loss. Quote AMD Athlon 64 X2 Dual Core 6000+ (3.0 GHz) 4 GB DDR2 RAM 2 x NVIDIA GeForce 9500 GT 512 MB (SLI 1.0 GB) Windows XP Pro Link to comment Share on other sites More sharing options...
AggrorJorn Posted October 26, 2010 Share Posted October 26, 2010 perhaps you can test it out with LoadMaterial and paint the material on a dummy model. Quote Link to comment Share on other sites More sharing options...
Rick Posted October 26, 2010 Author Share Posted October 26, 2010 Will it didn't hit me until I woke up this morning what the issue was. Pretty lame too if you ask me The issue was when I am looping through each actor. It was incrementing correctly. Thanks for helping with this guys. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted October 26, 2010 Share Posted October 26, 2010 The issue was that it was incrementing the loop correctly? Quote Link to comment Share on other sites More sharing options...
Rick Posted October 26, 2010 Author Share Posted October 26, 2010 Incorrectly, sorry Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.