Jump to content
  • Advertisement

gpr1me

Member
  • Content Count

    18
  • Joined

  • Last visited

Community Reputation

122 Neutral

About gpr1me

  • Rank
    Member
  1. Thanks Zipster, that was exacly what i was looking for. Works perfeclty now :)
  2. I am having some trouble figuring this out. Basically i have set up a bunch of predetermined positions on the map which i visit in some predinfined order. The camera follows the path specified. It will go to one position which i set by the center of the gluLookAt() function. The center is the direction my camera is moving. My move function is this: void Camera::MoveForward( void ) { eye.x += (center.x - eye.x) / step; //eye.y += (center.y - eye.y) / step; eye.z += (center.z - eye.z) / step; center.x += (center.x - eye.x) / step; //center.y += (center.y - eye.y) / step; center.z += (center.z - eye.z) / step; } I have commented out the y positions because i do not want it to change. A am also increasing the center position so the camera will not slow down when it gets near the position it's going to. Once it gets to that position i update the center to the next position and it continues. Now my problem is if i have say 3 positions (p1, p2, p3) i want to camera to go to. It will start at p1->p2->p3. And say the distance between p1 and p2 is 10 and the distance between p2 and p3 is 20. This means that the camera will move from p2 to p3 faster than it moved from p1 to p2. How should i fix this problem? I am thinking i should have the center position always a constant distance away from my eye position and in the direction of the next position on the map to visit. How would i do this?
  3. In my little game i want to be able to look at a specific point in my 3d scene. If my camera is at (0, 0, 0) and i want to be able to look at (10, 0, 20) how would i do this. I understand that i need to change the gluLookAt() function. Which basically sets the camera's (eye, center, up). The Eye is the location of the camera, center is the direction the camera is pointing and up is defining what up is. So would i have to do something like this? gluLookAt(0.0, 0.0, 0.0, 10.0, 0.0, 20.0, 0.0, 1.0, 0.0); This will Make eye.x = 0.0, eye.y = 0.0, eye.z = 0.0 center.x = 10.0, center.y = 0.0, center.z = 20.0 up.x = 0.0, up.y = 1.0, up.z = 0.0 That means the camera will be at the origin and looking at the point (10.0, 0.0, 20.0). Am i correct? So if i want to look at a specific point all i would have to do is change the center to that point?
  4. I am using visual studio's 2005 and i am having a problem trying to run some code. The error says that fatal error LNK1104: cannot open file 'libc.lib' I have searched google and found alot of people had the same issue with VS.net 2005. But i did not find a solution that works for me. I tried to ignore libc.lib by adding it into: Project Properties->Configuration Properties->Linker->Input->Ignore Specific Library But if i add it there i get this error: error LNK2019: unresolved external symbol __iob referenced in function _output_message jpeg.lib I am guessing i am getting this error because jpeg.lib is looking for something defined in libc.lib. Is there a way around this?
  5. I want to be able to change the way OpenGL reads my screen coordinates. What i mean by this is: OpenGL reads the TOP LEFT of the opengl screen as X=0 and Y=0. Instead of that i would like it to read the MIDDLE MIDDLE as X=0 and Y=0. Basically i want it to be a cartesian coordinate system. If there a function for doing this or do i have to perform the calculation myself?
  6. gpr1me

    Pathfinding Suggestions

    Yeah this is true. Well i have decided to manually place the waypoints and edges between them. For the weight of the edge it will be a combination of the distance (easy calculation) and the type of terrain.
  7. gpr1me

    Weird Problem

    Wow, such a headache for that. Thanks alot for your help! i need to pass out now :S
  8. I have used textures before and now i am using the same code from a previous project i worked on but this time the code is not working. I am trying to load a .bmp file with this function: AUX_RGBImageRec* Map::LoadBMP(char *Filename) { FILE *File=NULL; if (!Filename) return NULL; File=fopen(Filename,"r"); if(File) { fclose(File); return auxDIBImageLoad(Filename); } return NULL; } Now in my previous project i have no problems. But now i copied this code over to my new project i get this error: error C2664: 'auxDIBImageLoadW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR' So when i cast the char* to a LPCWSTR i get linking errors. Im using visual studio .net 8. I have included glaux.h file and i can't seem to figure out what the difference is that makes it work in a one project and not in another project. If anyone had the same problem do you know what a solution might be?
  9. In my program i want to be able to make an object (like a plane made with a GL_QUAD) clickable. So if i have a plane displayed on the screen i want to be able to click on a point on the screen and get the X, Y position on the plane (not the screen). Is this some sort of collision detection or something? [Edited by - gpr1me on March 26, 2006 4:00:31 PM]
  10. gpr1me

    Pathfinding Suggestions

    Yeah i am going to be using floyd warshall all-pair shortest path algorithm. Dijkstra's algorithm is good for finding the shortest path between two vertice's but floyds find the shortest path between every pair. And if there are a large number of edges in the graph (about the same number of edges as vertice's) then floyds algorithm is faster.
  11. I am wrting a pathfinding program in OpenGL and i am having a little trouble as to how i want to respresent Waypoints on my map. I know i could use a simple A* algorithm but i wanted to try something different so i decided to try using Waypoints and an all-pair shortest path algorithm. Basically once my waypoints are positioned on my map i will be representing them as vertices in a graph and have weighted edges between them. After the graph is setup i will run an all-pair shortest path algorithm on my graph to get the shortest paths between each pair of vertice. This will all be pre-processed before the openGL window appears so it will be an extremely fast at run time. I just have to store a table in memory for this pre-processed solution. Ok so here is the point of this thread. I am not sure about how i will be making my waypoints. Right now i made a waypoint class and it stores an x, y position and has all the regular constructors and stuff like that. But should i position them manually or write an algorithm to do it. I was thinking just to place them like a certain distance away from eachother by running a simple double for loop. I wont place a waypoint if there is an obejct in that position already. And i will have auto placements of waypoints around each obejct that i place on the map (like rocks, tree's, mountains, ect...). I think this is a good solution but i just wanted to see if anyone can see downsides to this technique? Im sure it's not the best pathfinding technique out there but i think it will be fun to do. Any suggestions or comments would be great. Thanks
  12. gpr1me

    Dynamic Binding

    Ok so in the merge function which is implemented in each class would i have to implement multiple merge functions for each derived class. For example: I would have in my SimpleClass: Project & Merge(SimpleClass *); // would return a minor project Project & Merge(MinorClass *); // would return a minor project Project & Merge(MajorClass *); // would return a major project In MinorProject: Project & Merge(SimpleClass *); // would return a minor project Project & Merge(MinorClass *); // would return a minor project Project & Merge(MajorClass *); // would return a major project In MajorProject: Project & Merge(SimpleClass *); // would return a major project Project & Merge(MinorClass *); // would return a major project Project & Merge(MajorClass *); // would return a major project Or would i only have to have one overrided function in each derived class?
  13. I'm having some trouble figuring this out. I have a class heirarchy Project --> SimpleProject --> MinorProject --> MajorProject Now a simple project and a minor project can be merged to create a simple project, a simple project and a major project can be merged to create a major project. Basically any project can be merged with any other project which creates a new project. A simple project contains one and only one task. A Minor project contains a list of tasks, so merging a simple and minor project would create a new minor project with the list of the previous minor project and with the task from the simple project added to it. Also a major project is just like a minor project but with dependency's between tasks. So merging a major and a minor gives a major. Does this all make sense? So basically i want to write a function which does this. I have been told it can be done using Dynamic Binding but im not seeing how... Here are my class definition files if that helps you picture this more Project.h: #ifndef PROJECT_H #define PROJECT_H // forward declaration class Task; class Project { public: Project(); Project(const Project &); virtual ~Project(); // some pure virtual functions virtual void AddTask(Task *) = 0; virtual void DoTask() = 0; virtual bool HasTasks() = 0; private: // still to add... }; #endif SimpleProject.h: #ifndef SIMPLEPROJECT_H #define SIMPLEPROJECT_H #include "Project.h" #include "Task.h" class SimpleProject : public Project { public: SimpleProject(); SimpleProject(const SimpleProject &); ~SimpleProject(); void AddTask(Task *); void DoTask(); bool HasTasks(); SimpleProject & operator=(const SimpleProject & other); friend std::ostream & operator<<(std::ostream & os, const SimpleProject & sp); friend bool operator==(const SimpleProject & left, const SimpleProject & right); friend bool operator!=(const SimpleProject & left, const SimpleProject & right); private: Task *task; // the total number of tasks int numTasks; }; #endif MinorProject.h #ifndef MINORPROJECT_H #define MINORPROJECT_H #include <list> #include "Project.h" #include "Task.h" class MinorProject : public Project { public: MinorProject(); MinorProject(const MinorProject &); ~MinorProject(); void AddTask(Task *); void DoTask(); bool HasTasks(); MinorProject & operator=(const MinorProject &); friend std::ostream & operator<<(std::ostream &, const MinorProject &); friend bool operator==(const MinorProject &, const MinorProject &); friend bool operator!=(const MinorProject &, const MinorProject &); private: list<Task> *task_list; }; #endif MajorProject.h (this one is not yet competed...): #ifndef MAJORPROJECT_H #define MAJORPROJECT_H #include "Project.h" #include "Task.h" #include <list> #include <vector> class MajorProject : public Project { public: MajorProject(); MajorProject(const MajorProject &); //MajorProject(list<Task> *, vector<int *> *); ~MajorProject(); void AddTask(Task *); void AddDependency(const vector<int> &); void DoTask(); bool HasTasks(); MajorProject & operator=(const MajorProject & other); friend std::ostream & operator<<(std::ostream & os, const MajorProject & mp); friend bool operator==(const MajorProject & left, const MajorProject & right); friend bool operator!=(const MajorProject & left, const MajorProject & right); private: list<Task> *task_list; vector<vector<int>> *depend_vec; }; #endif If anyone can point me int he rigth direction i would appreciate that.
  14. Ok i understand what i was doing wrong. Im still getting the hang of pointers. Why do they have to teach just Java in my University! Anyways, thanks for your help dude!
  15. Im having a little trouble with a program i am writing. I have a class heirarchy: Project --> SimpleProject --> MinorProject ect... and another class: Task Now task has a pointer to a Project object in it's private section of the class definition. Here is Task.h #ifndef TASK_H #define TASK_H // forward declaration class Project; class Task { public: Task(); Task(const Task & t); Task(int, const Project &); ~Task(); void DoIt(); Task & operator=(const Task & other); friend std::ostream & operator<<(std::ostream & os, const Task & t); friend bool operator==(const Task & left, const Task & right); friend bool operator!=(const Task & left, const Task & right); private: int id; Project *pp; }; #endif Now i want the Project *pp pointer to point to a derived class of Project (SimpleProject, MinorProject). I defined the constructors of Task like this (Task.cpp): /** * Default Constructor */ Task::Task() { // do nothing } /** * Constructor with id and reference to project. */ Task::Task(int in_id, const Project & in_pp) { *pp = in_pp; // is this wrong? id = in_id; } /** * Copy Constructor. */ Task::Task(const Task & orig) { id = orig.id; pp = orig.pp; } Of so the id is getting set but for some reason the pp pointer is not being set. It is always the same memory address for each pp pointer even if i create more than on instance of the class. Do i have to dynamically create the Project that pp is pointing to in the constructors? But if i do that then i will have to know what type of project it is. My main file is: #include <iostream> #include <iomanip> using namespace std; #include "Task.h" #include "SimpleProject.h" #include "MinorProject.h" #include "MajorProject.h" int main() { SimpleProject *sp1 = new SimpleProject(); SimpleProject *sp2 = new SimpleProject(*sp1); SimpleProject *sp3 = new SimpleProject(*sp1); Task *t1 = new Task(1, *sp1); Task *t2 = new Task(2, *sp2); Task *t3 = new Task(*t1); sp1->AddTask(*t1); sp2->AddTask(*t2); sp3->AddTask(*t3); cout << *sp1 << endl; cout << *sp2 << endl; cout << *sp3 << endl; cout << (*sp1 == *sp2) << endl; delete sp1; delete sp2; delete sp3; return 0; } The only thing that is not working is the pp pointer in Task obejcts. Can anyone help me out?
  • 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!