Jump to content
  • Advertisement
Sign in to follow this  
wabbz111

[DX10] Multiple objects in a scene

This topic is 2546 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys i have been working with the tutorials on http://www.braynzarsoft.net/
and iedoc has been a big help. I had previously created a pyramid (find the topic here.)
Now i wanted to render that pyramid and a sphere into the skybox.The code compiles
and runs fine with the sphere displaying correctly but the
pyramid shows up as large flat square(rotate around to see it) that is not intergrated into the scene.

The Main file


#include <Windows.h>
#include <d3d10.h>
#include <d3dx10.h>
#include <string>
#include <vector>
#include <dinput.h>
#include <fstream>
#include <istream>
#pragma comment (lib, "dinput8.lib")
#pragma comment (lib, "dxguid.lib")
#pragma comment(lib, "D3D10.lib")
#pragma comment(lib, "d3dx10d.lib")

using namespace std;

LPCTSTR WndClassName = L"firstwindow";
HWND hwnd = NULL;

const int Width = 800;
const int Height = 600;

bool InitializeWindow(HINSTANCE hInstance,
int ShowWnd,
int width, int height,
bool windowed);

HRESULT hr;
ID3D10Device* d3dDevice;
IDXGISwapChain* SwapChain;
ID3D10RenderTargetView* RenderTargetView;
ID3D10Effect* FX;
ID3D10InputLayout* VertexLayout;
ID3D10Buffer* VertexBuffer;
ID3D10Buffer* IndexBuffer;
ID3D10EffectTechnique* Technique;
ID3D10DepthStencilView* DepthStencilView;
ID3D10Texture2D* DepthStencilBuffer;

ID3D10EffectShaderResourceVariable* fxDiffuseMapVar;
ID3D10EffectMatrixVariable* fxWVPVar;
D3DXMATRIX WVP;
D3DXMATRIX World;
D3DXMATRIX View;
D3DXMATRIX Projection;
ID3D10EffectVariable* fxLightVar;
IDirectInputDevice8* DIKeyboard;
IDirectInputDevice8* DIMouse;
DIMOUSESTATE mouseLastState;
LPDIRECTINPUT8 DirectInput;
vector<ID3DX10Mesh*> meshes;
int meshCount;
bool LoadMesh(wstring filename);
int meshTextures = 0;
vector<ID3D10ShaderResourceView*> TextureResourceViews;
vector<UINT> meshSubsets;

DWORD NumVertices;
DWORD NumFaces;

/////////////////////////new/////////////////////////////////////////////////
ID3D10EffectShaderResourceVariable* fxSkyMapVar;
ID3D10ShaderResourceView* smrv = 0;
ID3D10EffectTechnique* SkyMapTechnique;
void CreateSphere(int LatLines, int LongLines);
/////////////////////////new/////////////////////////////////////////////////

float moveLeftRight = 0.0f;
float moveBackForward = 0.0f;

D3DXVECTOR3 Position = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
D3DXVECTOR3 Target = D3DXVECTOR3( 0.0f, 0.0f, 1.0f);
D3DXVECTOR3 Up = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
D3DXVECTOR3 DefaultForward = D3DXVECTOR3(0.0f,0.0f,1.0f);
D3DXVECTOR3 DefaultRight = D3DXVECTOR3(1.0f,0.0f,0.0f);
D3DXVECTOR3 Forward = D3DXVECTOR3(0.0f,0.0f,1.0f);
D3DXVECTOR3 Right = D3DXVECTOR3(1.0f,0.0f,0.0f);

D3DXMATRIX rotationMatrix;

float yaw = 0.0f;
float pitch = 0.0f;

void UpdateCamera();

D3DXMATRIX Scale;
D3DXMATRIX Translation;
D3DXMATRIX Transformations;

bool InitializeDirect3dApp(HINSTANCE hInstance);
bool InitDirectInput(HINSTANCE hInstance);
void DetectInput();
bool InitScene();
void DrawScene();
bool ReleaseObjects();
int messageloop();

LRESULT CALLBACK WndProc(HWND hWnd,
UINT msg,
WPARAM wParam,
LPARAM lParam);

struct Vertex
{
Vertex(){}
Vertex(float x, float y, float z,
float u, float v, float nx, float ny, float nz)
: pos(x,y,z), texCoord(u,v), normal(nx,ny,nz){}

D3DXVECTOR3 pos;
D3DXVECTOR2 texCoord;
D3DXVECTOR3 normal;
};

D3D10_INPUT_ELEMENT_DESC layout[] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 20, D3D10_INPUT_PER_VERTEX_DATA, 0}
};

struct Light
{
Light()
{
ZeroMemory(this, sizeof(Light));
}
D3DXVECTOR3 dir;
float pad;
D3DXCOLOR ambient;
D3DXCOLOR diffuse;
};

Light light;


int WINAPI WinMain(HINSTANCE hInstance, //Main windows function
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
TextureResourceViews.clear();

if(!InitializeWindow(hInstance, nShowCmd, Width, Height, true))
{
MessageBox(0, L"Window Initialization - Failed",
L"Error", MB_OK);
return 0;
}

if(!InitializeDirect3dApp(hInstance))
{
MessageBox(0, L"Direct3D Initialization - Failed",
L"Error", MB_OK);
return 0;
}

if(!InitDirectInput(hInstance))
{
MessageBox(0, L"Direct Input Initialization - Failed",
L"Error", MB_OK);
return 0;
}

if(!InitScene())
{
MessageBox(0, L"Scene Initialization - Failed",
L"Error", MB_OK);
return 0;
}

messageloop();

if(!ReleaseObjects())
{
MessageBox(0, L"Object Releasing - Failed",
L"Error", MB_OK);
return 0;
}

return 0;
}

bool InitializeWindow(HINSTANCE hInstance,
int ShowWnd,
int width, int height,
bool windowed)
{
typedef struct _WNDCLASS {
UINT cbSize;
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HANDLE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCTSTR lpszMenuName;
LPCTSTR lpszClassName;
} WNDCLASS;

WNDCLASSEX wc;

wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = NULL;
wc.cbWndExtra = NULL;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 2);
wc.lpszMenuName = NULL;
wc.lpszClassName = WndClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

if (!RegisterClassEx(&wc))
{
MessageBox(NULL, L"Error registering class",
L"Error", MB_OK | MB_ICONERROR);
return 1;
}

hwnd = CreateWindowEx(
NULL,
WndClassName,
L"Window Title",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
width, height,
NULL,
NULL,
hInstance,
NULL
);

if (!hwnd)
{
MessageBox(NULL, L"Error creating window",
L"Error", MB_OK | MB_ICONERROR);
return 1;
}

ShowWindow(hwnd, ShowWnd);
UpdateWindow(hwnd);


return true;
}

bool InitializeDirect3dApp(HINSTANCE hInstance)
{
UINT createDeviceFlags = 0;

D3D10_DRIVER_TYPE driverTypes[] =
{
D3D10_DRIVER_TYPE_HARDWARE,
D3D10_DRIVER_TYPE_REFERENCE,
};
UINT numDriverTypes = sizeof( driverTypes ) / sizeof( driverTypes[0] );

DXGI_SWAP_CHAIN_DESC scd;
scd.BufferDesc.Width = Width;
scd.BufferDesc.Height = Height;
scd.BufferDesc.RefreshRate.Numerator = 60;
scd.BufferDesc.RefreshRate.Denominator = 1;
scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
scd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
scd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;

//no multisampling
scd.SampleDesc.Count = 1;
scd.SampleDesc.Quality = 0;

scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scd.BufferCount = 1;
scd.OutputWindow = hwnd;
scd.Windowed = true;
scd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
scd.Flags = 0;

D3D10CreateDeviceAndSwapChain(0, D3D10_DRIVER_TYPE_HARDWARE, 0, 0, D3D10_SDK_VERSION, &scd, &SwapChain, &d3dDevice);

ID3D10Texture2D* backBuffer;
SwapChain->GetBuffer(0, _uuidof(ID3D10Texture2D), reinterpret_cast<void**>(&backBuffer));
d3dDevice->CreateRenderTargetView(backBuffer, 0, &RenderTargetView);
backBuffer->Release();

D3D10_TEXTURE2D_DESC depthStencilDesc;

depthStencilDesc.Width = Width;
depthStencilDesc.Height = Height;
depthStencilDesc.MipLevels = 1;
depthStencilDesc.ArraySize = 1;
depthStencilDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthStencilDesc.SampleDesc.Count = 1;
depthStencilDesc.SampleDesc.Quality = 0;
depthStencilDesc.Usage = D3D10_USAGE_DEFAULT;
depthStencilDesc.BindFlags = D3D10_BIND_DEPTH_STENCIL;
depthStencilDesc.CPUAccessFlags = 0;
depthStencilDesc.MiscFlags = 0;

d3dDevice->CreateTexture2D(&depthStencilDesc, NULL, &DepthStencilBuffer);
d3dDevice->CreateDepthStencilView(DepthStencilBuffer, NULL, &DepthStencilView);

d3dDevice->OMSetRenderTargets(1, &RenderTargetView, DepthStencilView);

// Setup the viewport
D3D10_VIEWPORT vp;
vp.Width = Width;
vp.Height = Height;
vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f;
vp.TopLeftX = 0;
vp.TopLeftY = 0;
d3dDevice->RSSetViewports( 1, &vp );

D3DXMatrixIdentity( &World );

Position = D3DXVECTOR3( 0.0f, 4.0f, -10.0f );
Target = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
Up = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
D3DXMatrixLookAtLH( &View, &Position, &Target, &Up );

return true;
}

bool InitDirectInput(HINSTANCE hInstance)
{
DirectInput8Create(hInstance,
DIRECTINPUT_VERSION,
IID_IDirectInput8,
(void**)&DirectInput,
NULL);

DirectInput->CreateDevice(GUID_SysKeyboard,
&DIKeyboard,
NULL);

DirectInput->CreateDevice(GUID_SysMouse,
&DIMouse,
NULL);

DIKeyboard->SetDataFormat(&c_dfDIKeyboard);
DIKeyboard->SetCooperativeLevel(hwnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);

DIMouse->SetDataFormat(&c_dfDIMouse);
DIMouse->SetCooperativeLevel(hwnd, DISCL_EXCLUSIVE | DISCL_NOWINKEY | DISCL_FOREGROUND);

return true;
}

void UpdateCamera()
{
D3DXMatrixRotationYawPitchRoll( &rotationMatrix, yaw, pitch, 0 );
D3DXVec3TransformCoord( &Target, &DefaultForward, &rotationMatrix );
D3DXVec3Normalize( &Target, &Target );

D3DXMATRIX RotateYTempMatrix;
D3DXMatrixRotationY(&RotateYTempMatrix, yaw);

D3DXVec3TransformNormal(&Right, &DefaultRight, &RotateYTempMatrix);
D3DXVec3TransformNormal(&Up, &Up, &RotateYTempMatrix);
D3DXVec3TransformNormal(&Forward, &DefaultForward, &RotateYTempMatrix);

Position += moveLeftRight*Right;
Position += moveBackForward*Forward;

moveLeftRight = 0.0f;
moveBackForward = 0.0f;

Target = Position + Target;

D3DXMatrixLookAtLH( &View, &Position, &Target, &Up );
}


