-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document 3D Abstraction Layer #238
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work overall. Just a few minor quibbles and questions.
src/easy3d.c
Outdated
G3X_AlphaBlend(TRUE); | ||
G3X_EdgeMarking(FALSE); | ||
G3X_SetFog(FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); | ||
G3X_SetClearColor(GX_RGB(0, 0, 0), 0, 0x7fff, 63, FALSE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Would it be useful to mark 0x7FFF
as the maximum value for a RGB15 palette?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 0x7FFF he refers to a depth value, not a color. Point still stands though, a constant would be appropriate. Not sure what to call it though. As far as I know there isn't any constant defined for this in the SDK. G3X_MAX_DEPTH
maybe or G3X_DEPTH_MAX
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like G3X_DEPTH_MAX
.
Documents the 2 levels of 3D abstraction layers in the game. Below a "quick" write-up about the system.
TL;DR: Easy 3D model loading and drawing API.
Abstraction Layers
The lowest level 3D is interacting directly with the hardware via NitroSDK. NitroSystem provides a slight abstraction over this with
G3D
.The game has 2 additional layers of abstraction over this:
1 - Easy3D
The first layer of abstraction is the Easy3D System (
easy3d.h
). Which provides basic functionality for:To elaborate on the last point: Before using any 3D graphics, a "3D Graphics State" must be initialized. The struct for this is currently called
GenericPointerData
. The Easy3D system provides an easy method to set up a simple gfx state viaEasy3D_Init
(WithEasy3D_Shutdown
as its counterpart), which works for most scenarios.2 - Easy3DObject
The second layer of abstraction is
Easy3DObject
(easy3d_object.h
). This API provides a streamlined interface for:One thing to keep in mind is that this system by itself does not establish a 3D GFX State.
This system is also not used everywhere. In a lot of places Easy3D is used directly instead of this object oriented interface.
Example
The following is an example for using the
Easy3DObject
API for:I will be using the Giratina model from the title screen for this.
Loading the data
The first thing needed is some static storage to hold our data:
Next we load all of the data:
This is all that needs to be done in terms of setup, now the model is ready to draw (provided a 3D GFX State has been set up).
Drawing the Model
Before drawing there's a few things that should be configured on the object, one of them being the position of the model obviously. For simplicity's sake I will just set the models position to the player's position.
Now we can actually render the model:
All of that results in the following:
giratina.mp4
Obviously the rotation and resizing is not outlined above. The code for this is the following: