• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Ty Typhoon
      I like to build my A - Team now.
       
      I need loyal people who can trust and believe in a dream.
      If you got time and no need for direct pay please contact me now.
       
      We cant pay now, you will recieve a lifetime percentage if the released game will give earnings. 
      If I get the best people together for a team, everything should be possible.
       
       
      What i need:
      - Programmer c++
      - Unity / Unreal - we must check whats possible, please share your experience with me.
      - Sculpter, 3D Artist
      - Animator
      - Marketing / Promotion 
       
       
      What i do:
      - Studio Owner
      - Director
      - Recruit exactly you
      - Sounddesign
      - Main theme composing
      - Vocals
      - Game design
      - Gun, swords, shields and weapon design
      - Character, plants and animal design
       
       
      Please dont ask about the Name of the Game, about Designs or Screenshots.
      The game will be defintitly affected about our and your skills if you join the team.
       
       
      Planned for the big Game:
      - 1st person shooter
      - online multiplayer
      - character manipulation
      - complete big open world with like lifetime actions and reactions
      - gunstore with many items to buy
      - many upgrades for players
      - specials like mini games
       
      So if you are interested in joining a team with a nearly complete game idea, contact me now and tell me what you can do.
       
      discord:
      joerg federmann composing#2898
       
       
    • By codelyoko373
      I wasn't sure if this would be the right place for a topic like this so sorry if it isn't.
      I'm currently working on a project for Uni using FreeGLUT to make a simple solar system simulation. I've got to the point where I've implemented all the planets and have used a Scene Graph to link them all together. The issue I'm having with now though is basically the planets and moons orbit correctly at their own orbit speeds.
      I'm not really experienced with using matrices for stuff like this so It's likely why I can't figure out how exactly to get it working. This is where I'm applying the transformation matrices, as well as pushing and popping them. This is within the Render function that every planet including the sun and moons will have and run.
      if (tag != "Sun") { glRotatef(orbitAngle, orbitRotation.X, orbitRotation.Y, orbitRotation.Z); } glPushMatrix(); glTranslatef(position.X, position.Y, position.Z); glRotatef(rotationAngle, rotation.X, rotation.Y, rotation.Z); glScalef(scale.X, scale.Y, scale.Z); glDrawElements(GL_TRIANGLES, mesh->indiceCount, GL_UNSIGNED_SHORT, mesh->indices); if (tag != "Sun") { glPopMatrix(); } The "If(tag != "Sun")" parts are my attempts are getting the planets to orbit correctly though it likely isn't the way I'm meant to be doing it. So I was wondering if someone would be able to help me? As I really don't have an idea on what I would do to get it working. Using the if statement is truthfully the closest I've got to it working but there are still weird effects like the planets orbiting faster then they should depending on the number of planets actually be updated/rendered.
    • By BenjaminBouchet
      Learning game development in Unreal Engine could be a daunting task for someone who don’t know where to start, and a cumbersome process if you don’t organize your progression correctly. One thing commonly known by experienced developers and by people unfamiliar with coding: mastering a development language is a long and difficult task.
      From blueprints to C++ in Unreal Engine
      If you want to learn fast, you need a good learning strategy. Unreal Engine contains a very powerful tool which you can use to learn C++ faster: its blueprint system. Blueprints are extremely easy to learn (and you may already have a good knowledge of them). Thus you can conveniently use them as a guide for writing code in C++. This is the reason why I am writing a tutorial series on how to make the transition from Unreal Engine blueprints to C++.
      Learn and practice C++
      Following this tutorial, you’ll acquire new concepts of C++ programming in every chapter. Then following chapters will give you reasons to reuse and practice those same concepts. There’s no better way to wire you brain.
      Link to the tutorial: [Tutorial] Learn C++ in Unreal Engine 4 by making a powerful camera
      Please do send me as much feedback as you want. I’ll be considering every constructive remarks and taking them into consideration. Your feedback will help me to improve and update the existing chapters and to make the next one better.

      View full story
    • By BenjaminBouchet
      Learning game development in Unreal Engine could be a daunting task for someone who don’t know where to start, and a cumbersome process if you don’t organize your progression correctly. One thing commonly known by experienced developers and by people unfamiliar with coding: mastering a development language is a long and difficult task.
      From blueprints to C++ in Unreal Engine
      If you want to learn fast, you need a good learning strategy. Unreal Engine contains a very powerful tool which you can use to learn C++ faster: its blueprint system. Blueprints are extremely easy to learn (and you may already have a good knowledge of them). Thus you can conveniently use them as a guide for writing code in C++. This is the reason why I am writing a tutorial series on how to make the transition from Unreal Engine blueprints to C++.
      Learn and practice C++
      Following this tutorial, you’ll acquire new concepts of C++ programming in every chapter. Then following chapters will give you reasons to reuse and practice those same concepts. There’s no better way to wire you brain.
      Link to the tutorial: [Tutorial] Learn C++ in Unreal Engine 4 by making a powerful camera
      Please do send me as much feedback as you want. I’ll be considering every constructive remarks and taking them into consideration. Your feedback will help me to improve and update the existing chapters and to make the next one better.
    • By mrDIMAS
      Hello everyone! I need to fill lua table with functions from script file like this:
      function init() end function update() end I need to create table on stack and fill it with this functions from specified file. How can I do this?
  • Advertisement
  • Advertisement

