Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


newtechnology

Member Since 05 Nov 2013
Offline Last Active Yesterday, 02:38 AM

#5190357 What is a lobby server?

Posted by newtechnology on 31 October 2014 - 07:36 AM

Have you tried reading the FAQ or Googling?


Yes, but I don't understand it perfectly.


#5190145 What is a lobby server?

Posted by newtechnology on 30 October 2014 - 08:24 AM

I searched the internet but couldn't find a perfect answer. What are lobby servers? How are they different from general servers?

I want to start working on a small multiplayer fps game from scratch using C++ and DirectX 11. So, I want to start learning about networking (using winsock) for it. I cannot find any good resource for it. Isn't there a book or something similar which teaches networking (using winsock) to absolute network beginners?


#5162278 Why is this happening?

Posted by newtechnology on 23 June 2014 - 02:52 AM

I don't know why is this happening but I think its related to specular highlight problem. I'm 99% sure that problem isn't in shader.

Mskt6Uh.png

 

View from other angle:

 

cBP5UJf.png

 

 

The problem only occurs when I enter and look down into house. It doesn't happen when I'm far from the house.




#5160590 What to do now?

Posted by newtechnology on 14 June 2014 - 11:31 PM

Thank you for all this advice. I now understood that it is not important to finish the project but it is important to learn more and more. I already have a journal and a blog but there were very few comments so i stopped posting. But i think i will do it now again.


#5155792 Where to calculate TBN matrix?

Posted by newtechnology on 25 May 2014 - 12:34 AM

Thanks both.
@Newtechnology: how would you do that with just one normalize in the PS, you skip normalizing the vectors when they come into the PS? (normal, bitangent and tangent)

@OsmanB: but do I need the view vector per pixel instead of per vertex?

//---------------------------------------------------------------------------------------
// Transforms a normal map sample to world space.
//---------------------------------------------------------------------------------------
float3 NormalSampleToWorldSpace(float3 normalMapSample, float3 unitNormalW, float3 tangentW)
{
// Uncompress each component from [0,1] to [-1,1].
float3 normalT = 2.0f*normalMapSample - 1.0f;
 
// Build orthonormal basis.
float3 N = unitNormalW;
float3 T = normalize(tangentW - dot(tangentW, N)*N);
float3 B = cross(N, T);
 
float3x3 TBN = float3x3(T, B, N);
 
// Transform from tangent space to world space.
float3 bumpedNormalW = mul(normalT, TBN);
 
return bumpedNormalW;
}
 
//In pixel shader
 
float3 normalMapSample = gNormalMap.Sample(samLinear, pin.Tex).rgb;
float3 bumpedNormalW = NormalSampleToWorldSpace(normalMapSample, pin.NormalW, pin.TangentW);

this approach calculates bitangent in pixel shader.




#5155509 Where to calculate TBN matrix?

Posted by newtechnology on 23 May 2014 - 12:34 PM

Also binormal is wrongly used term, it is bitangent.


#5155071 Screenshot of your biggest success/ tech demo

Posted by newtechnology on 21 May 2014 - 09:05 AM

mAtE5rO.png
oEEYXzK.png


#5152469 Vertex Shader unexpected results, bizarre

Posted by newtechnology on 08 May 2014 - 11:27 PM

Maybe this could be because of wrong indexing?

For instance, there is an array of size 4.

int array[4]

And you are trying to access last element using array[4] instead of array[3].


#5152061 Vertex shader to pixel shader - way of sharing info?

Posted by newtechnology on 07 May 2014 - 09:38 AM

The output you return in vertex shader is input in pixel shader.


#5150261 how to load a 3D model with DirectX11?

Posted by newtechnology on 29 April 2014 - 01:43 AM

Use Assimp SDK to load models : http://assimp.sourceforge.net/




#5146652 Opinions needed

Posted by newtechnology on 13 April 2014 - 01:56 AM

DirectX 9 has a lot of overhead and it is no more updated. Use DirectX 11.




#5143835 Render Instanced models to shadows

Posted by newtechnology on 02 April 2014 - 12:27 AM

I fixed it. (the problem was with draw order)

10003368_858285324197823_867323870_n.jpg




#5142259 Help with my tree class

Posted by newtechnology on 26 March 2014 - 03:54 AM

The problem is solved, thank you for looking at this thread.


the problem was here:

