Jump to content
  • Advertisement

Concentrate

Member
  • Content Count

    971
  • Joined

  • Last visited

Community Reputation

181 Neutral

About Concentrate

  • Rank
    Advanced Member

Personal Information

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. const char *foo1(){   const char* a = "foo1";   return a; } const char* foo2() {  std::string myString = "foo2!";  return myString.c_str(); } int main(){     foo1();     foo2(); }
  2. Concentrate

    Newbie Javascript question

    If you are running on chrome, you can simply use the bind function,  this.tickIntervalId = setInterval(this.Tick.bind(this), 1000/60); //Update at 60 fps   or if you are using the popular underscore utility   this.tickIntervalId = setInterval(_.bind(this.Tick,this), 1000/60); //Update at 60 fps     The problem is that your Tick function gets called in a global context. Which means that, the 'this' pointer is the global 'this' which is not what you need. Hence you need to bind the 'this' context so that when the Tick function gets called from a global context, the original 'this' pointer is still saved.
  3. Try instantiating BitText in main, then pass it around where needed. That class seems to be lightweight right? So I assume creating that object is light.
  4. Interesting, this seems like a bug? Same result in chrome/firefox as well. Btw, on chrome increasing linewidth by 2, seems to fix the issue as you've mentioned.
  5. Concentrate

    Is there anything faster than A* pathing?

    Check this http://qiao.github.io/PathFinding.js/visual/ out. Check out the jump point search, with preprocessing and future information that algorithm is very fast. So it all depends on the context. But A* is a good starting point in most scenarios. 
  6. Here is the http://jsfiddle.net/DV9Bw/558/ . I'm not sure why there is opacity less than 255. If you hover over the non-overlapping section, you can see that the opacity is 127/128. Can someone clear this up for me? Why isn't opacity full (255). Also more importantly, why in the overlapping section, the two rectangle pixels are combined, instead of the destination rectangle(blue one I believe) completely take over the pixel at that coordinate? Is this just how the strokeRectangle works? If I change the stroke to fill, as in fillRectangle, then everything works as expected. Any help is greatly appreciated!
  7. void Building::_renderDefaultBuilding()const{ glColor3f(1.0f,1.0f,1.0f); glTranslatef(m_position.x,m_position.y,m_position.z); Vector3f t = m_size / 2.0f; glTranslatef(t.x,t.y,-t.z); //translate so its bottom surface starts at (0,0,0) glScalef(m_size.x,m_size.y,m_size.z); if(!Resource::textureList.empty()){ glBindTexture(GL_TEXTURE_2D, Resource::textureList[Resource::NIGHT_BUILDING_TEXTURE]); float s[] = {0.01f,0.0f,0.0f,0.0f}; float t[] = {0.0f,0.01f,0.0f,0.0f}; glTexGenfv(GL_S, GL_OBJECT_LINEAR, s); glTexGenfv(GL_T, GL_OBJECT_LINEAR, t); glEnable(GL_TEXTURE_GEN_S); // Auto Texture Generation glEnable(GL_TEXTURE_GEN_T); } glutSolidCube(1.0f); glScalef(1.0f/m_size.x,1.0f/m_size.y,1.0f/m_size.z); glTranslatef(-t.x,-t.y,t.z); glTranslatef(-m_position.x, -m_position.y, -m_position.z); } so I have the above code, but I need help with auto generating the textures such that I can scale which part of the texture gets rendered. Any help on this?
  8. The current problem I'm having right now is drawing the next branch starting at the end point of its parents branch. Not sure how to achieve the above using glRotate/glTranslate. Currently this is the drawing function void _generateTreeBranches(const Point3f& newPosition, float length, float rotation, const int depth) { if(depth > MAX_DEPTH) return; cout << "at depth = " << depth << endl; //for debugging if(depth == 0){ glColor3f(1.0f,1.0f,1.0f); }else if(depth == 1){ glColor3f(1.0f,0.0f,0.0f); }else{ glColor3f(0.0f,1.0f,0.0f); } glTranslatef(newPosition.x,newPosition.y,newPosition.z); glRotatef(rotation, 0.0f, 0.0f, 1.0f); drawLine(length); //draws centered at origin glRotatef(-rotation, 0.0f, 0.0f, 1.0f); glTranslatef(-newPosition.x,-newPosition.y,-newPosition.z); const float newLength = length * BRANCH_LENGTH_DECREASE_FACTOR; int nextDepth = depth + 1; Point3f nextPosition = {newPosition.x+length, newPosition.y, newPosition.z}; float leftRotation = rotation + CHILD_BRANCH_ANGLE * nextDepth; _generateTreeBranches(nextPosition,newLength,leftRotation,nextDepth); float rightRotation = rotation - CHILD_BRANCH_ANGLE * nextDepth; _generateTreeBranches(nextPosition,newLength,rightRotation,nextDepth); } Not sure, I'm guessing my next step would be to calculate the 'nextPosition' based on the current rotation, which should be the endPoint of the current line. Any advice on how to properly setup the positioning so that the line is generated starting at the endpoint of its parent's line. I really want to avoid manually calculating the position end based on angle of rotation and just let opengl do that via glTranslate/glRotate, but for this maybe there is no way out.
  9. I think im doing it correctly but the end result is not what I want, here is the code : void _generateTreeBranches(const Point3f& startPoint, const Point3f& endPoint, float rotation, const int depth) { if(depth > MAX_DEPTH) return; cout << "at depth = " << depth << endl; if(depth == 0)glColor3f(0.0f,1.0f,0.0f); else glColor3f(1.0f,1.0f,1.0f); float distanceOfPoint = pointDistance(startPoint, endPoint); glRotatef(rotation, 0.0f, 0.0f, 1.0f); glTranslatef(-startPoint.x, 0.0f, 0.0f); drawLine(startPoint, endPoint); glTranslatef(startPoint.x, 0.0f, 0.0f); glRotatef(-rotation, 0.0f, 0.0f, 1.0f); const float nextLength = distanceOfPoint; Point3f nextBranchStart = endPoint; Point3f nextBranchEnd = {endPoint.x + nextLength,endPoint.y,endPoint.z}; _generateTreeBranches(nextBranchStart, nextBranchEnd,45.0f,depth+1); } It draws something like /____ instead of the desired _____/ any advice? Also I've noticed that I can either manipulate glTranslate to position my object at position X or I can simply set its coordinates to be draw at position X. Which one is more preferable ?
  10. Did you try to compile this? Simple question like this could just be tested. Learn to be more independent.
  11. Is this because of default private inheritance for "class" over struct? Regular public inheritance seems to dipatch FastRunner::run() to Foo::run for me. [/quote] ...and we found the solution for that problem. Thank you, forgot about that
  12. Ok sorry guys, I understand now. My confusion was me assuming that only one vtable would be needed per hierarchy. But I realize that each class has its own vtable/vptr, and it might not be possible with only one vtable per hierarchy. It makes sense now.
  13. Thats a weird circular way to counter an argument? Its not really virtual is it? Its more like its overriding a virtual function. And anyone deriving a class with a run function would know that run was virtual. [/quote] Yes IRun::run is virtual and that makes sense, but IFastRunner::run doesn't really have to be virtual does it? It being virtual tells me that some other class might derive from FastRunner::run. I think one should instead have an option to explicitly state it as virtual. I may be confused here but it seems to me that you argue that the last run function in the vtable doesn't have to be virtual because it is the last one in the table. [/quote] No that is not what I was saying. Idk, maybe its there for efficiency reasons. Or that I'm just confused somehow and not seeing the reason for FastRunner::run to be explicitly virtual. Hope my question is clear [/quote] Your suggestions are correct. Virtual keyword only matters for derived classes. So in your case FastRunner::run() is not virtual any more. So that if you inherit it in the class Foo: class Foo : FastRunner { public run() const {} } Foo::run() does not override FastRunner::run() but hide it. As an example: FastRunner * base = new FastRunner; base->run() // FastRunner::run() base = new Foo; base->run() // FastRunner::run(); Foo * foo = new Foo; foo->run(); // Foo::run() foo->FastRunner::run(); // FastRunner::run(); [/quote] Wait, but I thought FastRunner::run is virtual by default since it overrode the base classes implementation. How come Foo::run hides it?
  14. I disagree. I think it would make more sense if FastRunner::run had to be labeled virtual, because it is virtual. [/quote] Thats a weird circular way to counter an argument? Its not really virtual is it? Its more like its overriding a virtual function. And anyone deriving a class with a run function would know that run was virtual. [/quote] Yes IRun::run is virtual and that makes sense, but IFastRunner::run doesn't really have to be virtual does it? It being virtual tells me that some other class might derive from FastRunner::run. I think one should instead have an option to explicitly state it as virtual. I may be confused here but it seems to me that you argue that the last run function in the vtable doesn't have to be virtual because it is the last one in the table. [/quote] No that is not what I was saying. Idk, maybe its there for efficiency reasons. Or that I'm just confused somehow and not seeing the reason for FastRunner::run to be explicitly virtual. Hope my question is clear
  15. Concentrate

    [intro to calculation] pose problems N.-1

    May I ask how you came up with that answer? From your question, I generate the following equation $perPerson = 72,000 / n 4000 = 72,000 / (n-3) n = 72000/4000 + 3 = 21 So I thought the answer would be 21. Maybe my initial equation is wrong.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!