void DetectInput()
{
float speed = 0.005f;

DIMOUSESTATE mouseCurrState;

BYTE keyboardState[256];

DIKeyboard->Acquire();
DIMouse->Acquire();

DIMouse->GetDeviceState(sizeof(DIMOUSESTATE), &mouseCurrState);

DIKeyboard->GetDeviceState(sizeof(keyboardState),(LPVOID)&keyboardState);

if(keyboardState[DIK_ESCAPE] & 0x80)
PostMessage(hwnd, WM_DESTROY, 0, 0);

if(keyboardState[DIK_A] & 0x80)
{
moveLeftRight -= speed;
}
if(keyboardState[DIK_D] & 0x80)
{
moveLeftRight += speed;
}
if(keyboardState[DIK_W] & 0x80)
{
moveBackForward += speed;
}
if(keyboardState[DIK_S] & 0x80)
{
moveBackForward -= speed;
}
if((mouseCurrState.lX != mouseLastState.lX) || (mouseCurrState.lY != mouseLastState.lY))
{
yaw += mouseLastState.lX * 0.001f;

pitch += mouseCurrState.lY * 0.001f;

mouseLastState = mouseCurrState;
}

UpdateCamera();

return;
}


bool LoadMesh(wstring filename)
{
HRESULT hr = 0;

ID3DX10Mesh* tempMesh;

UINT tempMeshSubsets;

wifstream fileIn (filename.c_str());
wstring skipString;

UINT meshVertices = 0;
UINT meshTriangles = 0;

if (fileIn)
{
fileIn >> skipString; // #Subsets
fileIn >> tempMeshSubsets;
fileIn >> skipString; // #Vertices
fileIn >> meshVertices;
fileIn >> skipString; // #Faces (Triangles)
fileIn >> meshTriangles;

meshSubsets.push_back(tempMeshSubsets);

hr = D3DX10CreateMesh(d3dDevice,
layout,
3,
layout[0].SemanticName,
meshVertices,
meshTriangles,
D3DX10_MESH_32_BIT,
&tempMesh);

if(FAILED(hr))
{
MessageBox(0, L"Mesh Creation - Failed",
L"Error", MB_OK);
return false;
}

fileIn >> skipString; //#Subset_info
for(UINT i = 0; i < tempMeshSubsets; ++i)
{
std::wstring diffuseMapFilename;

fileIn >> diffuseMapFilename;

ID3D10ShaderResourceView* DiffuseMapResourceView;

D3DX10CreateShaderResourceViewFromFile(d3dDevice,
diffuseMapFilename.c_str(), 0, 0, &DiffuseMapResourceView, 0 );

TextureResourceViews.push_back(DiffuseMapResourceView);

meshTextures++;
}

Vertex* verts = new Vertex[meshVertices];
fileIn >> skipString; //#Vertex_info
for(UINT i = 0; i < meshVertices; ++i)
{
fileIn >> skipString; //Vertex Position
fileIn >> verts.pos.x;
fileIn >> verts.pos.y;
fileIn >> verts.pos.z;

fileIn >> skipString; //Vertex Normal
fileIn >> verts.normal.x;
fileIn >> verts.normal.y;
fileIn >> verts.normal.z;

fileIn >> skipString; //Vertex Texture Coordinates
fileIn >> verts.texCoord.x;
fileIn >> verts.texCoord.y;
}
tempMesh->SetVertexData(0, verts);

delete[] verts;

DWORD* indices = new DWORD[meshTriangles*3];
UINT* attributeIndex = new UINT[meshTriangles];
fileIn >> skipString; //#Face_Index
for(UINT i = 0; i < meshTriangles; ++i)
{
fileIn >> indices[i*3+0];
fileIn >> indices[i*3+1];
fileIn >> indices[i*3+2];
fileIn >> attributeIndex; //Current Subset
}
tempMesh->SetIndexData(indices, meshTriangles*3);
tempMesh->SetAttributeData(attributeIndex);

delete[] indices;
delete[] attributeIndex;

tempMesh->GenerateAdjacencyAndPointReps(0.001f);
tempMesh->Optimize(D3DX10_MESHOPT_ATTR_SORT|D3DX10_MESHOPT_VERTEX_CACHE,0,0);
tempMesh->CommitToDevice();

meshCount++;
meshes.push_back(tempMesh);
}
else
{
MessageBox(0, L"Load Mesh File - Failed",
L"Error", MB_OK);
return false;
}

return true;
}

/////////////////////////new/////////////////////////////////////////////////

void CreateSphere(int LatLines, int LongLines)
{
NumVertices = LatLines * LongLines;
NumFaces = (LatLines-1)*(LongLines-1)*2;

float sphereYaw = 0.0f;
float spherePitch = 0.0f;

std::vector<Vertex> vertices(NumVertices);

D3DXVECTOR3 currVertPos = D3DXVECTOR3(0.0f, 1.0f, 0.0f);

for(DWORD i = 0; i < LatLines; ++i)
{
sphereYaw = i * (3.14/LatLines);
for(DWORD j = 0; j < LongLines; ++j)
{
spherePitch = j * (3.14/LongLines);
D3DXMatrixRotationYawPitchRoll( &rotationMatrix, sphereYaw, spherePitch, 0 );
D3DXVec3TransformCoord( &currVertPos, &DefaultForward, &rotationMatrix );
D3DXVec3Normalize( &currVertPos, &currVertPos );
vertices[i*LongLines+j].pos = currVertPos;
}
}

D3D10_BUFFER_DESC bd;
bd.Usage = D3D10_USAGE_IMMUTABLE;
bd.ByteWidth = sizeof( Vertex ) * NumVertices;
bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
bd.MiscFlags = 0;
D3D10_SUBRESOURCE_DATA InitData;
InitData.pSysMem = &vertices[0];
d3dDevice->CreateBuffer( &bd, &InitData, &VertexBuffer );

std::vector<DWORD> indices(NumFaces * 3);

int k = 0;
for(DWORD i = 0; i < LatLines-1; ++i)
{
for(DWORD j = 0; j < LongLines-1; ++j)
{
indices[k] = i*LongLines+j;
indices[k+1] = i*LongLines+j+1;
indices[k+2] = (i+1)*LongLines+j;

indices[k+3] = (i+1)*LongLines+j;
indices[k+4] = i*LongLines+j+1;
indices[k+5] = (i+1)*LongLines+j+1;

k += 6; // next quad
}
}

D3D10_BUFFER_DESC ibd;
ibd.Usage = D3D10_USAGE_IMMUTABLE;
ibd.ByteWidth = sizeof(DWORD) * NumFaces * 3;
ibd.BindFlags = D3D10_BIND_INDEX_BUFFER;
ibd.CPUAccessFlags = 0;
ibd.MiscFlags = 0;
D3D10_SUBRESOURCE_DATA iinitData;
iinitData.pSysMem = &indices[0];
d3dDevice->CreateBuffer(&ibd, &iinitData, &IndexBuffer);

UINT stride = sizeof( Vertex );
UINT offset = 0;
d3dDevice->IASetVertexBuffers( 0, 1, &VertexBuffer, &stride, &offset );
d3dDevice->IASetIndexBuffer(IndexBuffer, DXGI_FORMAT_R32_UINT, 0);

}
/////////////////////////new/////////////////////////////////////////////////

bool InitScene()
{
HRESULT hr = 0;
ID3D10Blob* compilationErrors = 0;

/////////////////////////new/////////////////////////////////////////////////
LoadMesh(L"plane.dat"); //meshes[1]

LoadMesh(L"3DSphere.dat"); //meshes[0]

CreateSphere(10, 10);

///////////////////////
Vertex v[5];

v[0] = Vertex( 0.0f, 2.5f, 0.0f, 0.0f, 0.5f, 0.5f, 0.0f, 0.0f);
v[1] = Vertex( 2.5f, -2.5f, 2.5f, 0.0f, 0.5f, 0.5f, 0.0f, 0.0f);
v[2] = Vertex( -2.5f, -2.5f, 2.5f, 0.0f, 0.5f, 0.5f, 0.0f, 0.0f);
v[3] = Vertex( 2.5f, -2.5f,-2.5f, 0.0f, 0.5f, 0.5f, 0.0f, 0.0f);
v[4] = Vertex( -2.5f, -2.5f,-2.5f, 0.0f, 0.5f, 0.5f, 0.0f, 0.0f);

D3D10_BUFFER_DESC vbd;
vbd.Usage = D3D10_USAGE_IMMUTABLE;
vbd.ByteWidth = sizeof(Vertex) * 5;
vbd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
vbd.CPUAccessFlags = 0;
vbd.MiscFlags = 0;
D3D10_SUBRESOURCE_DATA vinitData;
vinitData.pSysMem = v;
d3dDevice->CreateBuffer(&vbd, &vinitData, &VertexBuffer);


DWORD i[18];

// Front Face
i[0] = 0; i[1] = 2; i[2] = 1;

//Back
i[3] = 0; i[4] = 3; i[5] = 4;

// Left Face
i[6] = 0; i[7] = 1; i[8] = 3;

//Right
i[9] = 0; i[10] = 4; i[11] = 2;

// Bottom Face
i[12] = 4; i[13] = 1; i[14] = 2;
i[15] = 3; i[16] = 1; i[17] = 4;


////////////////////////////

D3DX10_IMAGE_LOAD_INFO loadSMInfo;
loadSMInfo.MiscFlags = D3D10_RESOURCE_MISC_TEXTURECUBE;

ID3D10Texture2D* SMTexture = 0;
hr = D3DX10CreateTextureFromFile(d3dDevice, L"skymap.dds",
&loadSMInfo, 0, (ID3D10Resource**)&SMTexture, 0);

if(FAILED(hr))
{
MessageBox(0, L"Load cube texture - Failed",
L"Error", MB_OK);
return false;
}

D3D10_TEXTURE2D_DESC SMTextureDesc;
SMTexture->GetDesc(&SMTextureDesc);

D3D10_SHADER_RESOURCE_VIEW_DESC SMViewDesc;
SMViewDesc.Format = SMTextureDesc.Format;
SMViewDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURECUBE;
SMViewDesc.TextureCube.MipLevels = SMTextureDesc.MipLevels;
SMViewDesc.TextureCube.MostDetailedMip = 0;

hr = d3dDevice->CreateShaderResourceView(SMTexture, &SMViewDesc, &smrv);

if(FAILED(hr))
{
MessageBox(0, L"Create Cube Texture RV - Failed",
L"Error", MB_OK);
return false;
}
SMTexture->Release();
/////////////////////////new/////////////////////////////////////////////////

light.dir = D3DXVECTOR3(0.25f, 0.5f, -1.0f);
light.ambient = D3DXCOLOR(0.2f, 0.2f, 0.2f, 1.0f);
light.diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);



hr = D3DX10CreateEffectFromFile( L"vertex.fx", NULL, NULL, "fx_4_0", D3D10_SHADER_ENABLE_STRICTNESS, 0,
d3dDevice, NULL, NULL, &FX, &compilationErrors, NULL );
if(FAILED(hr))
{
MessageBoxA(0, (char*)compilationErrors->GetBufferPointer(), 0, 0);
compilationErrors->Release();
return false;
}

Technique = FX->GetTechniqueByName( "Tech" );

/////////////////////////new/////////////////////////////////////////////////
SkyMapTechnique = FX->GetTechniqueByName("SkyMapTech");
/////////////////////////new/////////////////////////////////////////////////

fxWVPVar = FX->GetVariableByName("WVP")->AsMatrix();
fxDiffuseMapVar = FX->GetVariableByName("DiffuseMap")->AsShaderResource();
fxLightVar = FX->GetVariableByName("light");
fxSkyMapVar = FX->GetVariableByName("SkyMap")->AsShaderResource();

D3D10_PASS_DESC PassDesc;
Technique->GetPassByIndex( 0 )->GetDesc( &PassDesc );
d3dDevice->CreateInputLayout( layout, 3, PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &VertexLayout );

d3dDevice->IASetInputLayout( VertexLayout );

d3dDevice->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST );

return true;
}

bool ReleaseObjects()
{
if( d3dDevice ) d3dDevice->ClearState();

if( VertexBuffer ) VertexBuffer->Release();
if( IndexBuffer ) IndexBuffer->Release();
if( VertexLayout ) VertexLayout->Release();
if( FX ) FX->Release();
if( RenderTargetView ) RenderTargetView->Release();
if( SwapChain ) SwapChain->Release();
if( d3dDevice ) d3dDevice->Release();

DIKeyboard->Unacquire();
DIMouse->Unacquire();
if( DirectInput ) DirectInput->Release();

for(int i = 0; i < meshCount; i++)
if( meshes ) meshes->Release();

return true;
}

void DrawScene()
{
//Draw Scene Here
D3DXCOLOR bgColor( 0.0f, 0.0f, 0.0f, 1.0f);
d3dDevice->ClearRenderTargetView( RenderTargetView, bgColor );
d3dDevice->ClearDepthStencilView(DepthStencilView, D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, 1.0f, 0);

D3DXMatrixPerspectiveFovLH(&Projection, 0.4f*3.14f, Width/Height, 1.0f, 1000.0f);

fxLightVar->SetRawValue(&light, 0, sizeof(Light));
/////////////////////////new/////////////////////////////////////////////////
D3D10_TECHNIQUE_DESC skymaptechDesc;
SkyMapTechnique->GetDesc( &skymaptechDesc );
/////////////////////////new/////////////////////////////////////////////////

D3D10_TECHNIQUE_DESC techDesc;
Technique->GetDesc( &techDesc );

D3DXMatrixScaling( &Scale, 1.0f, 1.0f, 1.0f );
D3DXMatrixTranslation( &Translation, 0.0f, -3.0f, 0.0f );

Transformations = Scale * Translation;

WVP = World * Transformations * View * Projection;
fxWVPVar->SetMatrix((float*)&WVP);

/*draw plane
for( UINT p = 0; p < techDesc.Passes; ++p )
{
for(UINT subsetID = 0; subsetID < meshSubsets[0]; ++subsetID)
{
fxDiffuseMapVar->SetResource(TextureResourceViews[subsetID]);
Technique->GetPassByIndex( p )->Apply( 0 );
meshes[0]->DrawSubset(subsetID);
}
}*/

D3DXMatrixScaling( &Scale, 2.0f, 2.0f, 2.0f );
D3DXMatrixTranslation( &Translation, 0.0f, 1.0f, 5.0f );

Transformations = Scale * Translation;

WVP = World * Transformations * View * Projection;
fxWVPVar->SetMatrix((float*)&WVP);

//draw sphere
for( UINT p = 0; p < techDesc.Passes; ++p )
{
for(UINT subsetID = 0; subsetID < meshSubsets[1]; ++subsetID)
{
fxDiffuseMapVar->SetResource(TextureResourceViews[subsetID + meshSubsets[0]]);
Technique->GetPassByIndex( p )->Apply( 0 );
meshes[1]->DrawSubset(subsetID);
}
}

D3DXMatrixScaling( &Scale, 100.0f, 100.0f,100.0f );
D3DXMatrixTranslation( &Translation, Position.x, Position.y, Position.z );

Transformations = Scale * Translation;

WVP = World * Transformations * View * Projection;
fxWVPVar->SetMatrix((float*)&WVP);

/////////////////////////new/////////////////////////////////////////////////
//draw skymap based off loaded mesh sphere
fxSkyMapVar->SetResource(smrv);
for( UINT p = 0; p < skymaptechDesc.Passes; ++p )
{
SkyMapTechnique->GetPassByIndex( p )->Apply( 0 );
d3dDevice->DrawIndexed(NumFaces * 3, 0, 0);
}
/////////////////////////new/////////////////////////////////////////////////

/////////////////pyramid



//draw pyramid
for( UINT p = 0; p < techDesc.Passes; ++p )
{
Technique->GetPassByIndex( p )->Apply( 0 );
d3dDevice->DrawIndexed(18, 0, 0);
}

WVP = World * Transformations * View * Projection;
fxWVPVar->SetMatrix((float*)&WVP);

/////////////pyramid

SwapChain->Present( 0, 0 );
}

int messageloop(){
MSG msg;
ZeroMemory(&msg, sizeof(MSG));
while(true)
{
BOOL PeekMessageL(
LPMSG lpMsg,
HWND hWnd,
UINT wMsgFilterMin,
UINT wMsgFilterMax,
UINT wRemoveMsg
);

if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else{
// run game code
DetectInput();
DrawScene();
}
}
return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd,
UINT msg,
WPARAM wParam,
LPARAM lParam)
{
switch( msg )
{
case WM_DESTROY:

PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,
msg,
wParam,
lParam);
}



The vertex file


//"vertex.fx" file


struct Light
{
float3 dir;
float4 ambient;
float4 diffuse;
};

cbuffer cbPerFrame
{
Light light;
};

cbuffer cbPerObject
{
float4x4 WVP;
};

Texture2D DiffuseMap;
TextureCube SkyMap;

SamplerState TriLinearSample
{
Filter = MIN_MAG_MIP_LINEAR;
};

struct VS_OUTPUT //output structure for vertex shader
{
float4 Pos : SV_POSITION;
float2 texCoord : TEXCOORD;
float3 normal : NORMAL;
};

struct SKYMAP_VS_OUTPUT //output structure for skymap vertex shader
{
float4 Pos : SV_POSITION;
float3 texCoord : TEXCOORD;
};

// Vertex Shader
VS_OUTPUT VS(float3 inPos : POSITION, float2 inTexCoord : TEXCOORD, float3 normal : NORMAL)
{
VS_OUTPUT output = (VS_OUTPUT)0;

output.Pos = mul(float4(inPos, 1.0f), WVP);

output.normal = mul(normal, WVP);

output.texCoord = inTexCoord;

return output; //send color and position to pixel shader
}

SKYMAP_VS_OUTPUT SKYMAP_VS(float3 inPos : POSITION, float2 inTexCoord : TEXCOORD, float3 normal : NORMAL)
{
SKYMAP_VS_OUTPUT output = (SKYMAP_VS_OUTPUT)0;

output.Pos = mul(float4(inPos, 1.0f), WVP).xyww;

output.texCoord = inPos;

return output; //send color and position to pixel shader
}

// Pixel Shader
float4 PS(VS_OUTPUT input) : SV_Target
{
input.normal = normalize(input.normal);

float4 diffuse = DiffuseMap.Sample( TriLinearSample, input.texCoord );

float3 finalColor;

finalColor = diffuse * light.ambient;
finalColor += saturate(dot(light.dir, input.normal) * light.diffuse * diffuse);

return float4(finalColor, diffuse.a);
}

float4 SKYMAP_PS(SKYMAP_VS_OUTPUT input) : SV_Target
{
return SkyMap.Sample(TriLinearSample, input.texCoord);
}

RasterizerState NoCulling
{
CullMode = None;
};

DepthStencilState LessEqualDSS
{
DepthFunc = LESS_EQUAL;
};

technique10 Tech
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetPixelShader( CompileShader( ps_4_0, PS() ) );
}
}

technique10 SkyMapTech
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, SKYMAP_VS() ) );
SetPixelShader( CompileShader( ps_4_0, SKYMAP_PS() ) );

SetRasterizerState(NoCulling);
SetDepthStencilState(LessEqualDSS, 0);
}
}



The sphere is being loaded as data file
shere.dat



#Subsets 2
#Vertices 360
#Faces 120

#Subset_info
PurpleGalaxy.jpg
PurpleGalaxy.jpg

#Vertex_info
Pos: -0.250000 0.433013 -0.866025
Norm: -0.250000 0.433013 -0.866025
tc: 0.083333 0.833333

Pos: 0.000000 0.500000 -0.866025
Norm: 0.000000 0.500000 -0.866025
tc: 0.000000 0.833333

Pos: 0.000000 0.000000 -1.000000
Norm: 0.000000 0.000000 -1.000000
tc: 0.000000 1.000000

Pos: -0.433013 0.250000 -0.866025
Norm: -0.433013 0.250000 -0.866025
tc: 0.166667 0.833333

Pos: -0.250000 0.433013 -0.866025
Norm: -0.250000 0.433013 -0.866025
tc: 0.083333 0.833333

Pos: 0.000000 0.000000 -1.000000
Norm: 0.000000 0.000000 -1.000000
tc: 0.083333 1.000000

Pos: -0.500000 0.000000 -0.866025
Norm: -0.500000 0.000000 -0.866025
tc: 0.250000 0.833333

Pos: -0.433013 0.250000 -0.866025
Norm: -0.433013 0.250000 -0.866025
tc: 0.166667 0.833333

Pos: 0.000000 0.000000 -1.000000
Norm: 0.000000 0.000000 -1.000000
tc: 0.166667 1.000000

Pos: -0.433013 -0.250000 -0.866025
Norm: -0.433013 -0.250000 -0.866025
tc: 0.333333 0.833333

Pos: -0.500000 0.000000 -0.866025
Norm: -0.500000 0.000000 -0.866025
tc: 0.250000 0.833333

Pos: 0.000000 0.000000 -1.000000
Norm: 0.000000 0.000000 -1.000000
tc: 0.250000 1.000000

Pos: -0.250000 -0.433013 -0.866025
Norm: -0.250000 -0.433013 -0.866025
tc: 0.416667 0.833333

Pos: -0.433013 -0.250000 -0.866025
Norm: -0.433013 -0.250000 -0.866025
tc: 0.333333 0.833333

Pos: 0.000000 0.000000 -1.000000
Norm: 0.000000 0.000000 -1.000000
tc: 0.333333 1.000000

Pos: -0.000000 -0.500000 -0.866025
Norm: -0.000000 -0.500000 -0.866025
tc: 0.500000 0.833333

Pos: -0.250000 -0.433013 -0.866025
Norm: -0.250000 -0.433013 -0.866025
tc: 0.416667 0.833333

Pos: 0.000000 0.000000 -1.000000
Norm: 0.000000 0.000000 -1.000000
tc: 0.416667 1.000000

Pos: 0.250000 -0.433013 -0.866025
Norm: 0.250000 -0.433013 -0.866025
tc: 0.583333 0.833333

Pos: -0.000000 -0.500000 -0.866025
Norm: -0.000000 -0.500000 -0.866025
tc: 0.500000 0.833333

Pos: 0.000000 0.000000 -1.000000
Norm: 0.000000 0.000000 -1.000000
tc: 0.500000 1.000000

Pos: 0.433013 -0.250000 -0.866025
Norm: 0.433013 -0.250000 -0.866025
tc: 0.666667 0.833333

Pos: 0.250000 -0.433013 -0.866025
Norm: 0.250000 -0.433013 -0.866025
tc: 0.583333 0.833333

Pos: 0.000000 0.000000 -1.000000
Norm: 0.000000 0.000000 -1.000000
tc: 0.583333 1.000000

Pos: 0.500000 -0.000000 -0.866025
Norm: 0.500000 -0.000000 -0.866025
tc: 0.750000 0.833333

Pos: 0.433013 -0.250000 -0.866025
Norm: 0.433013 -0.250000 -0.866025
tc: 0.666667 0.833333

Pos: 0.000000 0.000000 -1.000000
Norm: 0.000000 0.000000 -1.000000
tc: 0.666667 1.000000

Pos: 0.433013 0.250000 -0.866025
Norm: 0.433013 0.250000 -0.866025
tc: 0.833333 0.833333

Pos: 0.500000 -0.000000 -0.866025
Norm: 0.500000 -0.000000 -0.866025
tc: 0.750000 0.833333

Pos: 0.000000 0.000000 -1.000000
Norm: 0.000000 0.000000 -1.000000
tc: 0.750000 1.000000

Pos: 0.250000 0.433012 -0.866025
Norm: 0.250000 0.433012 -0.866025
tc: 0.916667 0.833333

Pos: 0.433013 0.250000 -0.866025
Norm: 0.433013 0.250000 -0.866025
tc: 0.833333 0.833333

Pos: 0.000000 0.000000 -1.000000
Norm: 0.000000 0.000000 -1.000000
tc: 0.833333 1.000000

Pos: 0.000000 0.500000 -0.866025
Norm: 0.000000 0.500000 -0.866025
tc: 1.000000 0.833333

Pos: 0.250000 0.433012 -0.866025
Norm: 0.250000 0.433012 -0.866025
tc: 0.916667 0.833333

Pos: 0.000000 0.000000 -1.000000
Norm: 0.000000 0.000000 -1.000000
tc: 0.916667 1.000000

Pos: -0.433013 0.750000 -0.500000
Norm: -0.433013 0.750000 -0.500000
tc: 0.083333 0.666667

Pos: 0.000000 0.866025 -0.500000
Norm: 0.000000 0.866025 -0.500000
tc: 0.000000 0.666667

Pos: 0.000000 0.500000 -0.866025
Norm: 0.000000 0.500000 -0.866025
tc: 0.000000 0.833333

Pos: -0.250000 0.433013 -0.866025
Norm: -0.250000 0.433013 -0.866025
tc: 0.083333 0.833333

Pos: -0.433013 0.750000 -0.500000
Norm: -0.433013 0.750000 -0.500000
tc: 0.083333 0.666667

Pos: 0.000000 0.500000 -0.866025
Norm: 0.000000 0.500000 -0.866025
tc: 0.000000 0.833333

Pos: -0.750000 0.433013 -0.500000
Norm: -0.750000 0.433013 -0.500000
tc: 0.166667 0.666667

Pos: -0.433013 0.750000 -0.500000
Norm: -0.433013 0.750000 -0.500000
tc: 0.083333 0.666667

Pos: -0.250000 0.433013 -0.866025
Norm: -0.250000 0.433013 -0.866025
tc: 0.083333 0.833333

Pos: -0.433013 0.250000 -0.866025
Norm: -0.433013 0.250000 -0.866025
tc: 0.166667 0.833333

Pos: -0.750000 0.433013 -0.500000
Norm: -0.750000 0.433013 -0.500000
tc: 0.166667 0.666667

Pos: -0.250000 0.433013 -0.866025
Norm: -0.250000 0.433013 -0.866025
tc: 0.083333 0.833333

Pos: -0.866025 0.000000 -0.500000
Norm: -0.866025 0.000000 -0.500000
tc: 0.250000 0.666667

Pos: -0.750000 0.433013 -0.500000
Norm: -0.750000 0.433013 -0.500000
tc: 0.166667 0.666667

Pos: -0.433013 0.250000 -0.866025
Norm: -0.433013 0.250000 -0.866025
tc: 0.166667 0.833333

Pos: -0.500000 0.000000 -0.866025
Norm: -0.500000 0.000000 -0.866025
tc: 0.250000 0.833333

Pos: -0.866025 0.000000 -0.500000
Norm: -0.866025 0.000000 -0.500000
tc: 0.250000 0.666667

Pos: -0.433013 0.250000 -0.866025
Norm: -0.433013 0.250000 -0.866025
tc: 0.166667 0.833333

Pos: -0.750000 -0.433013 -0.500000
Norm: -0.750000 -0.433013 -0.500000
tc: 0.333333 0.666667

Pos: -0.866025 0.000000 -0.500000
Norm: -0.866025 0.000000 -0.500000
tc: 0.250000 0.666667

Pos: -0.500000 0.000000 -0.866025
Norm: -0.500000 0.000000 -0.866025
tc: 0.250000 0.833333

Pos: -0.433013 -0.250000 -0.866025
Norm: -0.433013 -0.250000 -0.866025
tc: 0.333333 0.833333

Pos: -0.750000 -0.433013 -0.500000
Norm: -0.750000 -0.433013 -0.500000
tc: 0.333333 0.666667

Pos: -0.500000 0.000000 -0.866025
Norm: -0.500000 0.000000 -0.866025
tc: 0.250000 0.833333

Pos: -0.433013 -0.750000 -0.500000
Norm: -0.433013 -0.750000 -0.500000
tc: 0.416667 0.666667

Pos: -0.750000 -0.433013 -0.500000
Norm: -0.750000 -0.433013 -0.500000
tc: 0.333333 0.666667

Pos: -0.433013 -0.250000 -0.866025
Norm: -0.433013 -0.250000 -0.866025
tc: 0.333333 0.833333

Pos: -0.250000 -0.433013 -0.866025
Norm: -0.250000 -0.433013 -0.866025
tc: 0.416667 0.833333

Pos: -0.433013 -0.750000 -0.500000
Norm: -0.433013 -0.750000 -0.500000
tc: 0.416667 0.666667

Pos: -0.433013 -0.250000 -0.866025
Norm: -0.433013 -0.250000 -0.866025
tc: 0.333333 0.833333

Pos: -0.000000 -0.866025 -0.500000
Norm: -0.000000 -0.866025 -0.500000
tc: 0.500000 0.666667

Pos: -0.433013 -0.750000 -0.500000
Norm: -0.433013 -0.750000 -0.500000
tc: 0.416667 0.666667

Pos: -0.250000 -0.433013 -0.866025
Norm: -0.250000 -0.433013 -0.866025
tc: 0.416667 0.833333

Pos: -0.000000 -0.500000 -0.866025
Norm: -0.000000 -0.500000 -0.866025
tc: 0.500000 0.833333

Pos: -0.000000 -0.866025 -0.500000
Norm: -0.000000 -0.866025 -0.500000
tc: 0.500000 0.666667

Pos: -0.250000 -0.433013 -0.866025
Norm: -0.250000 -0.433013 -0.866025
tc: 0.416667 0.833333

Pos: 0.433012 -0.750000 -0.500000
Norm: 0.433012 -0.750000 -0.500000
tc: 0.583333 0.666667

Pos: -0.000000 -0.866025 -0.500000
Norm: -0.000000 -0.866025 -0.500000
tc: 0.500000 0.666667

Pos: -0.000000 -0.500000 -0.866025
Norm: -0.000000 -0.500000 -0.866025
tc: 0.500000 0.833333

Pos: 0.250000 -0.433013 -0.866025
Norm: 0.250000 -0.433013 -0.866025
tc: 0.583333 0.833333

Pos: 0.433012 -0.750000 -0.500000
Norm: 0.433012 -0.750000 -0.500000
tc: 0.583333 0.666667

Pos: -0.000000 -0.500000 -0.866025
Norm: -0.000000 -0.500000 -0.866025
tc: 0.500000 0.833333

Pos: 0.750000 -0.433013 -0.500000
Norm: 0.750000 -0.433013 -0.500000
tc: 0.666667 0.666667

Pos: 0.433012 -0.750000 -0.500000
Norm: 0.433012 -0.750000 -0.500000
tc: 0.583333 0.666667

Pos: 0.250000 -0.433013 -0.866025
Norm: 0.250000 -0.433013 -0.866025
tc: 0.583333 0.833333

Pos: 0.433013 -0.250000 -0.866025
Norm: 0.433013 -0.250000 -0.866025
tc: 0.666667 0.833333

Pos: 0.750000 -0.433013 -0.500000
Norm: 0.750000 -0.433013 -0.500000
tc: 0.666667 0.666667

Pos: 0.250000 -0.433013 -0.866025
Norm: 0.250000 -0.433013 -0.866025
tc: 0.583333 0.833333

Pos: 0.866025 -0.000001 -0.500000
Norm: 0.866025 -0.000001 -0.500000
tc: 0.750000 0.666667

Pos: 0.750000 -0.433013 -0.500000
Norm: 0.750000 -0.433013 -0.500000
tc: 0.666667 0.666667

Pos: 0.433013 -0.250000 -0.866025
Norm: 0.433013 -0.250000 -0.866025
tc: 0.666667 0.833333

Pos: 0.500000 -0.000000 -0.866025
Norm: 0.500000 -0.000000 -0.866025
tc: 0.750000 0.833333

Pos: 0.866025 -0.000001 -0.500000
Norm: 0.866025 -0.000001 -0.500000
tc: 0.750000 0.666667

Pos: 0.433013 -0.250000 -0.866025
Norm: 0.433013 -0.250000 -0.866025
tc: 0.666667 0.833333

Pos: 0.750000 0.433012 -0.500000
Norm: 0.750000 0.433012 -0.500000
tc: 0.833333 0.666667

Pos: 0.866025 -0.000001 -0.500000
Norm: 0.866025 -0.000001 -0.500000
tc: 0.750000 0.666667

Pos: 0.500000 -0.000000 -0.866025
Norm: 0.500000 -0.000000 -0.866025
tc: 0.750000 0.833333

Pos: 0.433013 0.250000 -0.866025
Norm: 0.433013 0.250000 -0.866025
tc: 0.833333 0.833333

Pos: 0.750000 0.433012 -0.500000
Norm: 0.750000 0.433012 -0.500000
tc: 0.833333 0.666667

Pos: 0.500000 -0.000000 -0.866025
Norm: 0.500000 -0.000000 -0.866025
tc: 0.750000 0.833333

Pos: 0.433013 0.750000 -0.500000
Norm: 0.433013 0.750000 -0.500000
tc: 0.916667 0.666667

Pos: 0.750000 0.433012 -0.500000
Norm: 0.750000 0.433012 -0.500000
tc: 0.833333 0.666667

Pos: 0.433013 0.250000 -0.866025
Norm: 0.433013 0.250000 -0.866025
tc: 0.833333 0.833333

Pos: 0.250000 0.433012 -0.866025
Norm: 0.250000 0.433012 -0.866025
tc: 0.916667 0.833333

Pos: 0.433013 0.750000 -0.500000
Norm: 0.433013 0.750000 -0.500000
tc: 0.916667 0.666667

Pos: 0.433013 0.250000 -0.866025
Norm: 0.433013 0.250000 -0.866025
tc: 0.833333 0.833333

Pos: 0.000000 0.866025 -0.500000
Norm: 0.000000 0.866025 -0.500000
tc: 1.000000 0.666667

Pos: 0.433013 0.750000 -0.500000
Norm: 0.433013 0.750000 -0.500000
tc: 0.916667 0.666667

Pos: 0.250000 0.433012 -0.866025
Norm: 0.250000 0.433012 -0.866025
tc: 0.916667 0.833333

Pos: 0.000000 0.500000 -0.866025
Norm: 0.000000 0.500000 -0.866025
tc: 1.000000 0.833333

Pos: 0.000000 0.866025 -0.500000
Norm: 0.000000 0.866025 -0.500000
tc: 1.000000 0.666667

Pos: 0.250000 0.433012 -0.866025
Norm: 0.250000 0.433012 -0.866025
tc: 0.916667 0.833333

Pos: -0.500000 0.866025 0.000000
Norm: -0.500000 0.866025 0.000000
tc: 0.083333 0.500000

Pos: 0.000000 1.000000 0.000000
Norm: 0.000000 1.000000 0.000000
tc: 0.000000 0.500000

Pos: 0.000000 0.866025 -0.500000
Norm: 0.000000 0.866025 -0.500000
tc: 0.000000 0.666667

Pos: -0.433013 0.750000 -0.500000
Norm: -0.433013 0.750000 -0.500000
tc: 0.083333 0.666667

Pos: -0.500000 0.866025 0.000000
Norm: -0.500000 0.866025 0.000000
tc: 0.083333 0.500000