void Tree::DrawFarModel(CXMMATRIX W)
{
if (farModel_NumVisibleObjects == 0)
return;
 
pDeviceContext->IASetInputLayout(InputLayouts::InstancedBasic32);
    pDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
 
UINT stride[2] = {sizeof(Vertex::Basic32), sizeof(Model::InstancedData)};
    UINT offset[2] = {0,0};
ID3D11Buffer* vbs[2] = {*far_mModel_MeshData.VertexBuffer, *mModel_MeshData.InstancedBuffer};

it should be:

3D11Buffer* vbs[2] = {*far_mModel_MeshData.VertexBuffer, *far_mModel_MeshData.InstancedBuffer};



#5131683 Directx 11 File Importing

Posted by newtechnology on 16 February 2014 - 05:39 AM

My directx 11 model loader using assimp. (I've gone through a lot of problems in model loading so give credits to me and other people (Richard software website's author, Frank .D luna and mrbeans22 (or something like that)) if you use this.)

#include "stdafx.h"
 
//================== .h file ===============================

#ifndef _MODEL_H_
#define _MODEL_H_
 
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
 
 
class MeshGeometry
{
public:
struct Subset
{
Subset()
{
ID = -1;
 
VertexCount = 0;
FaceCount = 0;
 
VertexStart = 0;
FaceStart = 0;
}
 
UINT ID;
UINT VertexStart;
UINT VertexCount;
UINT FaceStart;
UINT FaceCount;
 
};
 
public:
MeshGeometry();
~MeshGeometry();
 
template <typename VertexType>
void SetVertices(const VertexType* vertices, UINT count);
void SetIndices(const USHORT* indices, UINT count);
void SetSubsetTable(std::vector<Subset>& subsetTable);
 
void Draw(UINT subsetID);
 
private:
MeshGeometry(const MeshGeometry& rhs);
MeshGeometry& operator=(const MeshGeometry& rhs);
 
private:
ID3D11Buffer* VertexBuffer;
ID3D11Buffer* IndexBuffer;
 
DXGI_FORMAT IndexBufferFormat;
UINT VertexStride;
 
std::vector<Subset> SubsetTable;
};
 
 
 
class Model16
{
public:
struct InitInfo
{
//pointer to texture manager so that a same texture
//doesn't get loaded multiple times
TextureMgr* Mgr;
 
//Optional
//only set this if you want to manually set material
Material Material; 
 
//Set this to 0 for no lights
//NOTE: the number cannot be greater than 3
USHORT NumLights; 
 
//set this to true if you want to use materials loaded from model
//else set this to false if you want to manually specify materials
bool UseDefaultMaterial; 
};
 
std::vector<Vertex::Basic32> vertices;
public:
Model16();
~Model16();
 
void LoadModel(const std::string& FileName);
void Render(CXMMATRIX World);
 
void SetDirLight01(DirectionalLight& DirLight1);
void SetDirLight02(DirectionalLight& DirLight2);
void SetDirLight03(DirectionalLight& DirLight3);
 
void SetInitInfo(InitInfo& info);
private:
struct ModelData
{ 
ModelData()
{
mNumVertices = 0;
mNumFaces = 0;
mSubsetCount = 0;
}
 
MeshGeometry Mesh;
 
UINT mNumVertices;
UINT mNumFaces;
UINT mSubsetCount;
 
};
 
DirectionalLight Lights[3];
 
 
std::vector<ID3D11ShaderResourceView*> DiffuseMapSRV;
std::vector<Material> Materials;
 
ModelData mModel;
InitInfo mInfo;
};
 
 
 
#endif

 
 
//================== .cpp file ===========================
Model16::Model16()
{
//by default there are 3 directional lights
//but sometimes we don't want to compute lighting calculation for some objects
//which would go almost unnoticed so this class provides abilities for setting lights
//if the user sets 0 lights in initinfo then there would be no lighting calculation done 
 
//Init default light source
 
//50% light from front
Lights[0].Ambient  = XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f);
Lights[0].Diffuse  = XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f);
Lights[0].Specular = XMFLOAT4(0.0f, 0.0f, 0.0f, 1.0f);
Lights[0].Direction = XMFLOAT3(0.707f, -0.707f, 0.0f);
 
