Example #1
0
//塵の描画
void draw_Dust() {
	substance *sub = dust.getSub();
	substance *p = player.getSub();
	//乱数を時刻ごとに決める

	//塵の座標をランダムに決めるために、乱数を設定
	unsigned int seed = int(rand() % 1000 + 1);
	srand(0);

	//float range = 20.0f;		  
	int range = 1000;
	for (int i = 0; i < dust.getSize(); i++) {
		//遠くのものは点で描画
		sub[i].x = (float)GetRandom(-DUST_RANGE, DUST_RANGE);
		sub[i].y = (float)GetRandom(-DUST_RANGE, DUST_RANGE);
		sub[i].z = (float)GetRandom(-DUST_RANGE, DUST_RANGE);
		DrawPixel3D(VGet(sub[i].x, sub[i].y, sub[i].z), GetColor(255, 255, 255));

		//近くのものは線で描画 
		sub[i].x = (float)GetRandom(0, DUST_RANGE);
		sub[i].y = (float)GetRandom(0, DUST_RANGE);
		sub[i].z = (float)GetRandom(0, DUST_RANGE);
		sub[i].x = modulo(-p[0].x + sub[i].x, (float)range) - range * 0.5f;
		sub[i].y = modulo(-p[0].y + sub[i].y, (float)range) - range * 0.5f;
		sub[i].z = modulo(-p[0].z + sub[i].z, (float)range) - range * 0.5f;
		DrawLine3D(VGet(sub[i].x, sub[i].y, sub[i].z), 
			VGet(sub[i].x - p[0].vx * (range * 0.001f) + 0.001f, 
			sub[i].y - p[0].vy * (range * 0.001f), 
			sub[i].z - p[0].vz * (range * 0.001f)), 
			GetColor(255, 255, 255));
	}

	srand(seed);
}
Example #2
0
void BatchRenderer::DrawCube( const float4x4& worldMatrix, const FColor& color )
{
	static const XMVECTOR verts[8] =
    {
        { -1, -1, -1, 0 },
        { 1, -1, -1, 0 },
        { 1, -1, 1, 0 },
        { -1, -1, 1, 0 },
        { -1, 1, -1, 0 },
        { 1, 1, -1, 0 },
        { 1, 1, 1, 0 },
        { -1, 1, 1, 0 }
    };
	const UINT* edgeIndices = AABB::GetEdges();

    // copy to vertex buffer
    //assert( 8 <= MAX_VERTS );

	XMFLOAT3 transformedVerts[8];
	for( int i=0; i < 8; ++i )
	{
		XMVECTOR v = XMVector3Transform( verts[i], worldMatrix );
		XMStoreFloat3( &transformedVerts[i], v );
	}

	for( int iEdge = 0; iEdge < AABB::NUM_EDGES; iEdge++ )
	{
		XMFLOAT3 & start = transformedVerts[ edgeIndices[iEdge*2] ];
		XMFLOAT3 & end = transformedVerts[ edgeIndices[iEdge*2 + 1] ];
		DrawLine3D( as_vec3(start), as_vec3(end), color, color );
	}
}
Example #3
0
	virtual void Draw() const
	{
		DrawLine3D(
			m_pt1.x, m_pt1.y, m_pt1.z,
			m_pt2.x, m_pt2.y, m_pt2.z,
			m_nColor1, m_nColor2, m_fWidth);
	}
Example #4
0
void BatchRenderer::DrawGrid( const Vec3D& XAxis, const Vec3D& YAxis, const Vec3D& Origin, int iXDivisions, int iYDivisions, const FColor& color )
{
//	HRESULT hr;

	iXDivisions = Max( 1, iXDivisions );
	iYDivisions = Max( 1, iYDivisions );

	// build grid geometry
//	INT iLineCount = iXDivisions + iYDivisions + 2;
	//assert( (2*iLineCount) <= MAX_VERTS );

	XMVECTOR vX = XMLoadFloat3( &as_float3(XAxis) );
	XMVECTOR vY = XMLoadFloat3( &as_float3(YAxis) );
	XMVECTOR vOrigin = XMLoadFloat3( &as_float3(Origin) );

	for( INT i = 0; i <= iXDivisions; i++ )
	{
		FLOAT fPercent = ( FLOAT )i / ( FLOAT )iXDivisions;
		fPercent = ( fPercent * 2.0f ) - 1.0f;
		XMVECTOR vScale = XMVectorScale( vX, fPercent );
		vScale = XMVectorAdd( vScale, vOrigin );

		XMVECTOR vA, vB;
		vA = XMVectorSubtract( vScale, vY );
		vB = XMVectorAdd( vScale, vY );

		DrawLine3D( as_vec4(vA).ToVec3(), as_vec4(vB).ToVec3(), color, color );
	}

//	INT iStartIndex = ( iXDivisions + 1 ) * 2;
	for( INT i = 0; i <= iYDivisions; i++ )
	{
		FLOAT fPercent = ( FLOAT )i / ( FLOAT )iYDivisions;
		fPercent = ( fPercent * 2.0f ) - 1.0f;
		XMVECTOR vScale = XMVectorScale( vY, fPercent );
		vScale = XMVectorAdd( vScale, vOrigin );
		
		XMVECTOR vA, vB;
		vA = XMVectorSubtract( vScale, vX );
		vB = XMVectorAdd( vScale, vX );

		DrawLine3D( as_vec4(vA).ToVec3(), as_vec4(vB).ToVec3(), color, color );
	}
}
Example #5
0
void BatchRenderer::DrawInfiniteGrid( const Vec3D& eyePos, FLOAT height, const FColor& color )
{
	const FLOAT gridHalfSizeX = 100.0f, gridHalfSizeZ = 100.0f;
	const UINT numGridCells = 50;
	const FLOAT invNumGridCells = 1.0f / numGridCells;
	const FLOAT dx = gridHalfSizeX * 2 * invNumGridCells;
	const FLOAT dz = gridHalfSizeZ * 2 * invNumGridCells;

	//Vec3D gridCenter(
	//	mxSnapFloat( eyePos.x, invNumGridCells ),
	//	height,
	//	mxSnapFloat( eyePos.z, invNumGridCells )
	//);

	// Set start position.

	FLOAT x = -gridHalfSizeX;
	FLOAT z = -gridHalfSizeZ;

	for( int i = 0; i < numGridCells; i++ )
	{
		DrawLine3D(
			x, height, -gridHalfSizeZ,
			x, height,  gridHalfSizeZ,
			color, color
		);
		x += dx;
	}
	for( int i = 0; i < numGridCells; i++ )
	{
		DrawLine3D(
			-gridHalfSizeX, height,  z,
			+gridHalfSizeX, height,  z,
			color, color
		);
		z += dz;
	}
}
Example #6
0
void BatchRenderer::DrawTriangle3D(
	const Vec3D& a, const Vec3D& b, const Vec3D& c,
	const FColor& color
)
{
#if 0
	DrawLine3D( a, b, color, color );
	DrawLine3D( b, c, color, color );
	DrawLine3D( c, a, color, color );
#else
	SetBatchState( this, D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP );

	Vertex & v0 = self->batchedVertices.Add();
	Vertex & v1 = self->batchedVertices.Add();
	Vertex & v2 = self->batchedVertices.Add();
	Vertex & v3 = self->batchedVertices.Add();

	v0.xyz.x 	= a.x;
	v0.xyz.y 	= a.y;
	v0.xyz.z 	= a.z;
	v0.rgba.asU32 	= color.ToRGBA32();

	v1.xyz.x 	= b.x;
	v1.xyz.y 	= b.y;
	v1.xyz.z 	= b.z;
	v1.rgba.asU32 	= color.ToRGBA32();

	v2.xyz.x 	= c.x;
	v2.xyz.y 	= c.y;
	v2.xyz.z 	= c.z;
	v2.rgba.asU32 	= color.ToRGBA32();

	v3.xyz.x 	= a.x;
	v3.xyz.y 	= a.y;
	v3.xyz.z 	= a.z;
	v3.rgba.asU32 	= color.ToRGBA32();
#endif
}
Example #7
0
void BatchRenderer::DrawCircle( const Vec3D& origin,const Vec3D& vX,const Vec3D& vY, const FColor& color, FLOAT radius, INT numSides )
{
	FLOAT	fAngleDelta = MX_TWO_PI / (FLOAT)numSides;
	Vec3D	vPrevVertex = origin + vX * radius;

	for( INT iSide = 0; iSide < numSides; iSide++ )
	{
		Vec3D	v = origin +
			(vX * mxCos(fAngleDelta * (iSide + 1)) + vY * mxSin(fAngleDelta * (iSide + 1))) * radius;

		DrawLine3D(vPrevVertex,v,color,color);

		vPrevVertex = v;
	}
}
Example #8
0
	void draw(const Color &color)
	{
		DrawLine3D(pos[0], pos[1], color);
	}