Pos: 0.000000 0.866025 -0.500000
Norm: 0.000000 0.866025 -0.500000
tc: 0.000000 0.666667

Pos: -0.866025 0.500000 0.000000
Norm: -0.866025 0.500000 0.000000
tc: 0.166667 0.500000

Pos: -0.500000 0.866025 0.000000
Norm: -0.500000 0.866025 0.000000
tc: 0.083333 0.500000

Pos: -0.433013 0.750000 -0.500000
Norm: -0.433013 0.750000 -0.500000
tc: 0.083333 0.666667

Pos: -0.750000 0.433013 -0.500000
Norm: -0.750000 0.433013 -0.500000
tc: 0.166667 0.666667

Pos: -0.866025 0.500000 0.000000
Norm: -0.866025 0.500000 0.000000
tc: 0.166667 0.500000

Pos: -0.433013 0.750000 -0.500000
Norm: -0.433013 0.750000 -0.500000
tc: 0.083333 0.666667

Pos: -1.000000 0.000000 0.000000
Norm: -1.000000 0.000000 0.000000
tc: 0.250000 0.500000

Pos: -0.866025 0.500000 0.000000
Norm: -0.866025 0.500000 0.000000
tc: 0.166667 0.500000

Pos: -0.750000 0.433013 -0.500000
Norm: -0.750000 0.433013 -0.500000
tc: 0.166667 0.666667

Pos: -0.866025 0.000000 -0.500000
Norm: -0.866025 0.000000 -0.500000
tc: 0.250000 0.666667

Pos: -1.000000 0.000000 0.000000
Norm: -1.000000 0.000000 0.000000
tc: 0.250000 0.500000

Pos: -0.750000 0.433013 -0.500000
Norm: -0.750000 0.433013 -0.500000
tc: 0.166667 0.666667

Pos: -0.866026 -0.500000 0.000000
Norm: -0.866026 -0.500000 0.000000
tc: 0.333333 0.500000

Pos: -1.000000 0.000000 0.000000
Norm: -1.000000 0.000000 0.000000
tc: 0.250000 0.500000

Pos: -0.866025 0.000000 -0.500000
Norm: -0.866025 0.000000 -0.500000
tc: 0.250000 0.666667

Pos: -0.750000 -0.433013 -0.500000
Norm: -0.750000 -0.433013 -0.500000
tc: 0.333333 0.666667

Pos: -0.866026 -0.500000 0.000000
Norm: -0.866026 -0.500000 0.000000
tc: 0.333333 0.500000

Pos: -0.866025 0.000000 -0.500000
Norm: -0.866025 0.000000 -0.500000
tc: 0.250000 0.666667

Pos: -0.500000 -0.866025 0.000000
Norm: -0.500000 -0.866025 0.000000
tc: 0.416667 0.500000

Pos: -0.866026 -0.500000 0.000000
Norm: -0.866026 -0.500000 0.000000
tc: 0.333333 0.500000

Pos: -0.750000 -0.433013 -0.500000
Norm: -0.750000 -0.433013 -0.500000
tc: 0.333333 0.666667

Pos: -0.433013 -0.750000 -0.500000
Norm: -0.433013 -0.750000 -0.500000
tc: 0.416667 0.666667

Pos: -0.500000 -0.866025 0.000000
Norm: -0.500000 -0.866025 0.000000
tc: 0.416667 0.500000

Pos: -0.750000 -0.433013 -0.500000
Norm: -0.750000 -0.433013 -0.500000
tc: 0.333333 0.666667

Pos: -0.000000 -1.000000 0.000000
Norm: -0.000000 -1.000000 0.000000
tc: 0.500000 0.500000

Pos: -0.500000 -0.866025 0.000000
Norm: -0.500000 -0.866025 0.000000
tc: 0.416667 0.500000

Pos: -0.433013 -0.750000 -0.500000
Norm: -0.433013 -0.750000 -0.500000
tc: 0.416667 0.666667

Pos: -0.000000 -0.866025 -0.500000
Norm: -0.000000 -0.866025 -0.500000
tc: 0.500000 0.666667

Pos: -0.000000 -1.000000 0.000000
Norm: -0.000000 -1.000000 0.000000
tc: 0.500000 0.500000

Pos: -0.433013 -0.750000 -0.500000
Norm: -0.433013 -0.750000 -0.500000
tc: 0.416667 0.666667

Pos: 0.499999 -0.866026 0.000000
Norm: 0.499999 -0.866026 0.000000
tc: 0.583333 0.500000

Pos: -0.000000 -1.000000 0.000000
Norm: -0.000000 -1.000000 0.000000
tc: 0.500000 0.500000

Pos: -0.000000 -0.866025 -0.500000
Norm: -0.000000 -0.866025 -0.500000
tc: 0.500000 0.666667

Pos: 0.433012 -0.750000 -0.500000
Norm: 0.433012 -0.750000 -0.500000
tc: 0.583333 0.666667

Pos: 0.499999 -0.866026 0.000000
Norm: 0.499999 -0.866026 0.000000
tc: 0.583333 0.500000

Pos: -0.000000 -0.866025 -0.500000
Norm: -0.000000 -0.866025 -0.500000
tc: 0.500000 0.666667

Pos: 0.866025 -0.500001 0.000000
Norm: 0.866025 -0.500001 0.000000
tc: 0.666667 0.500000

Pos: 0.499999 -0.866026 0.000000
Norm: 0.499999 -0.866026 0.000000
tc: 0.583333 0.500000

Pos: 0.433012 -0.750000 -0.500000
Norm: 0.433012 -0.750000 -0.500000
tc: 0.583333 0.666667

Pos: 0.750000 -0.433013 -0.500000
Norm: 0.750000 -0.433013 -0.500000
tc: 0.666667 0.666667

Pos: 0.866025 -0.500001 0.000000
Norm: 0.866025 -0.500001 0.000000
tc: 0.666667 0.500000

Pos: 0.433012 -0.750000 -0.500000
Norm: 0.433012 -0.750000 -0.500000
tc: 0.583333 0.666667

Pos: 1.000000 -0.000001 0.000000
Norm: 1.000000 -0.000001 0.000000
tc: 0.750000 0.500000

Pos: 0.866025 -0.500001 0.000000
Norm: 0.866025 -0.500001 0.000000
tc: 0.666667 0.500000

Pos: 0.750000 -0.433013 -0.500000
Norm: 0.750000 -0.433013 -0.500000
tc: 0.666667 0.666667

Pos: 0.866025 -0.000001 -0.500000
Norm: 0.866025 -0.000001 -0.500000
tc: 0.750000 0.666667

Pos: 1.000000 -0.000001 0.000000
Norm: 1.000000 -0.000001 0.000000
tc: 0.750000 0.500000

Pos: 0.750000 -0.433013 -0.500000
Norm: 0.750000 -0.433013 -0.500000
tc: 0.666667 0.666667

Pos: 0.866026 0.499999 0.000000
Norm: 0.866026 0.499999 0.000000
tc: 0.833333 0.500000

Pos: 1.000000 -0.000001 0.000000
Norm: 1.000000 -0.000001 0.000000
tc: 0.750000 0.500000

Pos: 0.866025 -0.000001 -0.500000
Norm: 0.866025 -0.000001 -0.500000
tc: 0.750000 0.666667

Pos: 0.750000 0.433012 -0.500000
Norm: 0.750000 0.433012 -0.500000
tc: 0.833333 0.666667

Pos: 0.866026 0.499999 0.000000
Norm: 0.866026 0.499999 0.000000
tc: 0.833333 0.500000

Pos: 0.866025 -0.000001 -0.500000
Norm: 0.866025 -0.000001 -0.500000
tc: 0.750000 0.666667

Pos: 0.500001 0.866025 0.000000
Norm: 0.500001 0.866025 0.000000
tc: 0.916667 0.500000

Pos: 0.866026 0.499999 0.000000
Norm: 0.866026 0.499999 0.000000
tc: 0.833333 0.500000

Pos: 0.750000 0.433012 -0.500000

Norm: 0.750000 0.433012 -0.500000
tc: 0.833333 0.666667

Pos: 0.433013 0.750000 -0.500000
Norm: 0.433013 0.750000 -0.500000
tc: 0.916667 0.666667

Pos: 0.500001 0.866025 0.000000
Norm: 0.500001 0.866025 0.000000
tc: 0.916667 0.500000

Pos: 0.750000 0.433012 -0.500000
Norm: 0.750000 0.433012 -0.500000
tc: 0.833333 0.666667

Pos: 0.000000 1.000000 0.000000
Norm: 0.000000 1.000000 0.000000
tc: 1.000000 0.500000

Pos: 0.500001 0.866025 0.000000
Norm: 0.500001 0.866025 0.000000
tc: 0.916667 0.500000

Pos: 0.433013 0.750000 -0.500000
Norm: 0.433013 0.750000 -0.500000
tc: 0.916667 0.666667

Pos: 0.000000 0.866025 -0.500000
Norm: 0.000000 0.866025 -0.500000
tc: 1.000000 0.666667

Pos: 0.000000 1.000000 0.000000
Norm: 0.000000 1.000000 0.000000
tc: 1.000000 0.500000

Pos: 0.433013 0.750000 -0.500000
Norm: 0.433013 0.750000 -0.500000
tc: 0.916667 0.666667

Pos: -0.433013 0.750000 0.500000
Norm: -0.433013 0.750000 0.500000
tc: 0.083333 0.333333

Pos: 0.000000 0.866025 0.500000
Norm: 0.000000 0.866025 0.500000
tc: 0.000000 0.333333

Pos: 0.000000 1.000000 0.000000
Norm: 0.000000 1.000000 0.000000
tc: 0.000000 0.500000

Pos: -0.500000 0.866025 0.000000
Norm: -0.500000 0.866025 0.000000
tc: 0.083333 0.500000

Pos: -0.433013 0.750000 0.500000
Norm: -0.433013 0.750000 0.500000
tc: 0.083333 0.333333

Pos: 0.000000 1.000000 0.000000
Norm: 0.000000 1.000000 0.000000
tc: 0.000000 0.500000

Pos: -0.750000 0.433013 0.500000
Norm: -0.750000 0.433013 0.500000
tc: 0.166667 0.333333

Pos: -0.433013 0.750000 0.500000
Norm: -0.433013 0.750000 0.500000
tc: 0.083333 0.333333

Pos: -0.500000 0.866025 0.000000
Norm: -0.500000 0.866025 0.000000
tc: 0.083333 0.500000

Pos: -0.866025 0.500000 0.000000
Norm: -0.866025 0.500000 0.000000
tc: 0.166667 0.500000

Pos: -0.750000 0.433013 0.500000
Norm: -0.750000 0.433013 0.500000
tc: 0.166667 0.333333

Pos: -0.500000 0.866025 0.000000
Norm: -0.500000 0.866025 0.000000
tc: 0.083333 0.500000

Pos: -0.866025 0.000000 0.500000
Norm: -0.866025 0.000000 0.500000
tc: 0.250000 0.333333

Pos: -0.750000 0.433013 0.500000
Norm: -0.750000 0.433013 0.500000
tc: 0.166667 0.333333

Pos: -0.866025 0.500000 0.000000
Norm: -0.866025 0.500000 0.000000
tc: 0.166667 0.500000

Pos: -1.000000 0.000000 0.000000
Norm: -1.000000 0.000000 0.000000
tc: 0.250000 0.500000

Pos: -0.866025 0.000000 0.500000
Norm: -0.866025 0.000000 0.500000
tc: 0.250000 0.333333

Pos: -0.866025 0.500000 0.000000
Norm: -0.866025 0.500000 0.000000
tc: 0.166667 0.500000