//45% light from back
Lights[1].Ambient  = XMFLOAT4(0.45f, 0.45f, 0.45f, 1.0f);
Lights[1].Diffuse  = XMFLOAT4(0.45f, 0.45f, 0.45f, 1.0f);
Lights[1].Specular = XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f);
Lights[1].Direction = XMFLOAT3(-0.707f, 0.707f, 0.0f);
 
 
//35% light from front
Lights[2].Ambient  = XMFLOAT4(0.35f, 0.35f, 0.35f, 1.0f);
Lights[2].Diffuse  = XMFLOAT4(0.35f, 0.35f, 0.35f, 1.0f);
Lights[2].Specular = XMFLOAT4(0.25f, 0.25f, 0.25f, 1.0f);
Lights[2].Direction = XMFLOAT3(0.707f, -0.707f, 0.0f);
 
 
mInfo.Mgr = nullptr;
mInfo.NumLights = 3;
mInfo.UseDefaultMaterial = true;
}
 
Model16::~Model16()
{
 
}
 
 
 
void Model16::LoadModel(const std::string& filename)
{
 
Assimp::Importer imp;
 
const aiScene* pScene = imp.ReadFile(filename,
   aiProcess_CalcTangentSpace |
aiProcess_JoinIdenticalVertices |
        aiProcess_Triangulate |
        aiProcess_GenSmoothNormals |
aiProcess_OptimizeMeshes |
aiProcess_PreTransformVertices |
aiProcess_RemoveRedundantMaterials |
        aiProcess_ConvertToLeftHanded |
        aiProcess_SortByPType);
 
if (pScene == NULL)
ShowError(imp.GetErrorString());
 
 
std::vector<USHORT> indices;
 
std::vector<MeshGeometry::Subset> subsets;
 
 
for (UINT i = 0; i < pScene->mNumMeshes; i++)
{
aiMesh* mesh = pScene->mMeshes[i];
 
MeshGeometry::Subset subset;
 
subset.VertexCount = mesh->mNumVertices;
subset.VertexStart = vertices.size();
subset.FaceStart = indices.size() / 3;
subset.FaceCount = mesh->mNumFaces;
subset.ID = mesh->mMaterialIndex;
 
mModel.mNumFaces += mesh->mNumFaces;
mModel.mNumVertices += mesh->mNumVertices;
 
for (UINT j = 0; j < subset.VertexCount; j++)
{
Vertex::Basic32 vertex;
 
vertex.Pos.x = mesh->mVertices[j].x;
vertex.Pos.y = mesh->mVertices[j].y;
vertex.Pos.z = mesh->mVertices[j].z;
 
vertex.Normal.x = mesh->mNormals[j].x;
vertex.Normal.y = mesh->mNormals[j].y;
vertex.Normal.z = mesh->mNormals[j].z;
 
if (mesh->HasTextureCoords(0))
{
  vertex.Tex.x = mesh->mTextureCoords[0][j].x;
  vertex.Tex.y =  mesh->mTextureCoords[0][j].y;
}
 
vertices.push_back(vertex);
}
 
for (UINT j = 0; j < subset.FaceCount; j++)
{
for (UINT index = 0; index < mesh->mFaces[j].mNumIndices; index++)
{
indices.push_back(subset.VertexStart + mesh->mFaces[j].mIndices[index]);
}
}
 
 
 
 
aiMaterial* Mat = pScene->mMaterials[subset.ID];
 
if (mInfo.UseDefaultMaterial)
{ 
Material tempMat;
 
   aiColor4D color(0.0f, 0.0f, 0.0f, 0.0f);
 
   tempMat.Ambient = XMFLOAT4(0.0f, 0.0f, 0.0f, 0.0f);
   tempMat.Diffuse = XMFLOAT4(0.0f, 0.0f, 0.0f, 0.0f);
   tempMat.Specular = XMFLOAT4(0.0f, 0.0f, 0.0f, 0.0f);
   tempMat.Reflect = XMFLOAT4(0.0f, 0.0f, 0.0f, 0.0f);
 
   Mat->Get(AI_MATKEY_COLOR_AMBIENT, color);
 
   tempMat.Ambient = XMFLOAT4(color.r, color.g, color.b, color.a);
 
   Mat->Get(AI_MATKEY_COLOR_DIFFUSE, color);
 
   tempMat.Diffuse = XMFLOAT4(color.r, color.g, color.b, color.a);
 
   Mat->Get(AI_MATKEY_COLOR_SPECULAR, color);
 
   tempMat.Specular = XMFLOAT4(color.r, color.g, color.b, color.a);
 
   Mat->Get(AI_MATKEY_COLOR_REFLECTIVE, color);
 
   tempMat.Reflect = XMFLOAT4(color.r, color.g, color.b, color.a);
 
  //set material if there is no material
  if (tempMat.Ambient.x == 0 && tempMat.Ambient.y == 0 && tempMat.Ambient.z == 0 && tempMat.Ambient.w == 0)
  tempMat.Ambient = XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f);
 
  if (tempMat.Diffuse.x == 0 && tempMat.Diffuse.y == 0 && tempMat.Diffuse.z == 0 && tempMat.Diffuse.w == 0)
  tempMat.Diffuse = XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f);
 
  if (tempMat.Specular.x == 0 && tempMat.Specular.y == 0 && tempMat.Specular.z == 0 && tempMat.Specular.w == 0)
  tempMat.Specular = XMFLOAT4(0.6f, 0.6f, 0.6f, 16.0f);
 
  Materials.push_back(tempMat);
}
else
{
Materials.push_back(mInfo.Material);
}
 
