Space Environment

Started by
28 comments, last by jason83 19 years, 8 months ago
I disabled culling, so this shouldnt make any difference :S but still cant see anything. It must be a lighting problem then. If i disable lighting, i can see the sphere but not the texture and i dont see anything when i move the camera inside the cube.
Advertisement
is the skybox texture being loaded and set properly?
bool Setup() //Setup SkyBox & Lights Etc{	Device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);	HRESULT hr = 0;	hr = D3DXCreateSphere(		Device,		1.0f,		60,		60,		&Mesh,		0);	if(FAILED(hr))	{		::MessageBox(0, "D3DXCreateMesh() - FAILED", 0, 0);		return false;	}hr = D3DXCreateTextureFromFile(		Device,		"texture.jpg",		&Tex);	if(FAILED(hr))	{		::MessageBox(0, "D3DXCreateTexture() - FAILED", 0, 0);		return false;	}		Device->SetTexture(0,Tex);	Device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);	Device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);	Device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);	// 	// Set Lights.	//	D3DLIGHT9 light;	::ZeroMemory(&light, sizeof(light));	light.Type      = D3DLIGHT_DIRECTIONAL;	light.Ambient   = d3d::WHITE;	light.Diffuse   = d3d::WHITE;	light.Specular  = d3d::BLACK;	light.Direction = D3DXVECTOR3(0.0f, 0.0f, 0.0f);	Device->SetLight(0, &light);	Device->LightEnable(0, true);	Device->SetRenderState(D3DRS_NORMALIZENORMALS, true);	Device->SetRenderState(D3DRS_SPECULARENABLE, true);	//	// Set camera.	//	D3DXVECTOR3 pos(0.0f, 0.0f, 0.1f);	D3DXVECTOR3 target(0.0f, 0.0f,  1.0f);	D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);	D3DXMATRIX V;	D3DXMatrixLookAtLH(		&V,		&pos,		&target,		&up);	Device->SetTransform(D3DTS_VIEW, &V);	//	// Set projection matrix.	//	D3DXMATRIX proj;	D3DXMatrixPerspectiveFovLH(			&proj,			D3DX_PI * 0.5f, // 90 - degree			(float)Width / (float)Height,			1.0f,			1000.0f);	Device->SetTransform(D3DTS_PROJECTION, &proj);	return true;} //End of Setupbool Display(float timeDelta){	if( Device ) // Only use Device methods if we have a valid device.	{		//		// Render		//		Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xfffffff, 1.0f, 0);		Device->BeginScene();		Device->SetMaterial(&d3d::WHITE_MTRL);		Device->SetTexture(0, Tex);		Mesh->DrawSubset(0);		Device->EndScene();		Device->Present(0, 0, 0, 0);	}	return true;}


[The Display method is called from the WinMain function]

This is a small bit of code. Not all references are declared.

Edited by Coder: source tags

[Edited by - FMDGames on August 4, 2004 4:17:12 PM]
The reason you can't see the inside of the sphere is because polygons are one-sided. They're only solid on one side. If you look at a polygon from the rear, it's invisible.

I can't see where you're loading or rendering your cube. Did you leave that part out?

To turn off backface culling, use this:
Device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

Ryan Buhr

Technical Lead | Sector 13

Reactor Interactive, LLC

Facebook | Twitter

Its most likey the fact im using D3DXCreateSphere()... I couldnt get it to work on the cube either... I tried it on a sphere my 3d artist created and it textured it, but only on the outside and not on the inside. Only thing changed was the mesh was loaded instead of created.
The reason your generated sphere isn't textured is because the D3DXCreateSphere() function creates a mesh using the D3DFVF_XYZ | D3DFVF_NORMAL FVF - there are no texture coordinates generated, so a texture won't be used on these vertices.

Again, your artist is going to need to flip the normals on the cube or sphere or whatever, or else you will not be able to see the object from the inside.

Ryan Buhr

Technical Lead | Sector 13

Reactor Interactive, LLC

Facebook | Twitter

He did try, but he cant seem to work it out. Two of the spheres he sent me i could see outside, two of the spheres i couldnt see outside. But i cant see any on the inside :S. My guess is it must be a lighting problem.
More than likely, if it was a lighting problem, you wouldn't be able to see any meshes ever. What program are you using to create your meshes? What format are you loading them into your application in?

Ryan Buhr

Technical Lead | Sector 13

Reactor Interactive, LLC

Facebook | Twitter

My 3D Artist is using Maya, exporting into the X Format
Quote:Original post by HanSoL0
Check out the video of my game to see how this works.


Nice trailer. That's very similar to what my little space game was supposed to be like (but mine is way more stripped down) but I just can't seem to get my spaceship and camera to behave nicely together like yours. :(

This topic is closed to new replies.

Advertisement