Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

112 Neutral

About Ncyphe

  • Rank
  1. Thank You Everyone. I wanted to post my (near) final code for my CSectorMap // //Description: // A sector map is a data structure designed to store information on an [x,y,z] grid. // Its primary utilization is in tracking object placement in a 3D grid // // CSectorMap can be used to represent bot a 2D or 3D grid // // The individual chart elements are designed to be directly accessable; // however, direct access to the vector is not allowed. #ifndef CSECTORMAP_H #define CSECTORMAP_H #include <vector> #include <map> using std::vector; using std::map; template <class T> class CSectorMap { private: vector<T> VecChart; int iElementCount; //Total numbe of elements int iWidth; //width of the chart int iDepth; //Depth of the chart int iHeighth; //Heighth of the chart int iXMod; //modifies the index representing the first X-Element int iYMod; //modifies the index representing the first Y-Element int iZMod; //modifies the index representing the first Z-Element public: CSectorMap(); CSectorMap(int pWidth, int pDepth, int pHeight); CSectorMap(int pWidth, int pXIdxStart, int pDepth, int pYIdxStart, int pHeighth, int pZIdxStart); ~CSectorMap(); T& at(int x, int y, int z); //acces chart based on 3D idx T& at(int idx); //For direct access to the vector int size(); //Return the total number of elements }; template<class T> CSectorMap<T>::CSectorMap() { iElementCount = 0; iWidth = 0; iDepth = 0; iHeighth = 0; } template<class T> CSectorMap<T>::CSectorMap(int pWidth, int pDepth, int pHeighth = 0) { iElementCount = pWidth * pDepth * pHeighth; iWidth = pWidth; iDepth = pDepth; iHeighth = pHeighth; VecChart = vector<T>(iElementCount); } template<class T> CSectorMap<T>::CSectorMap(int pWidth, int pXIdxStart, int pDepth, int pYIdxStart, int pHeighth = 0, int pZIdxStart = 0) { iElementCount = pWidth * pDepth * pHeighth; iWidth = pWidth; iDepth = pDepth; iHeighth = pHeighth; iXMod = pXIdxStart; iYMod = pYIdxStart; iZMod = pZIdxStart; ecChart = vector<T>(iElementCount); } template<class T> CSectorMap<T>::~CSectorMap() { } template<class T> T& CSectorMap<T>::at(int x, int y, int z = 0) { return + (y*iWidth) + (z*iWidth*iHeighth)); } template<class T> T& CSectorMap<T>::at(int idx) { return; } template<class T> int CSectorMap<T>::size() { return (int)VecChart.size(); } #endif As I mentioned before, I built this for the purpose of storing information in a 3D grid. Because of that, I may rename it to Grid. A few other accessors will be added to obtain the grid width, height, and depth as well. The main purpose of this is I'm a Games and Simulations Programming student at DeVry, on my final year. I'm an excellent programmer, it's just I haven't done everything, and a lot of my knowledge will only come from years of experience in my future workplace. But I plan on using this in a simple base simulator, and this storage container will hold information related to each cell. The game will be played in a 2D style, but keeping it 3D will make it easily reusable. Again, thank y'all for your help, I really appreciate it.
  2. Quote:Original post by ApochPiQ Read through these FAQs to explain what's going on in your code, and why you're getting errors. WOW! That was perfect, an exact explanation of what was going on, thank you!
  3. Quote:Original post by Mike nl How are you using your template class? I would wager (from the error code) that you're using it as, for instance: CSectorMap<T> map; In which case you need to put an actual type there like 'int' instead of T. Edit: or it seems you're putting member functions in a source file, e.g.,: void CSectorMap<T>::foo() { } This doesn't work. All template member functions must be in the header file. So, I cannot use a .cpp file to define functions for a templated class? I'll try that and see what it gets me.
  4. I'm sorry, I was in such a hurry that I didn't even think about the error code. Here's the snippet from the compuile log: 1>------ Build started: Project: Testing_Grounds, Configuration: Debug Win32 ------ 1>Build started 10/14/2010 7:45:12 AM. 1>InitializeBuildStatus: 1> Touching "Debug\Testing_Grounds.unsuccessfulbuild". 1>ClCompile: 1> main.cpp 1> CSectorMap.cpp 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(1307): error C2036: 'T *' : unknown size 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(1301) : while compiling class template member function 'void std::vector<_Ty>::_Tidy(void)' 1> with 1> [ 1> _Ty=T 1> ] 1> c:\users\ben\documents\visual studio 2010\projects\testing_grounds\testing_grounds\csectormap.h(24) : see reference to class template instantiation 'std::vector<_Ty>' being compiled 1> with 1> [ 1> _Ty=T 1> ] 1> c:\users\ben\documents\visual studio 2010\projects\testing_grounds\testing_grounds\csectormap.cpp(3) : see reference to class template instantiation 'CSectorMap<T>' being compiled 1> with 1> [ 1> T=T 1> ] 1> Generating Code... 1> 1>Build FAILED. 1> 1>Time Elapsed 00:00:01.65 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Hope that helps in figuring out a solution.
  5. I have a small problem. I'm trying to define a templated class called SectorMap for the purpose of acting like a grid (2D or 3D). I want to use a vector to maintain all of the data, but I keep running into problems. using std::vector; template<class T> class SectorMap { private: vector<T> VecChart; ... basically, the compiler keeps throwing errors with vector<T>, and I've been trying to come up with a way to by pass that . . . and yet failed each time. Is there anyway around this? Note: The reason I'm building this is for a portfolio project I'm working on. I plan to use this data structure to store information about entities in each 3D sector.
  6. Ncyphe

    ID3DXEffect manager design?

    I'll take a deeper look at the documentation. I'll probably be back later with more questions, though.
  7. Ncyphe

    ID3DXEffect manager design?

    Quote:Original post by monkeyboi Have a look at the example of SDK called statemanagement This sample shows an example implementation of the ID3DXEffectStateManager interface. this inteface can be used to implement custom state-change handling for the D3DX effects system I have taken a glimpse of that; however, I wasn't too sure as to how I would go about actually using it.
  8. Ncyphe

    ID3DXEffect manager design?

    Quote:Original post by Gage64 I probably don't know enough about this to give you advice, but still I'd like to understand your problem a little better. Quote:-I don't know what variables will be used within the effect file Does this mean that the manager should pass the effect any variables it needs automatically? I think you can do something like this with HLSL semantics/annotations. Don't know if this is the best way, but it might be something to look into. Quote:-I don't know what information will be available with the mesh data Can you give more details? Maybe some examples? BTW, you can try looking at Ogre's source code, I think it contains some similar functionality. At least it might give you some ideas. I've considered using semantics; however, they start to cause problems if an effect file that's very different from normal use is applied. For example, one of my teammates developed a terrain renderer using texture blending. Naturally, I could create 4 different texture semantics; however, what if someone wanted to use more, it becomes a bit complicated. I'll probably end up using semantics in the end anyway (I'm already using them for camera variables.) As to the information. Obviously, each model would have at least a texture map; however, it may or may not have specular data, light map, emissivity map, etc. Ultimately, I'm trying to find the best solution for developing this class. I've already rewritten it 4 times, and would really only like to write it one last time. edit: I should give a further example. Say I have an object that uses a shader with 3 texture, and has 3 textures stored. What if the programmer using the engine decides to change the shader that object uses to one that uses 4 textures. Obviously, for this case, the data passing cannot be hard-coded and must somehow be made dynamic. My confusing hit a wall here. How to make it dynamic. I've tried creating a "passing" struct, but that blew up in my face.
  9. I've already asked this before, but I don't think I was very clear on what I was asking at the time. Anyway, I really need help, guys. I need to design and develop an effect manager for ID3DXEffect to store and allow for the rendering of effects on 3D data. I've scoured the net and have found very little information, and the info I have found doesn't relate to what I'm trying to do. Basically, I'm currently in school, and the professor tasked us with building a simple game engine. My group, the graphics group, was required to design the graphics core to be able to run any shader passed to it. My major problem is that I can't figure out a means to make it so that the Effect Manager is autonomous. Rules on the design: -I don't know what variables will be used within the effect file -I don't know what information will be available with the mesh data I really need a lot of help guys, my head is about to explode, and despite how hard I've been trying to figure this problem out, my group mates are really starting to get angry at me for not living up to my part of the project.
  10. in particular, with use of shaders. Basically, I'm looking for any resources, even books. Basically, I'm trying to figure out how to develop a practical dynamic shader engine to work side by side with graphics. I can't find any resources online, and most of the books are so expensive that I can't risk buying one just to find it doesn't help me at all. I need all the help I can get. Edit: Let me go into a little more detail. I'm in a senior level Engine Development class where I've been tasked with programming a Dynamic Shader class that will accept any .fx file passed in. This is driving me crazy as I've already rewritten my code several times over from incompatibilities. I've got it into a usable state for the final project in the class, but I already need to reprogram it again for the senior project. I need all the help I can get guys, creating a dynamic shader class is just driving me mad. [Edited by - Ncyphe on August 24, 2010 12:29:32 AM]
  11. Ncyphe

    D3DX SetTransform

    That y'all for all your help guys. Shaders are not my most knowledgeable subject, but I am learning a lot. Right now, I'm enrolled in the DeVry Games and Simulations Programming coarse, in my engine design class. I was tasked with programming a dynamic shader class, able to load shaders, and draw shaders, so that was a lot to ask for from me. I program one set of code, get it working, the professor has issues with it rewrite get code working, classmates have issues with it (too many function calls for our scripting class) rewrite to use custom ".material" and ".shader" files containing data about the shader, and info to pass to the shader. And this is where I'm at now. Group-mate informed me that her skybox wasn't moving, was passing the wrong World matrix, then I realized that the LoadMaterial function I created can only be used outside of a render loop. I think I fixed that, but it's been a long 8 weeks. This should have been finished 4 weeks ago, lol. edit: I do have to say though, a lot of people say I am very smart; however, I tend to learn very slowly, often with the solution just suddenly popping into my head on day . . . while doing something entirely irrelevant. [Edited by - Ncyphe on August 23, 2010 12:22:11 PM]
  12. Ncyphe

    D3DX SetTransform

    Thanks for the information. All these years reading the tutorials and books, it sounded like the World matrix was for doing something like modifying the world axis, or I don't know what I thought. The books all said, "Convert To World Space," why couldn't they have just said, "aligns the object within it world position, rotation, and scale."
  13. Very quick question guys, and I need a quick answer. The (D3DXGraohicsDevice)->SetTransform(~~) function that can be used to modify a mesh's position on screen. Can it still be used in conjunction with shader rendering? Note that this is in C++. Edit: This may be just hitting me now, but is the World matrix supposed to represent the actual position of an object in the world?
  14. Ncyphe

    Problem with HLSL

    Quote:Original post by Buckeye Quote:should I just multiply it by the world alone, and not with the projection or view matrix? Correct. Again: Quote:You should be using the world position of the vertex ... You'll have to supply a World matrix for the vertex conversion. // Transform vertex position to world space. float3 posWorld = mul(float4(input.position, 1.0f), WorldMat).xyz; // Unit vector from vertex to light source. float3 lightDirection = normalize(LightPosition - posWorld); Thanks, I'll give that a shot. Edit: Lol, I found an error in my code, but that World thing worked. I never realized that I would have needed to do a different mul() for obtaining the light vector. Thanks a lot!
  15. Ncyphe

    Problem with HLSL

    Quote:Original post by Buckeye Quote:float3 LightDirection = normalize(float4(,0.0f) - output.Position).xyz; If, as it seems to indicate, your light position is in world space, you're using the vertex WorldViewProj transformed position to determine the direction. That doesn't look right. You should be using the world position of the vertex, I believe. You'll have to supply a World matrix for the vertex conversion. Something like (stealing from Frank Luna): *** Source Snippet Removed *** But I've already done that. I multiplied it by the WorldViewProj matrix output.Position = mul(input.Position, WorldViewProj); should I just multiply it by the world alone, and not with the projection or view matrix?
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!