Pos: -0.750000 -0.433012 0.500000
Norm: -0.750000 -0.433012 0.500000
tc: 0.333333 0.333333

Pos: -0.866025 0.000000 0.500000
Norm: -0.866025 0.000000 0.500000
tc: 0.250000 0.333333

Pos: -1.000000 0.000000 0.000000
Norm: -1.000000 0.000000 0.000000
tc: 0.250000 0.500000

Pos: -0.866026 -0.500000 0.000000
Norm: -0.866026 -0.500000 0.000000
tc: 0.333333 0.500000

Pos: -0.750000 -0.433012 0.500000
Norm: -0.750000 -0.433012 0.500000
tc: 0.333333 0.333333

Pos: -1.000000 0.000000 0.000000
Norm: -1.000000 0.000000 0.000000
tc: 0.250000 0.500000

Pos: -0.433013 -0.750000 0.500000
Norm: -0.433013 -0.750000 0.500000
tc: 0.416667 0.333333

Pos: -0.750000 -0.433012 0.500000
Norm: -0.750000 -0.433012 0.500000
tc: 0.333333 0.333333

Pos: -0.866026 -0.500000 0.000000
Norm: -0.866026 -0.500000 0.000000
tc: 0.333333 0.500000

Pos: -0.500000 -0.866025 0.000000
Norm: -0.500000 -0.866025 0.000000
tc: 0.416667 0.500000

Pos: -0.433013 -0.750000 0.500000
Norm: -0.433013 -0.750000 0.500000
tc: 0.416667 0.333333

Pos: -0.866026 -0.500000 0.000000
Norm: -0.866026 -0.500000 0.000000
tc: 0.333333 0.500000

Pos: -0.000000 -0.866025 0.500000
Norm: -0.000000 -0.866025 0.500000
tc: 0.500000 0.333333

Pos: -0.433013 -0.750000 0.500000
Norm: -0.433013 -0.750000 0.500000
tc: 0.416667 0.333333

Pos: -0.500000 -0.866025 0.000000
Norm: -0.500000 -0.866025 0.000000
tc: 0.416667 0.500000

Pos: -0.000000 -1.000000 0.000000
Norm: -0.000000 -1.000000 0.000000
tc: 0.500000 0.500000

Pos: -0.000000 -0.866025 0.500000
Norm: -0.000000 -0.866025 0.500000
tc: 0.500000 0.333333

Pos: -0.500000 -0.866025 0.000000
Norm: -0.500000 -0.866025 0.000000
tc: 0.416667 0.500000

Pos: 0.433012 -0.750000 0.500000
Norm: 0.433012 -0.750000 0.500000
tc: 0.583333 0.333333

Pos: -0.000000 -0.866025 0.500000
Norm: -0.000000 -0.866025 0.500000
tc: 0.500000 0.333333

Pos: -0.000000 -1.000000 0.000000
Norm: -0.000000 -1.000000 0.000000
tc: 0.500000 0.500000

Pos: 0.499999 -0.866026 0.000000
Norm: 0.499999 -0.866026 0.000000
tc: 0.583333 0.500000

Pos: 0.433012 -0.750000 0.500000
Norm: 0.433012 -0.750000 0.500000
tc: 0.583333 0.333333

Pos: -0.000000 -1.000000 0.000000
Norm: -0.000000 -1.000000 0.000000
tc: 0.500000 0.500000

Pos: 0.750000 -0.433013 0.500000
Norm: 0.750000 -0.433013 0.500000
tc: 0.666667 0.333333

Pos: 0.433012 -0.750000 0.500000
Norm: 0.433012 -0.750000 0.500000
tc: 0.583333 0.333333

Pos: 0.499999 -0.866026 0.000000
Norm: 0.499999 -0.866026 0.000000
tc: 0.583333 0.500000

Pos: 0.866025 -0.500001 0.000000
Norm: 0.866025 -0.500001 0.000000
tc: 0.666667 0.500000

Pos: 0.750000 -0.433013 0.500000
Norm: 0.750000 -0.433013 0.500000
tc: 0.666667 0.333333

Pos: 0.499999 -0.866026 0.000000
Norm: 0.499999 -0.866026 0.000000
tc: 0.583333 0.500000

Pos: 0.866025 -0.000001 0.500000
Norm: 0.866025 -0.000001 0.500000
tc: 0.750000 0.333333

Pos: 0.750000 -0.433013 0.500000
Norm: 0.750000 -0.433013 0.500000
tc: 0.666667 0.333333

Pos: 0.866025 -0.500001 0.000000
Norm: 0.866025 -0.500001 0.000000
tc: 0.666667 0.500000

Pos: 1.000000 -0.000001 0.000000
Norm: 1.000000 -0.000001 0.000000
tc: 0.750000 0.500000

Pos: 0.866025 -0.000001 0.500000
Norm: 0.866025 -0.000001 0.500000
tc: 0.750000 0.333333

Pos: 0.866025 -0.500001 0.000000
Norm: 0.866025 -0.500001 0.000000
tc: 0.666667 0.500000

Pos: 0.750000 0.433012 0.500000
Norm: 0.750000 0.433012 0.500000
tc: 0.833333 0.333333

Pos: 0.866025 -0.000001 0.500000
Norm: 0.866025 -0.000001 0.500000
tc: 0.750000 0.333333

Pos: 1.000000 -0.000001 0.000000
Norm: 1.000000 -0.000001 0.000000
tc: 0.750000 0.500000

Pos: 0.866026 0.499999 0.000000
Norm: 0.866026 0.499999 0.000000
tc: 0.833333 0.500000

Pos: 0.750000 0.433012 0.500000
Norm: 0.750000 0.433012 0.500000
tc: 0.833333 0.333333

Pos: 1.000000 -0.000001 0.000000
Norm: 1.000000 -0.000001 0.000000
tc: 0.750000 0.500000

Pos: 0.433013 0.750000 0.500000
Norm: 0.433013 0.750000 0.500000
tc: 0.916667 0.333333

Pos: 0.750000 0.433012 0.500000
Norm: 0.750000 0.433012 0.500000
tc: 0.833333 0.333333

Pos: 0.866026 0.499999 0.000000
Norm: 0.866026 0.499999 0.000000
tc: 0.833333 0.500000

Pos: 0.500001 0.866025 0.000000
Norm: 0.500001 0.866025 0.000000
tc: 0.916667 0.500000

Pos: 0.433013 0.750000 0.500000
Norm: 0.433013 0.750000 0.500000
tc: 0.916667 0.333333

Pos: 0.866026 0.499999 0.000000
Norm: 0.866026 0.499999 0.000000
tc: 0.833333 0.500000

Pos: 0.000000 0.866025 0.500000
Norm: 0.000000 0.866025 0.500000
tc: 1.000000 0.333333

Pos: 0.433013 0.750000 0.500000
Norm: 0.433013 0.750000 0.500000
tc: 0.916667 0.333333

Pos: 0.500001 0.866025 0.000000
Norm: 0.500001 0.866025 0.000000
tc: 0.916667 0.500000

Pos: 0.000000 1.000000 0.000000
Norm: 0.000000 1.000000 0.000000
tc: 1.000000 0.500000

Pos: 0.000000 0.866025 0.500000
Norm: 0.000000 0.866025 0.500000
tc: 1.000000 0.333333

Pos: 0.500001 0.866025 0.000000
Norm: 0.500001 0.866025 0.000000
tc: 0.916667 0.500000

Pos: -0.250000 0.433013 0.866025
Norm: -0.250000 0.433013 0.866025
tc: 0.083333 0.166667

Pos: 0.000000 0.500000 0.866025
Norm: 0.000000 0.500000 0.866025
tc: 0.000000 0.166667

Pos: 0.000000 0.866025 0.500000
Norm: 0.000000 0.866025 0.500000
tc: 0.000000 0.333333

Pos: -0.433013 0.750000 0.500000
Norm: -0.433013 0.750000 0.500000
tc: 0.083333 0.333333

Pos: -0.250000 0.433013 0.866025
Norm: -0.250000 0.433013 0.866025
tc: 0.083333 0.166667

Pos: 0.000000 0.866025 0.500000
Norm: 0.000000 0.866025 0.500000
tc: 0.000000 0.333333

Pos: -0.433013 0.250000 0.866025
Norm: -0.433013 0.250000 0.866025
tc: 0.166667 0.166667

Pos: -0.250000 0.433013 0.866025
Norm: -0.250000 0.433013 0.866025
tc: 0.083333 0.166667

Pos: -0.433013 0.750000 0.500000
Norm: -0.433013 0.750000 0.500000
tc: 0.083333 0.333333

Pos: -0.750000 0.433013 0.500000
Norm: -0.750000 0.433013 0.500000
tc: 0.166667 0.333333

Pos: -0.433013 0.250000 0.866025
Norm: -0.433013 0.250000 0.866025
tc: 0.166667 0.166667

Pos: -0.433013 0.750000 0.500000
Norm: -0.433013 0.750000 0.500000
tc: 0.083333 0.333333

Pos: -0.500000 0.000000 0.866025
Norm: -0.500000 0.000000 0.866025
tc: 0.250000 0.166667

Pos: -0.433013 0.250000 0.866025
Norm: -0.433013 0.250000 0.866025
tc: 0.166667 0.166667

Pos: -0.750000 0.433013 0.500000
Norm: -0.750000 0.433013 0.500000
tc: 0.166667 0.333333

Pos: -0.866025 0.000000 0.500000
Norm: -0.866025 0.000000 0.500000
tc: 0.250000 0.333333

Pos: -0.500000 0.000000 0.866025
Norm: -0.500000 0.000000 0.866025
tc: 0.250000 0.166667

Pos: -0.750000 0.433013 0.500000
Norm: -0.750000 0.433013 0.500000
tc: 0.166667 0.333333

Pos: -0.433013 -0.250000 0.866025
Norm: -0.433013 -0.250000 0.866025
tc: 0.333333 0.166667

Pos: -0.500000 0.000000 0.866025
Norm: -0.500000 0.000000 0.866025
tc: 0.250000 0.166667

Pos: -0.866025 0.000000 0.500000
Norm: -0.866025 0.000000 0.500000
tc: 0.250000 0.333333

Pos: -0.750000 -0.433012 0.500000
Norm: -0.750000 -0.433012 0.500000
tc: 0.333333 0.333333

Pos: -0.433013 -0.250000 0.866025
Norm: -0.433013 -0.250000 0.866025
tc: 0.333333 0.166667

Pos: -0.866025 0.000000 0.500000
Norm: -0.866025 0.000000 0.500000
tc: 0.250000 0.333333

Pos: -0.250000 -0.433013 0.866025
Norm: -0.250000 -0.433013 0.866025
tc: 0.416667 0.166667

Pos: -0.433013 -0.250000 0.866025
Norm: -0.433013 -0.250000 0.866025
tc: 0.333333 0.166667

Pos: -0.750000 -0.433012 0.500000
Norm: -0.750000 -0.433012 0.500000
tc: 0.333333 0.333333

Pos: -0.433013 -0.750000 0.500000
Norm: -0.433013 -0.750000 0.500000
tc: 0.416667 0.333333

Pos: -0.250000 -0.433013 0.866025
Norm: -0.250000 -0.433013 0.866025
tc: 0.416667 0.166667

Pos: -0.750000 -0.433012 0.500000
Norm: -0.750000 -0.433012 0.500000
tc: 0.333333 0.333333

Pos: -0.000000 -0.500000 0.866025
Norm: -0.000000 -0.500000 0.866025
tc: 0.500000 0.166667

