Code Monkey home page Code Monkey logo

d3dx9_solar-system's Introduction

d3dx9_Solar-System

ezgif com-gif-maker

행렬 계산

Untitled-8a6b2297-10f8-4803-b5c0-72e743b3c748

void cPlanet::setMatrix(float speed, D3DXMATRIX _parentMat)
{
	// TRS 행렬 법칙에 따라
	// Scale 행렬 x Rotation 행렬 x Translate 행렬

	switch (this->type) 
	{
		// 태양
	case planetType::p_Sun:
		D3DXMatrixIdentity(&matrix);
		D3DXMatrixScaling(&this->pScalemat, pScale.x, pScale.y, pScale.z);
		D3DXMatrixRotationY(&this->pRotmat, degree++ / (80.0f / speed));
		D3DXMatrixTranslation(&this->pTransmat, this->pPos.x, this->pPos.y, this->pPos.z);
		// SRT 행렬
		matrix = this->pScalemat * this->pRotmat * this->pTransmat;
		break;

		//
	case planetType::p_Moon:
		D3DXMatrixIdentity(&matrix);
		D3DXMatrixScaling(&this->pScalemat, pScale.x, pScale.y, pScale.z);
		D3DXMatrixRotationY(&this->pRotmat, degree++ / (80.0f / speed * 2.0f));
		D3DXMatrixTranslation(&this->pTransmat, pPos.x, pPos.y, pPos.z);
		D3DXMatrixRotationY(&this->pOrbitmat, r_degree++ / (80.0f / speed));

		// SRT 행렬  *  공전행렬  *  부모행렬
		matrix = this->pScalemat * this->pRotmat * this->pTransmat * this->pOrbitmat * _parentMat;
		break;

		// 나머지 행성들
	default:
		D3DXMatrixIdentity(&matrix);
		D3DXMatrixScaling(&this->pScalemat, pScale.x, pScale.y, pScale.z);
		D3DXMatrixRotationY(&this->pRotmat, degree++ / (80.0f / speed * 2.0f));
		D3DXMatrixTranslation(&this->pTransmat, pPos.x, pPos.y, pPos.z);
		D3DXMatrixRotationY(&this->pOrbitmat, r_degree++ / (80.0f / speed));

		// SRT 행렬 * 공전행렬
		matrix = this->pScalemat * this->pRotmat * this->pTransmat * this->pOrbitmat;
		break;
	}

	OnFrameRender();
}

법선 매핑

매핑

void cPlanet::setTexture()
{
	if (SUCCEEDED(D3DXCreateSphere(p_dev, p_radius, mDetail, mDetail, &mesh, NULL)))
	{
		if (SUCCEEDED(mesh->CloneMeshFVF(D3DXMESH_SYSTEMMEM, CVERTEX_NTEX::FVF, p_dev, &temp_mesh)))
		{
			mesh->Release();
		}
	}

	CVERTEX_NTEX* pVerts;

	if (SUCCEEDED(temp_mesh->LockVertexBuffer(0, (void**)&pVerts)))
	{
		int numVerts = temp_mesh->GetNumVertices();

		for (int i = 0; i < numVerts; i++)
		{
			pVerts->tu = asinf(pVerts->normal.x) / D3DX_PI + 0.5f;
			pVerts->tv = asinf(pVerts->normal.y) / D3DX_PI + 0.5f;
			pVerts++;
		}

		temp_mesh->UnlockVertexBuffer();
	}
}

d3dx9_solar-system's People

Contributors

jun-cheol-shin avatar

Stargazers

Soojin Kim avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.