aiString path;
 
if (Mat->GetTextureCount(aiTextureType_DIFFUSE) > 0 && Mat->GetTexture(aiTextureType_DIFFUSE, 0, &path) == AI_SUCCESS)
{
char cpath[75];
 
sprintf(cpath, "Resources\\Textures\\%s", path.C_Str());
 
ID3D11ShaderResourceView* srv = mInfo.Mgr->CreateTexture(cpath);
 
DiffuseMapSRV.push_back(srv);
}
 
subsets.push_back(subset);
}
 
mModel.mSubsetCount = subsets.size();
 
mModel.Mesh.SetSubsetTable(subsets);
mModel.Mesh.SetIndices(&indices[0], indices.size());
mModel.Mesh.SetVertices(&vertices[0], vertices.size());
 
 
}
 
 
void Model16::SetDirLight01(DirectionalLight& Light)
{
Lights[0] = Light;
}
 
void Model16::SetDirLight02(DirectionalLight& Light)
{
Lights[1] = Light;
}
 
void Model16::SetDirLight03(DirectionalLight& Light)
{
Lights[2] = Light;
}
 
void Model16::SetInitInfo(InitInfo& info)
{
mInfo = info;
}
 
void Model16::Render(CXMMATRIX World)
{
 
ID3DX11EffectTechnique* activeTech;
 
 
    XMMATRIX worldInvTranspose = MathHelper::InverseTranspose(World);
XMMATRIX worldViewProj = World * d3d->m_Cam.ViewProj();
 
pDeviceContext->IASetInputLayout(InputLayouts::Basic32);
 
Effects::BasicFX->SetDirLights(Lights);
Effects::BasicFX->SetEyePosW(d3d->m_Cam.GetPosition());
 
if (mInfo.NumLights == 1)
activeTech = Effects::BasicFX->Light1TexAlphaClipTech;
else if (mInfo.NumLights == 2)
   activeTech = Effects::BasicFX->Light2TexAlphaClipTech;
else if (mInfo.NumLights == 3)
activeTech = Effects::BasicFX->Light3TexAlphaClipTech;
else if (mInfo.NumLights == 0)
activeTech = Effects::BasicFX->Light0TexAlphaClipTech;
 
 
Effects::BasicFX->SetWorld(World);
Effects::BasicFX->SetWorldInvTranspose(worldInvTranspose);
Effects::BasicFX->SetWorldViewProj(worldViewProj);
Effects::BasicFX->SetTexTransform(XMMatrixIdentity());
 
 
D3DX11_TECHNIQUE_DESC techDesc;
    activeTech->GetDesc(&techDesc);
 
pDeviceContext->RSSetState(0);
 
    for(UINT p = 0; p < techDesc.Passes; ++p)
    {
for (UINT i = 0; i < mModel.mSubsetCount; i++)
   {   
 
   Effects::BasicFX->SetMaterial(Materials[i]);
Effects::BasicFX->SetDiffuseMap(DiffuseMapSRV[i]);
 
   activeTech->GetPassByIndex(p)->Apply(0, pDeviceContext);
 
   mModel.Mesh.Draw(i);
   }
}
 
}
 
 
MeshGeometry::MeshGeometry()
{
VertexBuffer = nullptr;
IndexBuffer = nullptr;
 
IndexBufferFormat = DXGI_FORMAT_R16_UINT;
VertexStride = 0;
}
 
