Rendering a 3D Scene?
June 12, 2009 02:51PM
I really need some help here guys. I've been looking over tutorials, namely the NeHe tutorials and trying to cross them over from OpenGL to GX. However, I'm still having problems creating a 3D scene. Basically, all I want to do at this point is create:

1 Floor
1 Skybox
4 Walls

I'm not sure what I'm doing wrong. Here is my function for drawing my floor:

// Create the floor
void DrawFloor() {
	GX_Begin(GX_QUADS, GX_VTXFMT1, 4);
		GX_Normal3f32(0.0, 1.0, 0.0);			// Normal pointing up
		GX_TexCoord2f32(0.0f, 1.0f);			// Bottom-left of texture
		GX_Position3f32(-2.0, 0.0, 2.0);		// Bottom-left corner of floor
		GX_TexCoord2f32(0.0f, 0.0f);			// Top-left of texture
		GX_Position3f32(-2.0, 0.0, -2.0);		// Top-left corner of floor
		GX_TexCoord2f32(1.0f, 0.0f);			// Top-right of texture
		GX_Position3f32(2.0, 0.0, -2.0);		// Top-right corner of floor
		GX_TexCoord2f32(1.0f, 1.0f);			// Bottom-right of texture
		GX_Position3f32(2.0, 0.0, 2.0);			// Bottom-right corner of floor
	GX_End();
}

Is there an easier way to going about drawing a scene? Or do I have to do the entire scene like the above? I know there's something wrong with my code above, because it's not displaying on the screen. I've been at this damn 3D rendering for a few months, and I haven't really gotten anywhere. Can someone point me in a better direction?

Here is a screenshot of the scene I'm going for: 3D Scene Screenshot

EDIT: One more question...would it be easier to create a 3D scene using something like 3DSMax, export it to something like MD2 and load from SD? If so, what would be the best format to use? MD2?



Edited 2 time(s). Last edit at 06/12/2009 03:36PM by RazorChrist.
Re: Rendering a 3D Scene?
June 12, 2009 05:19PM
This function is only used to render something (in that specific case, a textured quad) but you also need to setup a few things like camera position, projection matrix, viewport, etc...
The fact it does not display anything could be due to a lot of things: it could be the camera not configured properly, the rendered scene not copied to video output, etc... there is no way this little code snippet could help anybody to tell you what's wrong ...

If you are already familiar with OpenGL, this should not be too difficult to use the GX functions to setup the environment, they are very similar Some of Nehe's tutorials have been also ported for libogc if that matters.

Finally, If you want something "easier", you probably mean a library which encapsulates all these low-level GX functions into more user-friendly routines ... unfortunately, I don't think such thing exist for homebrew devs at the moment.



Edited 1 time(s). Last edit at 06/12/2009 05:20PM by ekeeke.
Re: Rendering a 3D Scene?
June 13, 2009 10:39AM
I'm using NeHe's tutorials as a starting template for my code, then adding in the objects as I go. I didn't change anything of NeHe's code, just added mine in.
Re: Rendering a 3D Scene?
June 13, 2009 06:45PM
I think you are not positionning the vertices correctly in space regarding the default camera position, making them not visible in the rendered scene.
I also think the order of texture coordinates and their relation to one vertice position is important... unfortunately, I always proceeded using test&retry until I got something on screen because I was not sure of GX drawing restrictions & conventions...

If I were you I would try to first catch the difference between your code and the original one...
Re: Rendering a 3D Scene?
June 24, 2009 01:10PM
There is a library for rendering 3D scenes
It's still buggy and pretty basic but it works
It's revolution engine, you can check it here
it lets you creating textured objects in 3D space and playing around with them (moving, rotating, ...)
Version 0.4 is suposed to be released this summer, but by now you can use 0.3
However, if you don't want to use the library, you can check it's source code as an example on how to use GX
Re: Rendering a 3D Scene?
June 24, 2009 03:25PM
I think, but i'm not sure, Wii needed 4 GX_Normal3f32

Lasouze
Re: Rendering a 3D Scene?
June 24, 2009 04:15PM
@ technik - I had an older release of the src, but never compiled it. I'll download the latest and check it out. It sounded promising when I first got it, but never had the time to check it out.

Edit: By the way, I got it compiled and starting to edit REVmain.c but had some questions. I posted a topic in the Revolution forum. Thanks for the engine technik, I think it'll work great once I figure out how to use the code.

@ Lasouze - I'll try adding the GX_Normal3f32's in and see if that helps.

Thanks for the help guys, starting to get frustrated.



Edited 5 time(s). Last edit at 06/24/2009 05:20PM by RazorChrist.
Re: Rendering a 3D Scene?
June 24, 2009 06:52PM
Quote
lasouze
I think, but i'm not sure, Wii needed 4 GX_Normal3f32

Correct. Wii also expects the data in the order: position, normal, texture.
Sorry, only registered users may post in this forum.

Click here to login