• Content count

  • Joined

  • Last visited

Community Reputation

118 Neutral

About Nicholas1991

  • Rank
  1. OK. Thanks for your help! I'll move on to the 3ds max forum ^^.   Best wishes Nicholas
  2. Hm, the problem is, I'm no 3ds max expert. Until now I thought I would need separate UV-Coords for all 12 maps. But if I would use the same UV-Coords for all 12 maps, my problem would be solved. However, I don't know, if someone more experienced with 3ds max would appreciate the option of individual UV-Coords for all maps :/ (maybe some advanced techniques require a special UV arrangement). But that question should probably be posted in a different forum ^^.   But with such a small VertexFormat splitting the streams would then be unnecessary, wouldn't it?
  3. Your last suggestion is exactly what I am looking for. So you suggest, I store the UV-Information in a texture-like-format and then access this information in the vertexshader via a texture sampler? So I guess my exporter for 3ds max could already store this information in the proper format. However, I read that sampling from a texture is slower than simply accessing data from the input struct. Is it true?   Thanks for your help so far, much appreciated Nicholas
  4. Here is some more code to show what is frustrating me. I'm copy&past-ing a lot which is exactly what I want to avoid :/. (I have not yet compiled it (I'm in the middle of rewriting parts of my code :/), so there might be some minor errors.)   First the VertexTypes:  struct VERTEX1MAP { DirectX::XMFLOAT3 position; DirectX::XMFLOAT3 normal; DirectX::XMFLOAT2 mapcoord[1]; }; struct VERTEX2MAP { DirectX::XMFLOAT3 position; DirectX::XMFLOAT3 normal; DirectX::XMFLOAT2 mapcoord[2]; }; struct VERTEX3MAP { DirectX::XMFLOAT3 position; DirectX::XMFLOAT3 normal; DirectX::XMFLOAT2 mapcoord[3]; }; ... and so on     And here are the methods used to fill the VertexArrays: VERTEX1MAP BinaryMeshExporter::getFilledVertexType1(const Point3& position, const Point3& normal, const UVVert* uv, const pair<int,int>& uvAccess) { VERTEX1MAP out; out.position = Point3ToXMFLOAT3(position); out.normal = Point3ToXMFLOAT3(normal); out.mapcoord[0] = XMFLOAT2(uv[0][uvAccess.first], -uv[0][uvAccess.second]); return out; } VERTEX2MAP BinaryMeshExporter::getFilledVertexType2(const Point3& position, const Point3& normal, const UVVert* uv, const pair<int,int>& uvAccess) { VERTEX2MAP out; out.position = Point3ToXMFLOAT3(position); out.normal = Point3ToXMFLOAT3(normal); for ( int i=0; i<2; i++ ) out.mapcoord[i] = XMFLOAT2(uv[i][uvAccess.first], -uv[i][uvAccess.second]); return out; } VERTEX3MAP BinaryMeshExporter::getFilledVertexType3(const Point3& position, const Point3& normal, const UVVert* uv, const pair<int,int>& uvAccess) { VERTEX3MAP out; out.position = Point3ToXMFLOAT3(position); out.normal = Point3ToXMFLOAT3(normal); for ( int i=0; i<2; i++ ) out.mapcoord[i] = XMFLOAT2(uv[i][uvAccess.first], -uv[i][uvAccess.second]); return out; } ... And so on   Now as you can see, they are basically identical except for the array size of mapcoord. And also the fillmethods are identical except for the VertexType they use. Is there any kind of polymorphic concept for structs (without changing the structs size)?   I'm really desperate to change the code above (for the better), but I do not see how :/.
  5. I know my English isn't the best at the moment so is anything confusing about my question? I mean, "it can't be done" is also ok, if that's the case ^^.     Thanks in advance Nicholas
  6. Hi Folks,   This is some kind of beginner question, but I couldn't find the answer anywhere. I have successfully used the following Vertex-Type until now for simple textured geometry. An array of these vertices is then passed via IASetVertexBuffers(...): struct VERTEXPOSITIONNORMALTEXTURED { D3DXVECTOR3 position; D3DXVECTOR3 normal; D3DXVECTOR2 texcoord; static D3D11_INPUT_ELEMENT_DESC* GetVertexLayout() { static D3D11_INPUT_ELEMENT_DESC layout[] = { {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, {"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; return layout; } static UINT GetNumElements(){ return 3; } };   Now I would like to use more than one map on certain objects. I could of course now create lots of VertexTypes with one to ten UV-Coordinates for example to deal with objects that have one to ten UV-Coordinates. However that is not really an elegant solution. Of course I don't want to use an array of fixed size ten because then most of the time I store almost ten times as much data for each vertex than is necessary (most objects ingame only have a texture and no other maps, and most objects that use more than one map will probably not use all ten map slots). But if I want to create an array with unkown size during compiletime I would use pointers.       ... D3DXVECTOR3 position; D3DXVECTOR3 normal; D3DXVECTOR2* texcoords; UINT numTexCoords; ... ? ?     The layout[] would also be created during runtime. But what about the pointer? How do I Access this array in my HLSL VertexShader Method?     Thanks in advance Nicholas
  7. Thank you, works like a charm! Yours, Nicholas
  8. Hi guys, I had to stop working on my Game for quiete some time but now I am continuing with Susanne Wigard's Book on how to programm a basic game engine. Now I copied the fx-File from the CD that came with the book but for some reason my specular-light-dot is not behaving as planned (see pictures below). The fx-File: [CODE] //-------------------------------------------------------------------------------------- // Datei: Glanzlicht.fx // // Glanzlicht // // Susanne Wigard 2009 //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- // Global variables //-------------------------------------------------------------------------------------- cbuffer cb0 //Standardshader { float4 g_MaterialAmbientColor; // Material's ambient color float4 g_MaterialDiffuseColor; // Material's diffuse color float3 g_vLightDir; // Light's direction in world space, normalized float4 g_LightDiffuse; // Light's diffuse color float g_fTime; // App's time in seconds float4x4 g_mWorld; // World matrix for object float4x4 g_mWorldViewProjection; // World * View * Projection matrix } cbuffer cb1 //Für Glanzlicht { float4 g_LightSpecular = float4(1, 1, 1, 1); float g_SpecularPower; float4x4 g_mView; float4x4 g_mProj; } //-------------------------------------------------------------------------------------- // Vertex shader output structure //-------------------------------------------------------------------------------------- struct VS_OUTPUT { float4 Position : SV_Position; // vertex position float4 Diffuse : COLOR0; // vertex diffuse color (note that COLOR0 is clamped from 0..1) float2 TextureUV : TEXCOORD0; // vertex texture coords }; //-------------------------------------------------------------------------------------- // Vertexshader mit Glanzlicht //-------------------------------------------------------------------------------------- VS_OUTPUT RenderMitGlanzlichtVS( float4 vPos : POSITION, float3 vNormal : NORMAL) { VS_OUTPUT Output; float4 worldPos = mul(vPos, g_mWorld); float4 cameraPos = mul(worldPos, g_mView); //Position im Koordinatensystem der Kamera Output.Position = mul(cameraPos, g_mProj); float3 vNormalWorldSpace; vNormalWorldSpace = normalize(mul(vNormal, (float3x3)g_mWorld)); // normal (world space) float3 halfAngle = normalize(normalize(-cameraPos) + g_vLightDir); float NDotH = max(0, dot(halfAngle, vNormalWorldSpace)); Output.Diffuse.rgb = g_MaterialDiffuseColor * g_LightDiffuse * max(0,dot(vNormalWorldSpace, g_vLightDir)) + g_LightSpecular * pow(NDotH, g_SpecularPower) + g_MaterialAmbientColor; Output.Diffuse.a = 1.0f; return Output; } //-------------------------------------------------------------------------------------- // Standard-Pixelshader ohne Textur //-------------------------------------------------------------------------------------- float4 SimplePS( VS_OUTPUT In ) : SV_Target { return In.Diffuse; } //-------------------------------------------------------------------------------------- // Rendern mit Glanzlicht ohne Textur //-------------------------------------------------------------------------------------- fxgroup Glanzlicht { technique11 RenderMitGlanzlicht { pass P0 { SetVertexShader( CompileShader(vs_4_0, RenderMitGlanzlichtVS())); SetGeometryShader( NULL ); SetPixelShader( CompileShader(ps_4_0, SimplePS())); } } } [/CODE] What happens is.... strange. The diffuse and the ambient light work as intended. The specular lighting however screws up. Lets say the Sphere is always centered around (0,0,0) and has a radius of 2.0f. The Camera starts at (0.0f, 0.0f, 5.0f) and is directed towards (0,0,0). The light source ist at (0,0,10.0f) and it's direction vector is (0,0,1.0f). Then I see the following: (pictures attached with 1_ prefix) [attachment=11126:1_beginning.png] [attachment=11127:1_looking_up_slightly.PNG] [attachment=11128:1_moving_to_the_right_looking_down_slightly.png] However, if I change the light source to (10.0f, 0, 0) pointing at (1.0f,0,0) I see the following: (pictures attached with 2_ prefix) [attachment=11129:2_beginning.png] [attachment=11130:2_moving_to_the_left.png] [attachment=11131:2_moving_to_the_left_and_up.png] As you can see in the second setup the white spot is not moving at all. I mean the view matrix is used for the specular highlight but also for the calculation of the output position, so I assume it is correctly set. Maybe something went wrong during vector conversions (3 and 4 entries)? Or is it something more obvious? [img][/img] Yours, Nicholas P.S.: I've only started working with different rendering techniques. Up until now I always used a default fx-file so please keep it simple ;).
  9. templates and default values by default?

    I'm reading "Spieleprogrammierung mit DirectX 11 und C++" by Susanne Wigard. C++ is compared to java a pain in the... (personal opinion) But for me C++ seemed to be the best way to program 3D Games. Anyways, since the classes that leave out some template parameters do not use them at all it should be safe to fill in some random stuff. The book is only a guideline for beginners to get to know DirectX and general concepts so most likely parts of the code will be changed, expanded or removed later when I have some idea of how a game engine is structured.
  10. Hello everyone, with the help of a book and online tutorials I try to get into game programming. However, I'm still new to C++ so while reading and programming a little with C++ I had some trouble with templates. That's what I find in the book I'm reading: template <class blub, bool bSomething, typename someType> class MyClass { public: MyClass(); ~MyClass(); }; template <class blub, bool bSomething, typename someType> MyClass::MyClass() { } And then later: class NewClass : public MyClass<SOMECLASS> { //... }; Now the compiler obviously complains about missing template arguments, so I just fill in some values and everything works fine. However, it bothers me that throughout the entire book the author leaves out template arguments without defining default ones. I'm a bit worried that my app might show unexpected behaviour because of that. Thus my question wheter or not there is a way that the code as printed in the book works.
  11. Trouble with Templates and error C2039

    Ok, this time it was my fault. I had #include "OctreeNode.h" in DynamicEntity.h and vice versa. Now removed the entry in OctreeNode.h and everything works fine :).
  12. Hello everyone, I'm having some trouble with my application. Using the book "Spieleprogrammierung mit DirectX 11 und C++" I try to get startet with game programming. However, I must say that I have already found some mistakes in the book (Is it possible that Visual Studio Express 2008 (recommended by the author) and 2010 differ so much? I don't think so). Until now I could solve them myself with a bit of Internet research. But since I'm new to C++ (used Java before) this time I can't make out how to cange my application to make it run. "error C2039: '{ctor}': Ist kein Element von" (Is no element of) This is the part the compiler complains about: The code is in DynamicEntity.h, the definition of the constructor is in OctreeNode.h template<class VertexType, bool bIndexed, typename IndexType> OctreeNode::OctreeNode(const DynamicEntity<VertexType, bIndexed, IndexType> *pEntity) : m_bbMin(pEntity->m_bbMin), m_bbMax(pEntity->m_bbMax) { for (UINT64 idx = 0; idx < pEntity->m_nIndices; idx += 3) { D3DXVECTOR3 p[3]; for(int i = 0; i < 3; i++) { p[i] = ((VertexType*)pEntity->m_pVertices + pEntity->m_pIndices[idx + i])->position; m_Points.Add(p[i]); } } CreateChildNodes(); } This might also be important: In DynamicEntity.h template<class VertexType, bool bIndexed, typename IndexType> class DynamicEntity : public Visual { friend class OctreeNode; //.... And in OctreeNode.h template<class VertexType, bool bIndexed=true, typename IndexType = UINT16> class DynamicEntity; class OctreeNode { //... Since the project is already pretty extensive I don't want to post all of the code here. But if you need further information I will post some more. BTW: Why is there no preview Button? I would like to see how my post looks like before actually posting it.