Pos: -0.250000 -0.433013 0.866025
Norm: -0.250000 -0.433013 0.866025
tc: 0.416667 0.166667

Pos: -0.433013 -0.750000 0.500000
Norm: -0.433013 -0.750000 0.500000
tc: 0.416667 0.333333

Pos: -0.000000 -0.866025 0.500000
Norm: -0.000000 -0.866025 0.500000
tc: 0.500000 0.333333

Pos: -0.000000 -0.500000 0.866025
Norm: -0.000000 -0.500000 0.866025
tc: 0.500000 0.166667

Pos: -0.433013 -0.750000 0.500000
Norm: -0.433013 -0.750000 0.500000
tc: 0.416667 0.333333

Pos: 0.250000 -0.433013 0.866025
Norm: 0.250000 -0.433013 0.866025
tc: 0.583333 0.166667

Pos: -0.000000 -0.500000 0.866025
Norm: -0.000000 -0.500000 0.866025
tc: 0.500000 0.166667

Pos: -0.000000 -0.866025 0.500000
Norm: -0.000000 -0.866025 0.500000
tc: 0.500000 0.333333

Pos: 0.433012 -0.750000 0.500000
Norm: 0.433012 -0.750000 0.500000
tc: 0.583333 0.333333

Pos: 0.250000 -0.433013 0.866025
Norm: 0.250000 -0.433013 0.866025
tc: 0.583333 0.166667

Pos: -0.000000 -0.866025 0.500000
Norm: -0.000000 -0.866025 0.500000
tc: 0.500000 0.333333

Pos: 0.433013 -0.250000 0.866025
Norm: 0.433013 -0.250000 0.866025
tc: 0.666667 0.166667

Pos: 0.250000 -0.433013 0.866025
Norm: 0.250000 -0.433013 0.866025
tc: 0.583333 0.166667

Pos: 0.433012 -0.750000 0.500000
Norm: 0.433012 -0.750000 0.500000
tc: 0.583333 0.333333

Pos: 0.750000 -0.433013 0.500000
Norm: 0.750000 -0.433013 0.500000
tc: 0.666667 0.333333

Pos: 0.433013 -0.250000 0.866025
Norm: 0.433013 -0.250000 0.866025
tc: 0.666667 0.166667

Pos: 0.433012 -0.750000 0.500000
Norm: 0.433012 -0.750000 0.500000
tc: 0.583333 0.333333

Pos: 0.500000 -0.000000 0.866025
Norm: 0.500000 -0.000000 0.866025
tc: 0.750000 0.166667

Pos: 0.433013 -0.250000 0.866025
Norm: 0.433013 -0.250000 0.866025
tc: 0.666667 0.166667

Pos: 0.750000 -0.433013 0.500000
Norm: 0.750000 -0.433013 0.500000
tc: 0.666667 0.333333

Pos: 0.866025 -0.000001 0.500000
Norm: 0.866025 -0.000001 0.500000
tc: 0.750000 0.333333

Pos: 0.500000 -0.000000 0.866025
Norm: 0.500000 -0.000000 0.866025
tc: 0.750000 0.166667

Pos: 0.750000 -0.433013 0.500000
Norm: 0.750000 -0.433013 0.500000
tc: 0.666667 0.333333

Pos: 0.433013 0.250000 0.866025
Norm: 0.433013 0.250000 0.866025
tc: 0.833333 0.166667

Pos: 0.500000 -0.000000 0.866025
Norm: 0.500000 -0.000000 0.866025
tc: 0.750000 0.166667

Pos: 0.866025 -0.000001 0.500000
Norm: 0.866025 -0.000001 0.500000
tc: 0.750000 0.333333

Pos: 0.750000 0.433012 0.500000
Norm: 0.750000 0.433012 0.500000
tc: 0.833333 0.333333

Pos: 0.433013 0.250000 0.866025
Norm: 0.433013 0.250000 0.866025
tc: 0.833333 0.166667

Pos: 0.866025 -0.000001 0.500000
Norm: 0.866025 -0.000001 0.500000
tc: 0.750000 0.333333

Pos: 0.250000 0.433013 0.866025
Norm: 0.250000 0.433013 0.866025
tc: 0.916667 0.166667

Pos: 0.433013 0.250000 0.866025
Norm: 0.433013 0.250000 0.866025
tc: 0.833333 0.166667

Pos: 0.750000 0.433012 0.500000
Norm: 0.750000 0.433012 0.500000
tc: 0.833333 0.333333

Pos: 0.433013 0.750000 0.500000
Norm: 0.433013 0.750000 0.500000
tc: 0.916667 0.333333

Pos: 0.250000 0.433013 0.866025
Norm: 0.250000 0.433013 0.866025
tc: 0.916667 0.166667

Pos: 0.750000 0.433012 0.500000
Norm: 0.750000 0.433012 0.500000
tc: 0.833333 0.333333

Pos: 0.000000 0.500000 0.866025
Norm: 0.000000 0.500000 0.866025
tc: 1.000000 0.166667

Pos: 0.250000 0.433013 0.866025
Norm: 0.250000 0.433013 0.866025
tc: 0.916667 0.166667

Pos: 0.433013 0.750000 0.500000
Norm: 0.433013 0.750000 0.500000
tc: 0.916667 0.333333

Pos: 0.000000 0.866025 0.500000
Norm: 0.000000 0.866025 0.500000
tc: 1.000000 0.333333

Pos: 0.000000 0.500000 0.866025
Norm: 0.000000 0.500000 0.866025
tc: 1.000000 0.166667

Pos: 0.433013 0.750000 0.500000
Norm: 0.433013 0.750000 0.500000
tc: 0.916667 0.333333

Pos: 0.000000 0.500000 0.866025
Norm: 0.000000 0.500000 0.866025
tc: 0.000000 0.166667

Pos: -0.250000 0.433013 0.866025
Norm: -0.250000 0.433013 0.866025
tc: 0.083333 0.166667

Pos: 0.000000 0.000000 1.000000
Norm: 0.000000 0.000000 1.000000
tc: 0.000000 0.000000

Pos: -0.250000 0.433013 0.866025
Norm: -0.250000 0.433013 0.866025
tc: 0.083333 0.166667

Pos: -0.433013 0.250000 0.866025
Norm: -0.433013 0.250000 0.866025
tc: 0.166667 0.166667

Pos: 0.000000 0.000000 1.000000
Norm: 0.000000 0.000000 1.000000
tc: 0.083333 0.000000

Pos: -0.433013 0.250000 0.866025
Norm: -0.433013 0.250000 0.866025
tc: 0.166667 0.166667

Pos: -0.500000 0.000000 0.866025
Norm: -0.500000 0.000000 0.866025
tc: 0.250000 0.166667

Pos: 0.000000 0.000000 1.000000
Norm: 0.000000 0.000000 1.000000
tc: 0.166667 0.000000

Pos: -0.500000 0.000000 0.866025
Norm: -0.500000 0.000000 0.866025
tc: 0.250000 0.166667

Pos: -0.433013 -0.250000 0.866025
Norm: -0.433013 -0.250000 0.866025
tc: 0.333333 0.166667

Pos: 0.000000 0.000000 1.000000
Norm: 0.000000 0.000000 1.000000
tc: 0.250000 0.000000

Pos: -0.433013 -0.250000 0.866025
Norm: -0.433013 -0.250000 0.866025
tc: 0.333333 0.166667

Pos: -0.250000 -0.433013 0.866025
Norm: -0.250000 -0.433013 0.866025
tc: 0.416667 0.166667

Pos: 0.000000 0.000000 1.000000
Norm: 0.000000 0.000000 1.000000
tc: 0.333333 0.000000

Pos: -0.250000 -0.433013 0.866025
Norm: -0.250000 -0.433013 0.866025
tc: 0.416667 0.166667

Pos: -0.000000 -0.500000 0.866025
Norm: -0.000000 -0.500000 0.866025
tc: 0.500000 0.166667

Pos: 0.000000 0.000000 1.000000
Norm: 0.000000 0.000000 1.000000
tc: 0.416667 0.000000

Pos: -0.000000 -0.500000 0.866025
Norm: -0.000000 -0.500000 0.866025
tc: 0.500000 0.166667

Pos: 0.250000 -0.433013 0.866025
Norm: 0.250000 -0.433013 0.866025
tc: 0.583333 0.166667

Pos: 0.000000 0.000000 1.000000
Norm: 0.000000 0.000000 1.000000
tc: 0.500000 0.000000

Pos: 0.250000 -0.433013 0.866025
Norm: 0.250000 -0.433013 0.866025
tc: 0.583333 0.166667

Pos: 0.433013 -0.250000 0.866025
Norm: 0.433013 -0.250000 0.866025
tc: 0.666667 0.166667

Pos: 0.000000 0.000000 1.000000
Norm: 0.000000 0.000000 1.000000
tc: 0.583333 0.000000

Pos: 0.433013 -0.250000 0.866025
Norm: 0.433013 -0.250000 0.866025
tc: 0.666667 0.166667

Pos: 0.500000 -0.000000 0.866025
Norm: 0.500000 -0.000000 0.866025
tc: 0.750000 0.166667

Pos: 0.000000 0.000000 1.000000
Norm: 0.000000 0.000000 1.000000
tc: 0.666667 0.000000

Pos: 0.500000 -0.000000 0.866025
Norm: 0.500000 -0.000000 0.866025
tc: 0.750000 0.166667

Pos: 0.433013 0.250000 0.866025
Norm: 0.433013 0.250000 0.866025
tc: 0.833333 0.166667

Pos: 0.000000 0.000000 1.000000
Norm: 0.000000 0.000000 1.000000
tc: 0.750000 0.000000

Pos: 0.433013 0.250000 0.866025
Norm: 0.433013 0.250000 0.866025
tc: 0.833333 0.166667

Pos: 0.250000 0.433013 0.866025
Norm: 0.250000 0.433013 0.866025
tc: 0.916667 0.166667

Pos: 0.000000 0.000000 1.000000
Norm: 0.000000 0.000000 1.000000
tc: 0.833333 0.000000

Pos: 0.250000 0.433013 0.866025
Norm: 0.250000 0.433013 0.866025
tc: 0.916667 0.166667

Pos: 0.000000 0.500000 0.866025
Norm: 0.000000 0.500000 0.866025
tc: 1.000000 0.166667

Pos: 0.000000 0.000000 1.000000
Norm: 0.000000 0.000000 1.000000
tc: 0.916667 0.000000


#Face_Index
0 1 2 0
3 4 5 0
6 7 8 0
9 10 11 0
12 13 14 0
15 16 17 0
18 19 20 0
21 22 23 0
24 25 26 0
27 28 29 0
30 31 32 0
33 34 35 0
36 37 38 0
39 40 41 0
42 43 44 0
45 46 47 0
48 49 50 0
51 52 53 0
54 55 56 0
57 58 59 0
60 61 62 0
63 64 65 0
66 67 68 0
69 70 71 0
72 73 74 0
75 76 77 0
78 79 80 0
81 82 83 0
84 85 86 0
87 88 89 0
90 91 92 0
93 94 95 0
96 97 98 0
99 100 101 0
102 103 104 0
105 106 107 0
108 109 110 0
111 112 113 0
114 115 116 0
117 118 119 0
120 121 122 0
123 124 125 0
126 127 128 0
129 130 131 0
132 133 134 0
135 136 137 0
138 139 140 0
141 142 143 0
144 145 146 0
147 148 149 0
150 151 152 0
153 154 155 0
156 157 158 0
159 160 161 0
162 163 164 0
165 166 167 0
168 169 170 0
171 172 173 0
174 175 176 0
177 178 179 1
180 181 182 1
183 184 185 1
186 187 188 1
189 190 191 1
192 193 194 1
195 196 197 1
198 199 200 1
201 202 203 1
204 205 206 1
207 208 209 1
210 211 212 1
213 214 215 1
216 217 218 1
219 220 221 1
222 223 224 1
225 226 227 1
228 229 230 1
231 232 233 1
234 235 236 1
237 238 239 1
240 241 242 1
243 244 245 1
246 247 248 1
249 250 251 1
252 253 254 1
255 256 257 1
258 259 260 1
261 262 263 1
264 265 266 1
267 268 269 1
270 271 272 1
273 274 275 1
276 277 278 1
279 280 281 1
282 283 284 1
285 286 287 1
288 289 290 1
291 292 293 1
294 295 296 1
297 298 299 1
300 301 302 1
303 304 305 1
306 307 308 1
309 310 311 1
312 313 314 1
315 316 317 1
318 319 320 1
321 322 323 1
324 325 326 1
327 328 329 1
330 331 332 1
333 334 335 1
336 337 338 1
339 340 341 1
342 343 344 1
345 346 347 1
348 349 350 1
351 352 353 1
354 355 356 1
357 358 359 1


