• Advertisement

Nick C.

  • Content count

  • Joined

  • Last visited

Community Reputation

225 Neutral

About Nick C.

  • Rank
  1. I have solved my problem by updating my graphics driver. That was dumb of me, should've been my first thought. This topic can be closed if needed.
  2. If I understand your question correctly, this may work. 1) Optionally: Update your character's rotation:   mRotation.y += mRotationSpeed * GAMETIMER->DeltaTime(); 2) Optionally: Update your character's position   mPosition.x += sin(mRotation.y) * mMovementSpeed * GAMETIMER->DeltaTime(); mPosition.z += cos(mRotation.y) * mMovementSpeed * GAMETIMER->DeltaTime(); 3) Set the position and angle of your camera, according to your character's position and rotation. Position: x = mPosition.x - sin(-mRotation.y) * mZoom y = mPosition.y - sin(your camera's roll (rotation around x axis)) * mZoom z = mPosition.z + cos(-mRotation.y)* mZoom Rotation: That's up to you. Good luck ;) Depending on your logic, you may adjust the sign, add/substract pi and change cos/sin. Edit: Don't forget about possible overflow. Make sure your angles stay under 2 * pi.
  3. Hello everyone Everything was going well with the project I'm working on, until suddenly it's almost impossible to debug my code. I can step over all my instructions in Visual Studio just fine, until I try to create a swap chain. From then on, I can barely move my mouse (5+ seconds to see change), and everything in visual studio takes  a very long time. Stepping over instructions then take up to 5 seconds and almost 20 seconds to stop debugging (shift + F5). All other programs running on my computer have no problems though. I've used this code for over two years now, and never had any problems. At this point, it's just impossible to continue my work if I can't solve this problem. Any help would be greatly appreciated. Edit: I also notice calling std::exit(0) takes longer than usual. Code (in case it matters): bool D3DApp::InitD3D() { UINT createDeviceFlags = 0; #if defined(DEBUG) || defined(_DEBUG) createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; #endif D3D_FEATURE_LEVEL featureLevel; HR(D3D11CreateDevice( 0, // default adapter D3D->md3dDriverType, 0, // no software device createDeviceFlags, 0, 0, // default feature level array D3D11_SDK_VERSION, &D3D->md3dDevice, &featureLevel, &D3D->md3dImmediateContext), "D3D11CreateDevice failed."); if (featureLevel != D3D_FEATURE_LEVEL_11_0) { MessageBox(0, "Direct3D Feature Level 11 unsupported.", 0, 0); return false; } HR(D3D->md3dDevice->CheckMultisampleQualityLevels( DXGI_FORMAT_R8G8B8A8_UNORM, 4, &D3D->m4xMsaaQuality), "Multisample quality level not supported by device."); DXGI_SWAP_CHAIN_DESC sd; sd.BufferDesc.Width = WINDOW->mClientWidth; sd.BufferDesc.Height = WINDOW->mClientHeight; sd.BufferDesc.RefreshRate.Numerator = 60; sd.BufferDesc.RefreshRate.Denominator = 1; sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; if (D3D->mEnable4xMsaa) { sd.SampleDesc.Count = 4; sd.SampleDesc.Quality = D3D->m4xMsaaQuality - 1; } else { sd.SampleDesc.Count = 1; sd.SampleDesc.Quality = 0; } sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; sd.BufferCount = 1; sd.OutputWindow = mhMainWnd; sd.Windowed = true; sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; sd.Flags = 0; IDXGIDevice* dxgiDevice = 0; HR(D3D->md3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice), "D3D::md3dDevice->QueryInterface failed."); IDXGIAdapter* dxgiAdapter = 0; HR(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter), "dxgiDevice->GetParent failed."); IDXGIFactory* dxgiFactory = 0; HR(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory), "dxgiDevice->GetParent failed."); HR(dxgiFactory->CreateSwapChain(D3D->md3dDevice, &sd, &D3D->mSwapChain), "dxgiFactory->CreateSwapChain failed."); ReleaseCOM(dxgiDevice); ReleaseCOM(dxgiAdapter); ReleaseCOM(dxgiFactory); OnResize(); return true; }
  4. I have the feeling you're abusing pointers a bit :). I've never in my life seen a pointer to pointer to pointer to pointer.
  5. Nice list. After a lot of work I've done all 9 of them . No particle system added yet, because I don't really need it for now. I also recommend (what I did) to create your own file format and converter for animation related data (skinned, skeletal). I find files like fbx very hard to understand, and Collada files (*.dae) contain much more unnecessary data and are not structured well (in my opinion).
  6. Okay, thanks everyone for the replies (and sorry for my late reply). It seems that I should have included my entire function to prevent confusion here, as some people don't really know what I want to archieve here. So: the object of this function was to split a string on a character. However, the function that Ravyne showed here (yes, I know there are even more possible solutions) doesn't really do what I want, as I have a few more requirements xd. That function was actually one of the first I came up with. Let me explain you a few other things. - If the string doesn't contain that character, the function stores the entire string in a vector (size 1) -if the string is empty, the function stores an empty string ("") in a vector (also size 1) -If the character occurs as first character an empty string will be stored as first element in the vector -If there are multiple duplicates of that character following, it ignores all those. An example: vector<string> splittedString; char splitChar = '.'; string stringToSplit = ".test...12..3."; After the instruction SplitLine(stringToSplit, splittedString, splitChar); splittedString contains the strings 0.  (empty) 1. test 2. 12 3. 3 4.  (empty) Not trying to argue, just saying how it is... Like wintertime said, those two loops don't exactly do the same thing, but they do if you actually see the entire function. As I said before, I've tested all the possibilities comprehensively. So, without further ado, my entire function. You can use all my possibilities, they all do the same thing.   inline void DaeToAniConverter::SplitLine(string line, vector<string>& splittedline, char splitchar) { //vector with string segments should contain at least one string if (line == "") { splittedline.push_back(""); return; } int ll = line.length(); splittedline.clear(); int prevIndex(0); int j(0); while(j < ll) { int tempJ = line.find_first_of(splitchar, j); j = tempJ >= 0 ? tempJ : ll; //skip multiple equal characters splittedline.push_back(line.substr(prevIndex, (j-prevIndex))); while (j < ll - 1 && line[++j] == splitchar) {} prevIndex = j; } }   As you can see here, the main loop is only executed as many times as there will be string segments (in my last example, 5 times), so not character per character. I actually do use line.find_first_of. And about that performance issue, you are all right . It really doesn't make a big difference, and a good structure is sometimes more important than performance. Thanks to everyone else for your constructive remarks. Again (but now you know what I want to archieve here), if there is a better way to archieve this functionctionality, I would gladly hear about it. I'm just a 19 year old student, programming in my free time. Everyone makes mistakes, right? gz Nick Edit: This may be important. This function is part of a program that reads a file, converts it to a custom format, and writes it to a new file. I'm talking about pretty big files, so this function is usually executed at least hundred times (usually a few hundred). Right now it only takes 2-5 seconds for the program to do its thing, so that's not too bad .
  7. Hello all I don't usually write posts here, as I can find most information in the books I have, but I really have an interesting question here. I read some info on sequence points and order of evaluation in C++, but I'm still not sure about this issue. I have the following code (tiny part of a bigger function ofcourse). line is a string, ll is an int, j is an int and splitchar is a char The object of this piece of code is to increase j by 1, as long as the characer of line with index j, equals splitchar. The character of line with index j, before execution of the inner while loop code, always equals splitchar, quaranteed. So j will be increased by at least one. //some code int ll = line.length(); int j(0); while(j < ll) { //some code that uses and changes j, but nothing very important. It doesn't influence the following code or the subject of this topic. while (j < ll - 1 && line[j] == splitchar) ++j; //some code } I changed the inner while loop to while (j++ < ll - 1 && line[j] == splitchar) continue; or while (j < ll - 1 && line[++j] == splitchar) continue;    which are pretty much the same. Trust me, I've tested everything in detail ;) Note: postfix or prefix notation is very important here!   Now, my questions are; 1. Does it matter if I write "continue", or empty braces ("{}") in the last two examples, and how does this affect the performance? 2. Which one of these three would have the best performance? 3. Is there an even better possibility? Performance is not very important in this program, but I really want to know the little details, because it WILL matter in future projects. Thanks in advance Nick
  8. I think it would help the reader if you provided some specific code or compling errors ;) It's quite hard right now to see the problem.
  9. Note: -This is my personal opinion. -Don't read this if you're not interested in programming. My guess would be, and I ALWAYS think that when I want to learn a new aspect of programming or anything like that: buy a book. Really, there's no better way to learn something new. A few weeks ago I knew almost nothing about graphics programming (DirectX as my chosen API), and right now I know really, a lot. Books are written by people who are (or should be XD) very experienced in a certain field, and the books I've read were all written and explained very well, with many examples etc. The problem with learning something online is that a lot of info is widely spread on many places, and often written by "amateurs" (don't really like to use that word). So after have read some things, you may still have problems. You have to find all the info on many places, and you don't always know where. I know there are a lot of online places to learn about programming, and yes they are often good. But reading a book would be even better, and you will be spending your time more efficiently. Of course, it's still a matter of perseverance. You have to want to learn it. Because, when things get difficult, some people tend to give up. Anyway, that's just my opinion, books may not be the best way for someone to learn something, but for me it has worked very well so far. And to finish with, some books that may help YOU on the way (so skipping AI etc.) :) - Ivor Horton's beginning visual C++ 2012 (I have the 2010 version, but I suppose this one will be even better xd): For the complete beginner in the first few chapters to the more experience programmer in the later chapters. This was my first book I ever read about C++, and it has helped me a lot. - Introduction to 3D Game Programming with DirectX 11, by Frank D. Luna: I've read a big part of this, but I'm often having problems with it. It's a very nice book to start learning to program in DirectX 11 (and it covers quite a lot!), but not for the beginner. It also covers the basic math for computer graphics (especially in the first few chapters). I don't know any good books for OpenGL (I have the OpenGL superbible, but haven't read much in it yet xd). I've also read good reviews for the following (will read them soon): -Mathematics for 3D Game Programming and Computer Graphics, Third Edition, by Eric Lengyel -The C++ Standard Library: A Tutorial and Reference (2nd Edition), by Nicolai M. Josuttis That'll keep you busy for a few months or years xd. After that you can specialise in AI, algorithms, networking, ot whatever you want. Have a nice day :) Nick Edit1: Oh yeah, my advice: don't use an engine linke Unity or anything like that. If you really want to learn to program, go hardcore and start from "scratch" in an API like DirectX or OpenGL ;) If you just want to make games, without knowing too much of the technical aspect, you can use an engine.
  10. Solved! I had to #include <d3dx11.h> first. 1 rep for Erik!
  11. "Error 1 error C2146: syntax error : missing ';' before identifier 'XMConvertToRadians' c:\program files (x86)\microsoft directx sdk (june 2010)\include\xnamath.h 159" and code in xnamath.h: //...code #define XM_CRMASK_CR6BOUNDS XM_CRMASK_CR6FALSE #define XM_CACHE_LINE_SIZE 64 /**************************************************************************** * * Macros * ****************************************************************************/ // Unit conversion XMFINLINE FLOAT XMConvertToRadians(FLOAT fDegrees) { return fDegrees * (XM_PI / 180.0f); } //...code The weird thing is, I don't have any problems using xnamath in other classes. I only get these errors when including it in this class (at "#include <xnamath.h>"). My project worked perfectly before the creation of this class.
  12. Hello everyone. I'm getting hundreds of errors (251 to be precise) in the file xnamath.h. I'm not going to show them all, because that wouldn't make sense. The file is fine, and I can use it perfectly in other projects. It's hard to find the cause of a problem if visual studio shows errors which are not wrong. I got this problem when creating the following class (pretty simple, so I don't see how this would cause any problems). Thanks in advance. (btw, I'm pretty sure this belongs to general programming. If not, sorry about that [img]http://public.gamedev.net//public/style_emoticons/default/unsure.png[/img] ) ModelInstance.cpp: [source lang="cpp"]#include "ModelInstance.h" ModelInstance::ModelInstance(XMFLOAT3 scale, XMFLOAT3 rot, XMFLOAT3 offset) : Scale(scale), Rot(rot), Offset(offset), Scale2(XMFLOAT3(1.0f, 1.0f, 1.0f)), Rot2(XMFLOAT3(0, 0, 0)), Offset2(XMFLOAT3(0, 0, 0)) { } ModelInstance::~ModelInstance() { } void Modelinstance::Update(float dt, bool walk, XMFLOAT3 scale, XMFLOAT3 rot, XMFLOAT3 offset) { Scale2 = scale; Rot2 = rot; Offset2 = offset; } XMFLOAT4X4 Modelinstance::World() { XMFLOAT4X4 worldTransform; XMStoreFloat4x4(&worldTransform, XMMatrixScaling(Scale.x, Scale.y, Scale.z) * (XMMatrixRotationX(Rot.x) * XMMatrixRotationY(Rot.y) * XMMatrixRotationZ(Rot.z)) * XMMatrixTranslation(Offset.x, Offset.y, Offset.z) * XMMatrixScaling(Scale2.x, Scale2.y, Scale2.z) * (XMMatrixRotationX(Rot2.x) * XMMatrixRotationY(Rot2.y) * XMMatrixRotationZ(Rot2.z)) * XMMatrixTranslation(Offset2.x, Offset2.y, Offset2.z)); return worldTransform; } [/source] ModelInstance.h: [source lang="cpp"]#ifndef MODELINSTANCE_H #define MODELINSTANCE_H #include <xnamath.h> struct ModelInstance { public: ModelInstance(XMFLOAT3 scale, XMFLOAT3 rot, XMFLOAT3 offset); virtual ~ModelInstance(); virtual void Update(float dt, bool walk, XMFLOAT3 scale, XMFLOAT3 rot, XMFLOAT3 offset); XMFLOAT4X4 World(); protected: XMFLOAT3 Scale, Scale2; XMFLOAT3 Rot, Rot2; XMFLOAT3 Offset, Offset2; }; #endif [/source]
  13. [quote name='SiCrane' timestamp='1352649116' post='4999934'] When you declare a static variable in a class, you still need to define it in a source file. In one source file you need to put: [code] Keyinfo Input::KeyinfoArr[ACTIONCOUNT]; [/code] [/quote] Stupid of me. Works like a charm now, thanks
  14. Hello everyone I'm writing an input managing class, and I've stumbled upon a problem right now. I've been trying to fix it for a long time, but I just don't see the problem. It's probably a minor detail (like always.. -.-), but I would really apreciate it if someone could take a look at it. The error I'm getting is: Error 13 error LNK2001: unresolved external symbol "private: static struct Input::Keyinfo * Input::KeyinfoArr" (?KeyinfoArr@Input@@0PAUKeyinfo@1@A) C:\Nick\D3D projects\DVD\Code\Chapter 25 Character Animation\SkinnedMesh\InputManager.obj [source lang="cpp"]header file: struct Input { //...some code public: enum Action{ MOVEFORWARD, MOVEBACKWARD, STRAFELEFT, STRAFERIGHT, JUMP}; static bool AllowAction(Action action); private: //...some code static const int ACTIONCOUNT = 5; // amount of possible controls/actions struct Keyinfo { Action action; int code; // virtual-key code associated with action bool pressed; bool down; }; static Keyinfo KeyinfoArr[ACTIONCOUNT]; }; cpp file: //...some code bool Input::AllowAction(Action action) { for (int i = 0; i < ACTIONCOUNT; ++i) { if (KeyinfoArr[i].action == action) { if ((KeyinfoArr[i].action == Action::MOVEFORWARD || KeyinfoArr[i].action == Action::MOVEBACKWARD || KeyinfoArr[i].action == Action::STRAFELEFT || KeyinfoArr[i].action == Action::STRAFELEFT) && KeyinfoArr[i].down) return true; if (KeyinfoArr[i].action == Action::MOVEFORWARD && KeyinfoArr[i].pressed) return true; } } return false; }[/source]
  • Advertisement