MeshGeometry::~MeshGeometry()
{
ReleaseCOM(VertexBuffer);
ReleaseCOM(IndexBuffer);
}
 
void MeshGeometry::SetIndices(const USHORT* indices, UINT count)
{
D3D11_BUFFER_DESC ibd;
    ibd.Usage = D3D11_USAGE_IMMUTABLE;
    ibd.ByteWidth = sizeof(USHORT) * count;
    ibd.BindFlags = D3D11_BIND_INDEX_BUFFER;
    ibd.CPUAccessFlags = 0;
    ibd.MiscFlags = 0;
ibd.StructureByteStride = 0;
 
    D3D11_SUBRESOURCE_DATA iinitData;
    iinitData.pSysMem = indices;
 
HR(pDevice->CreateBuffer(&ibd, &iinitData, &IndexBuffer));
}
 
void MeshGeometry::SetSubsetTable(std::vector<Subset>& subsetTable)
{
SubsetTable = subsetTable;
}
 
void MeshGeometry::Draw(UINT subsetId)
{
    UINT offset = 0;
 
pDeviceContext->IASetVertexBuffers(0, 1, &VertexBuffer, &VertexStride, &offset);
pDeviceContext->IASetIndexBuffer(IndexBuffer, IndexBufferFormat, 0);
 
pDeviceContext->DrawIndexed(SubsetTable[subsetId].FaceCount * 3, SubsetTable[subsetId].FaceStart * 3,  0);
}
 
 
template <typename VertexType>
void MeshGeometry::SetVertices(const VertexType* vertices, UINT count)
{
ReleaseCOM(VertexBuffer);
 
VertexStride = sizeof(VertexType);
 
D3D11_BUFFER_DESC vbd;
    vbd.Usage = D3D11_USAGE_IMMUTABLE;
vbd.ByteWidth = sizeof(VertexType) * count;
    vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
    vbd.CPUAccessFlags = 0;
    vbd.MiscFlags = 0;
vbd.StructureByteStride = 0;
 
    D3D11_SUBRESOURCE_DATA vinitData;
    vinitData.pSysMem = vertices;
 
HR(pDevice->CreateBuffer(&vbd, &vinitData, &VertexBuffer));
}



#5126519 Direct3D 11 Load 3D Models (assimp)

Posted by newtechnology on 26 January 2014 - 10:28 AM

I've read some threads here at gamedev about using assimp to extract data and then finally i made this.

currently it can only draw models with materials and lights (no texture, you'll have to implement that yourself.)

 

Model.h

#ifndef _MODEL_H_
#define _MODEL_H_
 
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
 
 
class Model
{
public:
Model();
~Model();
 
void LoadModel(const std::string& FileName);
void Render(CXMMATRIX world);
private:
struct ModelData
{ 
ModelData()
{
VertexBuffer = nullptr;
IndexBuffer = nullptr;
}
 
 
ID3D11Buffer* VertexBuffer;
ID3D11Buffer* IndexBuffer;
 
UINT mNumVertices;
UINT mNumFaces;
};
 
ModelData mModel;
};
 
 
 
#endif

Model.cpp

#include "stdafx.h"
 
DirectionalLight DirLights[3];
Material Mat;
 
Model::Model()
{
 
DirLights[0].Ambient  = XMFLOAT4(0.2f, 0.2f, 0.2f, 1.0f);
DirLights[0].Diffuse  = XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f);
DirLights[0].Specular = XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f);
DirLights[0].Direction = XMFLOAT3(0.0f, 0.0f, 0.0f);
 
Mat.Ambient  = XMFLOAT4(0.48f, 0.77f, 0.46f, 1.0f);
Mat.Diffuse  = XMFLOAT4(0.48f, 0.77f, 0.46f, 1.0f);
Mat.Specular = XMFLOAT4(0.2f, 0.2f, 0.2f, 16.0f);
}
 