More questions about inheritance

Recommended Posts

This is a continuation of my previous topic, I am still super confused :P

Situation: There is this "D3DApp" class that is basically a framework to inherit from that give us a Window, a Renderer and a GameTimer. My class "Direct3D11Engine" derives from "D3DApp".

This is how the autor of "3d Game Programming using DirectX11" suggest to initialize my Direct3D11Engine class:

bool Direct3D11Engine::Init()
{
	if (!D3DApp::Init())
	{
		return false;
	}

	//Additional Initialization


	return true;
}

 

Now, from what I can tell something weird is happening, because the D3DApp::Init() method is called from inside my "Direct3D11Engine" fully constructed object.

At a first glance I would assume that a D3DApp object instance was default constructed and it's Init() method called, but that is not the case at all because if it was that way, then that instance would have his own ImmediateContext and swapChain and so on and my derived class would just have a bunch of nullptr instead, but I've tried to draw from within my "Direct3D11Engine" Draw() function and everything works, so that call to D3DApp::Init()  indeed  got my class variable all setup.

What on earth is going on here?! :S

Edited by MarcusAseth

Share this post


Link to post
Share on other sites
Advertisement

It's hard to say without the code. But probably what you are seeing here is that D3DApp::Init() is being used to call the base class version of Init(). I'd venture to guess that the author is suggesting you use this pattern to allow you to insert any of your application-specific code before or after the base application initialization runs.

There are alternative, better (in my experience) ways of implementing this pattern. But in this case the author is probably opting for simplicity and straightforwardness at the cost of robustness and expecting you to just "remember" to call the base class Init function at the right time.

The Foo::Bar() syntax means different things in different contexts. In this context, it means "explicitly call Foo's version of Bar on the object pointed to by the this pointer."

Share this post


Link to post
Share on other sites

Ok, probably is what is going on, so this means that from inside a derived class I can call a method of the parent class and the method will act on the derived class variables etc...? Is it really this sneaky?! :D

Example:

class A
{
public:
	A(){}
	virtual ~A();
	virtual void FancyFunction() {value = 20;}
protected:
	int value{};
};

class B : public A
{
public:
	B():A(){}
  	//this function below will set B's member variable "value" to 20
	virtual void FancyFunction() {A::FancyFunction();}
};

 

Edited by MarcusAseth

Share this post


Link to post
Share on other sites
16 minutes ago, MarcusAseth said:

so this means that from inside a derived class I can call a method of the parent class

Yes, this part is true.

16 minutes ago, MarcusAseth said:

and the method will act on the derived class variables

No, this part is not. The parent (base) class cannot see into the derived class. It doesn't know anything about it, and cannot act on any member variables of the derived class directly.

The Base::Method() syntax you're seeing here is nothing magical, it's just a way of disambiguating, for the compiler, which function you want to call in a case where there are two versions (the base virtual method and the derived overridden method, for example). It is otherwise akin to any regular old member function call.

Your terminology is a little off again, here. In your example, "value" is a member of A. Not B; B doesn't have a member named value of its own, it just has A's value because B inherits from A, and thus every instance of B is also an A. 

When you say things like that something "will act on the derived class variables," what you are saying is that if (continuing your example) B had a member variable called "name," that calling A::FancyFunction from B::FancyFunction could let A set name = "Frank." But that is not possible.

Share this post


Link to post
Share on other sites

I see. It's pretty awesome, before I had basically copy-pasted all the WinProc function, while now I can just do this (code below) and override only the WM_Message cases I care about, pretty convenient! :P

Learned one more very useful thing, thanks! :)

LRESULT Direct3D11Engine::MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
	

	default:
	return  D3DApp::MsgProc(hwnd, msg, wParam, lParam);
	}
}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Advertisement