• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

105 Neutral

About Sh@dow

  • Rank
  1. Thanks to all for reply,   I'm using some sort of bounding cube to detect collisions but the vertexes of that cube must be transformed. I'm thinking how to transform that vertexes.  GLM library seems to calculate matrices on using shaders so it is impossible to get result from it.
  2. Hi all,   My question is more about the general game engine design concept rather than particular case.   There are many objects in the scene and for some of them the coordinates must be known after they are rotated and translated. They are necessary to track collisions for instance.   The problem is that graphics libraries hide theese coordinates inside after transformation. For instance in OpenGL after we perform glTranslate/glRotate functions the current matrix holds all transformations but vertexes are multiplied to it internally when we pass vertexes into OpenGL.   It is interesting to me how the object coordinates tracked in the game engine?   There are several ways to do that.    The first one is to use glTranslate/glRotate for positioning objects and transformating the vertexes additionally in the engine code. The disadvantage of this approach is that two the same transformations are done.   Another way is not to use glTranslate/glRotate but do all the transformations manually and pass to the OpengGL library already transformed vertexes.   Are there any other ways?
  3. I found that the problem is in delay between Acquire and GetDeviceState. When no delay is used the buttons are not read. When delay is 50ms or more the button state is returned correctly. I think hardcoded delay value is not a good idea. Cause it can vary from driver to driver. How could i select a proper one?
  4. Hi everyone, I'm using DirectInput to read joystick state. Especially i need button states. Here is the code. [code] BOOL CALLBACK enumCallback(const DIDEVICEINSTANCE* instance, VOID* context) { HRESULT result; result = di->CreateDevice(instance->guidInstance, &joystick, NULL); if (FAILED(result)) { return DIENUM_STOP; } return DIENUM_CONTINUE; } bool EnumerateDevices() { if (FAILED(result = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&di, NULL))) { return false; } if (FAILED(result = di->EnumDevices(DI8DEVCLASS_GAMECTRL, enumCallback, NULL, DIEDFL_ATTACHEDONLY))) { return false; } } //////////////////MAIN CODE//////////////////// if (joystick == NULL) { OutputDebugString(L"JOYSTIC NOT FOUND\n"); return false; } DIDEVCAPS capabilities; if (FAILED(result = joystick->SetDataFormat(&c_dfDIJoystick))) { OutputDebugString(L"ERROR\n"); return; } if (FAILED(result = joystick->SetCooperativeLevel(dlg_handle, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))) { OutputDebugString(L"ERROR\n"); return; } capabilities.dwSize = sizeof(DIDEVCAPS); if (FAILED(result = joystick->GetCapabilities(&capabilities))) { OutputDebugString(L"ERROR\n"); return; } // this structure holds the data for the property changes DIPROPRANGE joy_axis_range; // first set x axis tp -1024 to 1024 joy_axis_range.lMin = -1024; joy_axis_range.lMax = 1024; joy_axis_range.diph.dwSize = sizeof(DIPROPRANGE); joy_axis_range.diph.dwHeaderSize = sizeof(DIPROPHEADER); joy_axis_range.diph.dwObj = DIJOFS_X; joy_axis_range.diph.dwHow = DIPH_BYOFFSET; joystick->SetProperty(DIPROP_RANGE,&joy_axis_range.diph); // now y-axis joy_axis_range.lMin = -1024; joy_axis_range.lMax = 1024; joy_axis_range.diph.dwSize = sizeof(DIPROPRANGE); joy_axis_range.diph.dwHeaderSize = sizeof(DIPROPHEADER); joy_axis_range.diph.dwObj = DIJOFS_Y; joy_axis_range.diph.dwHow = DIPH_BYOFFSET; joystick->SetProperty(DIPROP_RANGE,&joy_axis_range.diph); if (joystick == NULL) { OutputDebugString(L"Joystic not found\n"); } result = joystick->Acquire(); if (FAILED(result = joystick->GetDeviceState(sizeof(DIJOYSTATE), &js))) { OutputDebugString(L"The device should have been acquired during the Poll()\n"); return; } joystick->Unacquire(); joystick->Release(); [/code] In EnumDevice i see that the joystic is found. In GetCapabilities function i see the correct parameters of the joystick. When I say Poll the result is DI_NOEFFECT. Sho i removed Poll method. Acquire returns no errors. But after i say GetDeviceState the rgbButtons are zeros even if i press buttons. The program is dialog based. In CooperativeLevel i pass the handle of the dialog. Where is the problem? Why buttons are not readed? Thanks,
  5. Create 2D model in 3ds max

    Hi all, I'm developing a simple game (2D) and i need to draw a model. Is it possible to draw a model on a plane in 3ds max using primitives(circle,oval) and export vertex coordinates to a file? How could i do this? I see that 3ds max works only in 3D. Thanks,
  6. In Lesson 43 to render a texture from free type font we are saying: [code] glBegin(GL_QUADS); glTexCoord2d(0,0); glVertex2d(0,bitmap.rows); glTexCoord2d(0,y); glVertex2d(0,0); glTexCoord2d(x,y); glVertex2d(bitmap.width,0); glTexCoord2d(x,0); glVertex2d(bitmap.width,bitmap.rows); [/code] I can't understand what does this code do? We are drawing here two quads: first has all x = 0; What does this supposed to mean? Thanks.
  7. Hi, everyone I need to plot different types of graphics in one window. I'm using C++ language on Win platform. My problem is that i can't correctly imagine a whole program architecture. I have several objects each one draws the specific types of graph(signal, 2d matrix). These objects expect device context as a parameter. But if i have only one window that means i have only one device context. As i understand the device context could not be divided into areas to draw separately into them. I can draw into the whole device context at one time. That's a problem to me because i can't redraw graphics independently.Imagine we have two graphics. When new data comes for graph1 i want to redraw it (not the entire window area and other graph2) so i can't do that.Or maybe i can? Is there any way to redraw only part of the window.Some kind of incremental drawing?
  8. Hi everyone, I'm reading "The Official Guide to Learning OpenGL Version 1.1" and found something i can't understand. I'll let myself to cite a paragraph from it: Quote: With gluPerspective() you need to pick appropriate values for the field of view, or the image may look distorted. For example,suppose you're drawing to the entire screen, which happens to be 11 inches high. If you choose a filed of view of 90 degrees, your eye has to be about 7.8 inches from the screen for the image to appear undistorted.(This is the distance that makes the screen subtend 90 degrees.) If your eye is farther from the screen, as it usually is, the perspective doesn't look right. I can't understand why the distance is 7.8. As i understood the distance must be 5.5.
  9. Hi AverageMidget, thanks for your reply. I changed the code and the bug disappeared. After i wrote first post i found another way how to fix it: i changed DeferWindowPos(hdwp,displaytab, HWND_TOP, rc.left+crect.left, rc.top+crect.top, rc.right - rc.left, rc.bottom - rc.top,0) to SetWindowPos(displaytab,0,rc.left+crect.left,rc.top+crect.top,rc.right - rc.left,rc.bottom - rc.top,0); seems very strange but it works.
  10. Hi everyone, I need to create a window with tabs,each tab has a list view control.I wrote the application, but there is a bug in repainting the window on resize. The sources are written in C++,WinAPI,VS2005. The bug is the following: When the windows is resized vertically very fast the status bar is not repainted correctly. I have tried to create a list view without tab window and there is no problems with is. So i think it is somehow connected with tab window and list view window resize. I took the example from the msdn. Can anyone look through the sources (the are quite primitive) and tell what i'm doing wrong? Here is a screenshot of the bug: [url]http://img6.imageshack.us/img6/5444/tabbedwndbug.jpg[/url] And here are the sources: [url]http://rghost.net/2593001[/url] Thanks in advance.
  11. Hi everyone. Suppose we have a library which consist of two files: A.h and A.cpp. In A.h there is a class declaration in A.cpp class definition. These two files are in directory that do not belong to the project. I want to use this library. So in my project i set "Additional include directory" to the directory where files are and include A.h in my source files. But how can i make compiler to compile A.cpp file? I don't want to add it to my project. When i use boost or mfc i just include a header and it works.But there are no .cpp files in the project. How compiler finds the .cpp files and compile them? Thanks.
  12. My goal is to create a list view, which would be easy to use, and which could be managed using class methods. As we know when event occurs list view sends a message to a parent window.So the parent window must define the list's view reaction to external events. This situation does not suits me because the code is becoming scattered and less reusable.I want list view to handle all events,manage popup menus.Parent window must not know about any list view existence. So i subclassed list view window procedure to handle events before they processed to the parent window.As was noticed before it is impossible to handle WM_RBUTTONUP message even in subclassed procedure. I noticed that it is impossible to capture "right mouse button up" message with WM_NOTIFY/NM_RCLICK message.WM_CONTEXTMENU message solved the problem. Is is sent anytime the right mouse button goes up in the window. The only inconvenience is thatr it is necessary to check whether item is selected/focused or not and how many items are selected.My code for that is as follows: case WM_CONTEXTMENU: { int sm = SendMessage(object->listviewhandle,LVM_GETSELECTIONMARK,0,0); if(sm!=-1) //some items are selected or focused { int selcount = SendMessage(object->listviewhandle,LVM_GETSELECTEDCOUNT,0,0); if(selcount>1) break; //if more than one selected don't track //cheking if selected int fm = SendMessage(object->listviewhandle,LVM_GETITEMSTATE,sm,LVIS_FOCUSED|LVIS_SELECTED); int b = LVIS_SELECTED; if( (fm&LVIS_SELECTED)!=0) //is selected { POINT cpos; GetCursorPos(&cpos); TrackPopupMenu(object->popupselmenu,TPM_LEFTALIGN,cpos.x,cpos.y,0,object->listviewhandle,0); break; } else //maybe focused? { if( (fm&LVIS_FOCUSED )!=0) //is focused { POINT cpos; GetCursorPos(&cpos); TrackPopupMenu(object->popupnoselmenu,TPM_LEFTALIGN,cpos.x,cpos.y,0,object->listviewhandle,0); break; } } } else //no selection { POINT cpos; GetCursorPos(&cpos); TrackPopupMenu(object->popupnoselmenu,TPM_LEFTALIGN,cpos.x,cpos.y,0,object->listviewhandle,0); } } break; This code is not good but i have no idea how to make more shorter. When the user selects menu item in popup menu,the WM_COMMAND message handler calls virtual function which must be described in derived class.So certain type of universality is achieved :)
  13. Hi everyone, I'm using ListView control (no MFC pure api). I need to handle WM_RBUTTONUP message. To achieve that i subclassed the List View window. New procedure looks like: LRESULT CALLBACK newproc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch(uMsg) { case WM_RBUTTONUP: { Beep(8000,100); } break; default: return oldproc(hWnd,uMsg,wParam,lParam); } return oldproc(hWnd,uMsg,wParam,lParam); } The problem is that WM_RBUTTONUP triggers only if i do double click with right mouse button. It strange bacause WM_RBUTTONDOWN is processed normally.I checked the same situation is for left mouse button. Down is handled correctly up is only on double click. Where the problem can be?
  14. Hi everyone. I have a cube drawn in 3D using perspective projection. I wold like to detect if user's cursor is upon that object when user press a mouse button. Camera is moving freely and can be pointed at the object in any way. My idea is as follows: When a user press a button we have a coordinates x,y on the window rectangle relatively to any point of the window,let it be upper left.Then knowing the point C,V coordinated,view angle, distances to near and far planes we can calculate coordinates of point A. From cursor coordinates and window height and width we can get the ratio in which point A divides the screen,the same proportion will we for the near plane. When we know coordinates of A point we can define a line equation using point C and A. So now we can check if the line goes through the cube. I draw a picture to make myself clear. click me I started solving mathematical equations and though maybe OpenGL has any built in features that can help me. For example gluPerspective function is a wrapper round glFrustum so it somehow calculates the coordinates of the near plane.Maybe that can help me? Thanks in advance.
  15. OpenGL Get text length

    I tried to use GetTextExtentPoint32 function. It returns wrong string dimensions.
  • Advertisement