Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

169 Neutral

About Sabonis

  • Rank
  1. Sabonis

    Linker Error...

    Assuming you are using a VS compiler (which you might want to mention?) Make sure that your new library is added under the library dependencies along with its path.
  2. Sabonis

    GL transformations question

    Thanks for your help!
  3. Sabonis

    GL transformations question

    I think where my logic is failing is here: M= a b c 0 d e f 0 g h i 0 0 0 0 1 T = 1 0 0 x 0 1 0 y 0 0 1 z 0 0 0 1 Here is what their multiplication would mean (in my head) MxT = a b c x d e f y g h i z 0 0 0 1 BUT: The two commands separately executed would give a result of something like: a b c u d e f v g h i w 0 0 0 1 where u,v,w are completely different than xyz. I'm just confused as why.
  4. Hello, I am implementing my own gluLook at function with the help of: http://pyopengl.sourceforge.net/documentation/manual/gluLookAt.3G.html They mention "and gluLookAt is equivalent to glMultMatrixf(M); glTranslatef (-eyex, -eyey, -eyez);" Why can't the translation values for the eye be put into the matrix m? What is the different between combining the two and separating them into the commands glMultMatrixf and gltranslatef? The translation for xyz in the matrix m are 0, why not just populate them? Either way, ive tried both ways and both give me different results.
  5. Sabonis

    gl engine and QT widget

    Hi there, I believe what you are looking for is the class QGLWidget. It is a wrapper for openGL, and the reference documentation is here: [http://doc.trolltech.com/4.3/qglwidget.html#paintGL] paintGL() is basically where you want to put your drawing code. It is called from drawGL() by the base class behind the scenes. It draws sufficiently fast enough for most applications Now, if you want to have a separate math update function that updates as fast as possible, then you may look at creating a timer like this: // Create a derived class of QGLWidget. class MyWidget : public QGLWidget { Q_OBJECT .... public: MyWidget(); ~MyWidget(); public slots: void updateMath(); // redefine all the virtual base class functions here if you need .... private: QTimer* timer; ..... } MyWidget::MyWidget() :QGLWidget() { timer = new QTimer(parent); connect(timer, SIGNAL(timeout()), this, SLOT(updateMath())); timer->start(); // This is intentionally without params to update as fast as possible } MyWidget::~MyWidget() {delete timer;} I hope this helps!
  6. Sabonis

    tears of body parts

    This might be related to what you are talking about: http://www.alecrivers.com/fastlsm/ Just watch the video and there is a part where they tear a sheet of cells apart.
  7. Sabonis

    Matrix determinant

    Hello, I am playing around with some matrix math for my own learning and I came across a the "cofactor expansion" method for finding the determinant. http://comp.uark.edu/~jjrencis/femur/Learning-Modules/Linear-Algebra/solving/determinant/cofactor_expansion.html I implemented the recursive method and I decided to test it out for a 10x10 float matrix only to find out that it is terribly slow (~10 seconds!). I tried the same matrix in matlab and it seems almost instant :( Is there a faster way to get the determinant?
  8. Sabonis

    C++ const

    Hi, if I have some class like the following: Class A { A(const int* In) { ptr = In; } ... private: int* ptr; }; The compiler will no doubt complain that I am trying to convert a const pointer to a non-const pointer. Is it safe to use const_cast on In, or is there some other way to do this? The const keyword is there so to indicate I don't want to change the pointer in the copy ctor. But does this mean 'copying' it is changing it?
  9. Sabonis

    Dereference overloading

    ARGH! Score another one for version control... Okay well the error is gone now, but I would still like to hear your other thoughts on my implementation
  10. Sabonis

    Dereference overloading

    Visual Studio 2005 is the compiler I am using 1>------ Build started: Project: smtptrtest, Configuration: Debug Win32 ------ 1>Compiling... 1>main.cpp 1>.\main.cpp(27) : error C2819: type 'std::vector<_Ty>' does not have an overloaded member 'operator ->' 1> with 1> [ 1> _Ty=int 1> ] 1>.\main.cpp(27) : error C2039: 'size' : is not a member of 'SmartPtr<T>' 1> with 1> [ 1> T=std::vector<int> 1> ] 1>Build log was saved at "file://c:\***\smtptrtest\Debug\BuildLog.htm" 1>smtptrtest - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Error List: Error 1 error C2819: type 'std::vector<_Ty>' does not have an overloaded member 'operator ->' c:\***\smtptrtest\main.cpp 27 Error 2 error C2039: 'size' : is not a member of 'SmartPtr<T>' c:\***\smtptrtest\main.cpp 27 I am building a library of utilities for myself to use in my own projects. I'm just sick of having my conscience scolding me every time memory ends up being managed by a different class than where it originated. Please let me know what other problems you spotted! This was the first write-up and I want to know other people's ideas for this class structure.
  11. Hello, I am writing a 'smart pointer' class and am trying implement the -> pointer dereference functionality. Here is the Class: #ifndef _SMRTPTR_H_INCL_ #define _SMRTPTR_H_INCL_ template<typename T> class SmartPtr { public: SmartPtr(); SmartPtr(T* Obj); SmartPtr(SmartPtr &Copy); SmartPtr<T>& operator=(SmartPtr &Copy); SmartPtr<T>& operator=( T* Obj); inline SmartPtr<T>* operator&(); inline T& operator[](unsigned int Index); inline T& operator*(); inline T* operator->(); inline bool operator==(const T* Obj); inline bool isValid(); ~SmartPtr(); protected: inline void addRef(); inline void deRef(); inline void destroy(); T* data; unsigned int* refCount; }; template<typename T> SmartPtr<T>::SmartPtr() { data = 0; refCount = 0; } template<typename T> SmartPtr<T>::SmartPtr( T* Obj) { *this = Obj; } template<typename T> SmartPtr<T>::SmartPtr( SmartPtr<T> &Copy) { *this = Copy; } template<typename T> SmartPtr<T>::~SmartPtr() { this->deRef(); } template<typename T> SmartPtr<T>& SmartPtr<T>::operator=( T* Obj) { assert(Obj!= 0 && "Tried to assign a null pointer"); // De-reference whatever we are currently pointing to if it is valid if(this->isValid()) deRef(); // Copy the pointer data = Obj; refCount = new unsigned int; *refCount = 1; return *this; } template<typename T> SmartPtr<T>& SmartPtr<T>::operator=(SmartPtr<T> &Copy) { assert(Copy.isValid() && "Tried to copy an invalid smart pointer"); // De-reference whatever we are currently pointing to if it is valid if(this->isValid()) deRef(); // Copy the pointers and add a reference data = Copy->data; refCount = Copy->refCount; addRef(); return *this; } template<typename T> bool SmartPtr<T>::isValid() { if(data && refCount) return true; return false; } template<typename T> bool SmartPtr<T>::operator==(const T* Obj) { return data == Obj; } template<typename T> void SmartPtr<T>::deRef() { *refCount--; // Check if this is the last reference, and if so destroy the data if(*refCount==0) destroy(); } template<typename T> void SmartPtr<T>::destroy() { assert(*refCount==0 && "Tried to destroy when there are still references"); delete data; delete refCount; data=0; refCount = 0; } template<typename T> void SmartPtr<T>::addRef() { *refCount++; } template<typename T> T& SmartPtr<T>::operator*() { assert(this->isValid() && "Tried to deReference a null pointer"); return *data; } template<typename T> SmartPtr<T>* SmartPtr<T>::operator&() { return this; } template<typename T> T* SmartPtr<T>::operator->() { assert(this->isValid() && "Tried to deReference a null pointer"); return data; } template<typename T> T& SmartPtr<T>::operator[](unsigned int Index) { assert(this->isValid() && "Tried to deReference invalid smart pointer"); return data[Index]; } #endif Here is the main.cpp #include <vector> #include <iostream> #include <stdio.h> #include <Assert.h> #include "smartptr.h" using namespace std; void main() { vector<int>* A = new vector<int>; A->push_back(5); A->push_back(6); A->push_back(73); A->push_back(49); SmartPtr< vector<int> > B = A; cout << (*B)[1] << endl; cout << (*A)[1] << endl; cout << A->size() << endl; cout << (*B).size() << endl; cout << B->size() << endl; return; } It fails to compile on B->size() claiming that there is no overloaded -> function for the vector<int> class. Of course there isn't, but I am returning the T* pointer in the -> function... I'm not sure how to fix this, any help would be appreciated!
  12. Sabonis

    Color conversion

    Yup, these systems are not well defined and quite frustrating. Here is a link to the paper: [link]http://www.pcot.cat/pdf/common/icc/publicacions_icc/publicacions_tecniques/tractament_imatge/bienni_1999_2000/multiresolution_based_image_fusion.pdf[/link]
  13. Sabonis

    Color conversion

    Hello, I am implementing a paper I found for image fusion, and I have come to a roadblock on converting RGB to Intensity and Intensity to RGB There are three methods listed below: I1 = (r + g + b) / 3; I2 = max(r,g,b); I3 = (max(r,g,b) + min (r,g,b)) / 2; But the issue is that they don't describe how to get back to RGB values for any of those equations. The first one is based on smith's hexacone , the second on smith's triangle and the third isn't defined. Does anyone have some advice in this area? Thanks!
  14. Sabonis

    MESH programing

    Usually for models that are not geometric primitives, people use 3D modeling programs that enable them to manipulate vertices, textures etc. and save them into files which can be loaded into your program. The problem is that different programs have different file formats in which they save information about the model. For example, 3DS max is a program that saves models as a .3ds file which a lot of people convert to .X files that can be easily used with DirectX. You just need to choose a program and format to work with. There is no need to manually program vertices of a complex model, as programs have been made so you can manipulate this data visually and save it in a file to import to your program.
  15. Sabonis

    Places in a horror game

    What about a castle in a forest somewhere? Both are pretty scary to people when its dark outside. Ghosts live in castles and people are scared of slamming doors and creepy sounds. I personally like the Clive Barker's undying series because they scared the crap outta me. Forests haven't really been done but darkness and wilderness sounds can definitely take the imagination for a run. Especially if you know there are threats like bears or cougars or something similar :P Some added mechanics such as evolving levels might cause some clausterphobia because people wouldn't trust their senses anymore.
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!