Model::~Model()
{
ReleaseCOM(mModel.VertexBuffer);
ReleaseCOM(mModel.IndexBuffer);
}
 
 
void Model::LoadModel(const std::string& filename)
{
 
Assimp::Importer imp;
 
UINT NumMeshes;
UINT NumFaces;
 
const aiScene* pScene = imp.ReadFile(filename,
aiProcess_CalcTangentSpace |
aiProcess_Triangulate |
aiProcess_GenSmoothNormals |
aiProcess_SplitLargeMeshes |
aiProcess_ConvertToLeftHanded |
aiProcess_SortByPType |
aiProcess_PreTransformVertices);
 
if (pScene == NULL)
ShowError(imp.GetErrorString());
 
NumMeshes = pScene->mNumMeshes;
 
std::vector<Vertex::Basic32> vertices;
std::vector<DWORD> indices;
 
for (UINT i = 0; i < NumMeshes; i++)
{
aiMesh* mesh = pScene->mMeshes[i];
 
for (UINT j = 0; j < mesh->mNumVertices; j++)
{
Vertex::Basic32 v;
 
v.Pos.x = mesh->mVertices[j].x;
v.Pos.y = mesh->mVertices[j].y;
v.Pos.z = mesh->mVertices[j].z;
 
v.Normal.x = mesh->mNormals[j].x;
v.Normal.y = mesh->mNormals[j].y;
v.Normal.z = mesh->mNormals[j].z;
 
if (mesh->HasTextureCoords(0))
{
v.Tex.x = mesh->mTextureCoords[0][j].x;
v.Tex.y = mesh->mTextureCoords[0][j].y;
}
 
vertices.push_back(v);
}
 
for (UINT c = 0; c < mesh->mNumFaces; c++)
for (UINT e = 0; e < mesh->mFaces[c].mNumIndices; e++)
indices.push_back(mesh->mFaces[c].mIndices[e]);
 
}
 
 
mModel.mNumVertices = vertices.size();
mModel.mNumFaces = indices.size() / 3;
 
D3D11_BUFFER_DESC vbd;
vbd.Usage = D3D11_USAGE_IMMUTABLE;
vbd.ByteWidth = sizeof(Vertex::Basic32) * vertices.size();
vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vbd.CPUAccessFlags = 0;
vbd.MiscFlags = 0;
 
D3D11_SUBRESOURCE_DATA vinitData;
vinitData.pSysMem = &vertices[0];
 
HR(pDevice->CreateBuffer(&vbd, &vinitData, &mModel.VertexBuffer));
 
D3D11_BUFFER_DESC ibd;
ibd.Usage = D3D11_USAGE_IMMUTABLE;
ibd.ByteWidth = sizeof(DWORD) * indices.size();
ibd.BindFlags = D3D11_BIND_INDEX_BUFFER;
ibd.CPUAccessFlags = 0;
ibd.MiscFlags = 0;
 
D3D11_SUBRESOURCE_DATA iinitData;
iinitData.pSysMem = &indices[0];
 
HR(pDevice->CreateBuffer(&ibd, &iinitData, &mModel.IndexBuffer));
 
}
 
 
void Model::Render(CXMMATRIX world)
{
UINT Stride = sizeof(Vertex::Basic32);
UINT Offset = 0;
 
Effects::BasicFX->SetDirLights(DirLights);
Effects::BasicFX->SetEyePosW(d3d->m_Cam.GetPosition());
 
ID3DX11EffectTechnique* activeTech = Effects::BasicFX->Light3Tech;
 
    D3DX11_TECHNIQUE_DESC techDesc;
    activeTech->GetDesc(&techDesc);
 
    for(UINT p = 0; p < techDesc.Passes; ++p)
    {
pDeviceContext->IASetVertexBuffers(0, 1, &mModel.VertexBuffer, &Stride, &Offset);
pDeviceContext->IASetIndexBuffer(mModel.IndexBuffer, DXGI_FORMAT_R32_UINT, 0);
 
XMMATRIX worldInvTranspose = MathHelper::InverseTranspose(world);
XMMATRIX worldViewProj = world * d3d->m_Cam.ViewProj();
 
Effects::BasicFX->SetWorld(world);
Effects::BasicFX->SetWorldInvTranspose(worldInvTranspose);
Effects::BasicFX->SetWorldViewProj(worldViewProj);
Effects::BasicFX->SetMaterial(Mat);
 
activeTech->GetPassByIndex(p)->Apply(0, pDeviceContext);
pDeviceContext->DrawIndexed(mModel.mNumFaces * 3, 0, 0);
 
}
 
}





PARTNERS