• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About Hirocon

  • Rank
  1. Hello. I'm trying to remove an entry from a Lua table indexed with strings. If the Lua table were indexed by number, I could type table.remove(table, index) where index is a number. But the Lua compiler I'm using won't let me pass in a string as the index in the table.remove function. I need to remove old entries from a string-indexed table to avoid memory leaks. What do I do?
  2. I'm trying to render to a texture, and it's sort of working, but for some reason the depth test isn't always working. Sometimes farther away polygons are drawn on top of closer polygons. My texture render target is the exact same size as the back buffer, I'm using the same geometry and transformation matrices, and when I render to the back buffer the depth test works fine. I don't know what I'm doing wrong. I saw there was a thread about this same issue in OpenGL, but not in DirectX. I go out of my way to clear the depth buffers and enable the depth test before rendering. This is the code I have immediately before the call to BeginScene: direct3DDevice->SetRenderTarget(0, AAsurface); direct3DDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); direct3DDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); direct3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE); direct3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); It doesn't work. Help please.
  3. I'm trying to compile a shader (.fx file) using D3DXCreateEffectFromFile, and it is failing. I can make changes to the .fx file to get it to compile (but not do what I want) so I know the error is in the .fx file itself. How do I identify the error? Please help, I'm a noob at this.
  4. I'm trying to write a simple program that lets me open a .png file, read and write the argb values at each pixel, and save the file. I tried doing this in C# with the Bitmap class, as below: Bitmap map = new Bitmap("MyPng.png"); map.SetPixel(0, 0, Color.FromArgb(128, 50, 100, 150)); map.Save("MyPng2.png", System.Drawing.Imaging.ImageFormat.Png); This works, except the alpha channel doesn't get saved properly (all the pixels I set are entirely opaque). What am I doing wrong? Is there any easy way to do this in either C++ or C#, preferably without having to download and figure out how to use a bunch of other libraries?
  5. I'm trying to write a basic math library for use in games. I'm writing support for 4D matrices and vectors because I want to be able to use a single matrix to describe both rotations and translations. But I don't know of a clean way to handle addition between two 4D matrices or two 4D vectors. For example, if I want to sum up a bunch of vectors and then transform the sum by some matrix, I'll probably want the w coordinate of the sum vector to be 1, but if I just do straight vector addition it will end up being more than 1. I could just ignore the fourth dimension when performing addition, but this seems like an ugly hack. This seems like it would be a fairly common problem, so I'm just wondering if there is some sort of convention on how to perform addition.
  6. SixAxis interface?

    I'm not interested at this point in anything as specific as the response range of the accelerometers. I just want to know what type of information is provided. For how many axes does the controller give raw acceleration and/or rotation data, at how many points within the controller? Anyone with access to a PS3 SDK would necessarily know this information. It hadn't occurred to me that information this basic would be restricted under an NDA, but I guess it could be. Time to go look for the patent...
  7. I'm doing research on motion-based controllers and I'm trying to compare the Wii remote to the PS3 SixAxis controller based on the actual information provided by the controller. The Wii Remote doesn't actually provide information about all six degrees of freedom of motion. It provides acceleration data along three local axes, and information about the positions and intensities of infrared lights from the "sensor bar" as seen by the remote. When the wii remote is not pointed at the sensor bar (leaving only the acceleration data), the problem of tracking the wii remote's motion in all six degrees of freedom is under-constrained. I cannot find the corresponding information for the SixAxis controller. Does it live up to its name by actually providing information about all six axes? I'd like to find some source describing the specific motion data that can be read from a SixAxis controller, and if possible some description of the internal hardware used to generate this data. So far I have been unable to find any such sources. Can anyone help?
  8. I'm using the code linked from http://simulatedcomicproduct.com/2006/12/cwiimote-02.php to try to interact with a Wii remote in C++. I have the wiimote connected to the PC through the windows stack, and I know it is connected successfully because I can interact with it using the GUI linked from http://code.google.com/p/wiimote-api/. The code I downloaded compiles and runs without crashing, but I can't connect to the wiimote. The code appears to fail on a call to HidD_GetAttributes, which should return a non-zero value but returns false. I can't find much helpful documentation on this function anywhere, and I'm not sure exactly what it is supposed to do. The code where this function is called seems to try to loop through a bunch of devices looking for one that matches the profile of a wiimote, but the call to HidD_GetAttributes returns false the first time, as if it can't find any devices at all. Please help. What exactly does HidD_GetAttributes do, and why would it return false? Edit: I'm using Windows XP Professional with service pack 2, and I compiled the code through Visual Studio 2005 Express.
  9. C++ binary file IO

    It's working now. Thank you for the advice!
  10. I'm trying to write some code using IO with binary files in C++, but I'm having trouble doing very basic operations. I wrote the code below just as a test, to copy one file ("from") to another file ("to"). This seems like it should be a simple thing to do. ifstream from; ofstream to; from.open("from"); to.open("to"); char c; while(!from.eof()) { from.read(&c, 1); to.write(&c, 1); } from.close(); to.close(); Copying 1 byte at a time is probably not the most efficient way to do this, but this is just a test. The code above compiles and doesn't give any runtime errors, but it doesn't copy files correctly. The from.eof() call always seems to return true much too soon, so not all of the file is copied. I can't discern any pattern in when eof() returns true, but for any given file it always seems to happen in the same place. I don't want to attempt anything more complex until I get this working. Someone please help. Why does this code not correctly copy files?
  11. The working directory was the problem! I moved the exe to the appropriate folder and it ran fine. 10,000 thanks!
  12. When I build my game in release mode and run it from the IDE, without debugging, the game runs fine. But, when I run the program from the .exe file in the release folder, it crashes (the pop-up window asking if I want to send an error report appears). I'm using Visual C++ 2005 Express. The game always crashes in the same spot. The game will not crash if I comment out this line and everything after it in my loop: hr = FAILED(hr) ? hr : m_keyboard->GetDeviceState(sizeof(unsigned char[256]), (LPVOID)keystate); but it crashes from the .exe if I just uncomment that one line (it still runs fine from the IDE). hr is an HRESULT, m_keyboard is an LPDIRECTINPUTDEVICE, and keystate is an array of 256 unsigned chars. I don't know what differences there are, if any, between running a program from the .exe and running it from within the IDE with debugging off, which is why this error is so baffling to me. Please help.
  13. I'm trying to program 3D rotational physics, using matrices. Right now I'm just considering the case of an object spinning at the origin without applied forces. I don't have much experience with this, so please correct me if I get anything wrong. It is my understanding that 3D physics objects have moments of inertia (represented by a 3x3 matrix) and angular momentums (represented by a 3D vector). The moment of inertia of a rigid body is constant, but it is represented in local coordinates so the moment of inertia is world coordinates can change with time. The angular momentum is constant in world coordinates. Say M is the angular momentum vector (in world coordinates), I is the moment of inertia matrix (in local coordinates) and R is the object's current orientation (the matrix that transforms local coordinates to world coordinates). I want to find the angular velocity vector w in world coordinates. I have the equation M = Iw but this isn't quite accurate since I is in local coordinates. To fix it I write M = RIw. w = (I^-1)(R^-1)M. As an alternative method of finding m, I could first convert M to local coordinates, solve for w in local coordinates, and convert to world coordinates. Writing wl for w in local coordinates, this looks like (R^-1)M = Iwl. wl = (I^-1)(R^-1)M. w = Rwl = R(I^-1)(R^-1)M. Unfortunately, these two methods give different results... so where is my error? What is the correct formula for w? Furthermore, after I find w, what do I do with it to update R? Say I have the rotation matrix R and the angular velocity vector w at a given moment, how do I calculate the new rotation matrix after some small delta t? I don't need any super accurate integration method, just something computationally cheap that won't quickly require reorthogonalizing the rotation matrix.
  • Advertisement