Any help on how to resolve the problem is greatly appreciated. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Before I start, I want to make sure you at least read this. I would recommend reading through the lessons instead of just the code. There are some ideas and stuff that are better explained in the lessons that are not explained in the code. and i know I've explained most of the problems you've been having in my lessons. Not to tell you what to do or anything, if you just want the code from my lessons that's completely fine and still makes me happy that someones finding use for it, but I really think you would save yourself a couple headaches from reading a little more ;)

Let's start at the top of the problems. The first problem that you'll notice, is the function that creates the sphere is totally wrong... (i'm terribly sorry for using bad code... you'll see why its wrong in a moment...). Next thing you should notice, is you are setting your vertex buffer when creating the sphere (in CreateSphere()) to "VertexBuffer":

for(DWORD i = 0; i < LatLines; ++i)
{
sphereYaw = i * (3.14/LatLines);
for(DWORD j = 0; j < LongLines; ++j)
{
spherePitch = j * (3.14/LongLines);
D3DXMatrixRotationYawPitchRoll( &rotationMatrix, sphereYaw, spherePitch, 0 );
D3DXVec3TransformCoord( &currVertPos, &DefaultForward, &rotationMatrix );
D3DXVec3Normalize( &currVertPos, &currVertPos );
vertices[i*LongLines+j].pos = currVertPos;
}
}

...
// Here d3dDevice->CreateBuffer( &bd, &InitData, &VertexBuffer );


Next, you create your vertices for the pyramid (in InitScene()), and also store that into "VertexBuffer":

v[0] = Vertex( 0.0f, 2.5f, 0.0f, 0.0f, 0.5f, 0.5f, 0.0f, 0.0f);
...

...
// Here d3dDevice->CreateBuffer(&vbd, &vinitData, &VertexBuffer);


Whats happening when you do this, is that you are "replacing" the first vertices of the sphere with that of the pyramid.

After that, You are not actually creating an index buffer for your pyramid:

DWORD i[18];

// Front Face
i[0] = 0; i[1] = 2; i[2] = 1;

...

// No Index buffer creation here...

D3DX10_IMAGE_LOAD_INFO loadSMInfo;
loadSMInfo.MiscFlags = D3D10_RESOURCE_MISC_TEXTURECUBE;

ID3D10Texture2D* SMTexture = 0;
hr = D3DX10CreateTextureFromFile(d3dDevice, L"skymap.dds",
&loadSMInfo, 0, (ID3D10Resource**)&SMTexture, 0);


Now we go into the drawscene function. When you draw an opject, you have to bind the vertex buffer and index buffer to the input assembler (IA). I made a mistake and bound the spheres buffers in the function that created it, when i should have been binding it before you draw the sphere. Another mistake on my part... When you use the ID3DX10Mesh::DrawSubset() method, it automatically binds the meshes index and vertex buffers to the IA. Since like you've probably heard before, directx is a state machine, where things stay in their current state until specifically changed. that means that whenever you bind the buffers to the IA, they will stay bound until you bind other ones. In your code (and in my lessons sadly...) no vertex and index buffer was bound to the IA (except for the call to the DrawSubset method). Remember that the spheres index and vertex buffers were bound to the IA in the sphere create function. they will stay bound until changed, which happens on this line:

meshes[1]->DrawSubset(subsetID);

where you draw the little sphere with the braynzar logo thing on it. I feel so stupid because of the mistakes i have in my lesson, which i need to change soon, but you'll notice, when you set the vertex and index buffers before each drawindexed call, that the sky is only showing half, thats because the geometry is bad, and my function completely failed, and i never noticed it because i never actually bound the spheres buffer to the IA in the drawscene function, so that the other geometry was being drawn instead of the sphere from the spherecreate function.

Another thing, is that you are not creating the pyramids own world matrix and sending it to the shaders BEFORE you draw the pyramid, so that is why it is "following" the camera.

SO, to fix your program, this is what needs to happen:

First, declare two new ID3D10Buffer 's, one for the pyramids index buffer, and one for the pyramids vertex buffer:


ID3D10Buffer* pyramidVertBuff;
ID3D10Buffer* pyramidIndexBuff;


next we have to store the pyramids vertices into its own buffer (in the initscene() function):

D3D10_BUFFER_DESC vbd;
vbd.Usage = D3D10_USAGE_IMMUTABLE;
vbd.ByteWidth = sizeof(Vertex) * 5;
vbd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
vbd.CPUAccessFlags = 0;
vbd.MiscFlags = 0;
D3D10_SUBRESOURCE_DATA vinitData;
vinitData.pSysMem = v;

// Now storing in the pyramidVertBuff buffer
d3dDevice->CreateBuffer(&vbd, &vinitData, &pyramidVertBuff);


After that we need to actually create an index buffer for the pyramid, which we will do right after we create the pyramids indices:

DWORD i[18];

// Front Face
i[0] = 0; i[1] = 2; i[2] = 1;

...

ID3D10_BUFFER_DESC ibd;
ibd.Usage = D3D10_USAGE_IMMUTABLE;
ibd.ByteWidth = sizeof(DWORD) * 6 * 3;
ibd.BindFlags = D3D10_BIND_INDEX_BUFFER;
ibd.CPUAccessFlags = 0;
ibd.MiscFlags = 0;
D3D10_SUBRESOURCE_DATA iinitData;
iinitData.pSysMem = &i[0];
d3dDevice->CreateBuffer(&ibd, &iinitData, &pyramidIndexBuff);


Now that we have the pyramids own separate buffer, we need to actually bind the correct buffers to the IA before we draw our objects. To do that, we use the two functions ID3D10Device::IASetVertexBuffers() and ID3D10Device::IASetIndexBuffer(), like this:

// Set sky sphere's index and vertex buffers
UINT stride = sizeof( Vertex );
UINT offset = 0;
d3dDevice->IASetVertexBuffers( 0, 1, &VertexBuffer, &stride, &offset );
d3dDevice->IASetIndexBuffer(IndexBuffer, DXGI_FORMAT_R32_UINT, 0);

//draw skymap based off loaded mesh sphere
fxSkyMapVar->SetResource(smrv);
for( UINT p = 0; p < skymaptechDesc.Passes; ++p )
{
SkyMapTechnique->GetPassByIndex( p )->Apply( 0 );
d3dDevice->DrawIndexed(NumFaces * 3, 0, 0);
}


After that, we will need to set the buffers for the pyramid. Not only set the buffers, but also create a world matrix for the pyramid so that it doesn't use the same world matrix as the sky. Since the pixel shader expects a texture for each object, i also added a line that sends the braynzar logo texture (used on the 3DSphere object) to the shader:

// Create the World matrix (and put in the WVP matrix)
D3DXMatrixScaling( &Scale, 2.0f, 2.0f, 2.0f );
D3DXMatrixTranslation( &Translation, 0.0f, 1.0f, 10.0f );

Transformations = Scale * Translation;

WVP = World * Transformations * View * Projection;
fxWVPVar->SetMatrix((float*)&WVP);

// Bind the pyramids vertex and index buffer
d3dDevice->IASetVertexBuffers( 0, 1, &pyramidVertBuff, &stride, &offset );
d3dDevice->IASetIndexBuffer(pyramidIndexBuff, DXGI_FORMAT_R32_UINT, 0);

//draw pyramid
for( UINT p = 0; p < techDesc.Passes; ++p )
{
// Send a texture to the shader since it's expecting one (otherwise it will use the last texture sent to the shaders
fxDiffuseMapVar->SetResource(TextureResourceViews[0 + meshSubsets[0]]);

Technique->GetPassByIndex( p )->Apply( 0 );
d3dDevice->DrawIndexed(18, 0, 0);
}


So again, you will notice a couple problems with your render. First problem (my fault) is that the sky will look broken. this is because the function that creates the sphere is wrong. To fix this, you can either fix the function (i fixed it in my direct3d 11 lessons in the skymap lesson) or you can just use the 3DSphere loaded form the file. Since the skymap is seamless, you could actually use pretty much any shape, such as your pyramid, or a cube, and you probably won't notice a difference. To fix this fast and use the 3DSphere for the sky instead, just do this:

meshes[1]->DrawSubset(subsetID);
instead of:

d3dDevice->DrawIndexed(NumFaces * 3, 0, 0);

Next problem, is your pyramid. You did not create your vertices with the right texture coordinates and normals, so you will not see the braynzar logo nicely laid across the faces, and the lighting will be messed up. It's not too difficult to fix that though, just takes a little thought when looking at how your vertices are set up.

After all that, I hope i didn't miss anything, if i did, let me know ;)

Share this post


Link to post
Share on other sites
As usual iedoc your tutorials are the best. I have implemented them with no trouble.
Just a point of note.

I had to comment out the draw plane function

/*draw plane
for( UINT p = 0; p < techDesc.Passes; ++p )
{
for(UINT subsetID = 0; subsetID < meshSubsets[0]; ++subsetID)
{
fxDiffuseMapVar->SetResource(TextureResourceViews[subsetID]);
Technique->GetPassByIndex( p )->Apply( 0 );
meshes[0]->DrawSubset(subsetID);
}
}*/



As it causes the application to crash and enter debug mode displaying this message

Unhandled exception at 0x73bcafb5 in d3dtry.exe: 0xC0000005: Access violation reading location 0xcccccccc.
[/quote]

The problem is pointed as being on this line


fxDiffuseMapVar->SetResource(TextureResourceViews[subsetID]
[/quote]

However if i add "+ meshSubsets[1]" (similar to the draw sphere function). It works
but takes the same texture of the sphere (not the ground).


//draw plane
for( UINT p = 0; p < techDesc.Passes; ++p )
{
for(UINT subsetID = 0; subsetID < meshSubsets[0]; ++subsetID)
{
fxDiffuseMapVar->SetResource(TextureResourceViews[subsetID + meshSubsets[1] ] );
Technique->GetPassByIndex( p )->Apply( 0 );
meshes[0]->DrawSubset(subsetID);
}
}


The result is the same whether it is a 0 or 1. Maybe you have a solution to this problem.
Until my next post then. Have a good one.

Share this post


Link to post
Share on other sites
I uncommented the ground, and it worked completely fine for me. my guess is that maybe you don't have the ground.jpg file in the project folder?

Share this post


Link to post
Share on other sites

I uncommented the ground, and it worked completely fine for me. my guess is that maybe you don't have the ground.jpg file in the project folder?


Yes i found the problem.The ground texture is a bmp (not jpg). I changed that in the vertex file and it now works.
Next up is tackling the picking and collision detection tutorials. i will let you know how it goes.Thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net 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!