Fixed some issues in the asset builder; User guide work
This commit is contained in:
1 parent
a85f77c023
commit
f2bd6e457a
15 files changed
+150
-51
No files matched your search
@@ -44,11 +44,10 @@ project (`NFApp` by default), can be renamed at any time.
|
||||
|
||||
@note The template project is setup to build *Debug* and *Release* configurations. The *Debug*
|
||||
configuration includes a console window with debug output. The *Release* configuration does
|
||||
not have this console window. By default, the current configuration can be changed in the
|
||||
top toolbar.
|
||||
not have this console window, and will run as fast as possible with maximum optimizations.
|
||||
By default, the current configuration can be changed in the top toolbar.
|
||||
|
||||
Once the solution has been opened, you can find the `main.cpp` file inside the `src` folder
|
||||
as shown below.
|
||||
Once the solution has been opened, you can find the `main.cpp` file inside the `src` folder:
|
||||
|
||||
@image html blanktemplate.png "The template opened in Visual Studio" width=70%
|
||||
|
||||
@@ -57,7 +56,7 @@ your assets. You can also also hit the default keyboard shortcut of `Ctrl-Shift-
|
||||
both your app and assets.
|
||||
|
||||
@note When the "Build Assets" project is built, the resulting NFPacks are moved to
|
||||
the output `assets` directory next to your .exe for you.
|
||||
the output `assets` directory next to your `.exe` for you.
|
||||
|
||||
NF is a **statically-linked** library. This means that your build will not
|
||||
rely on any external dlls other than the MSVC redistributable.
|
||||
rely on any external dlls other than the MSVC redistributable. See @ref packagingTut.
|
||||
@@ -15,13 +15,15 @@ main thread of an NF app might be typically doing in the program's lifetime.
|
||||
|
||||
@image html applifetime.png "The lifetime of a typical NF app" width=20%
|
||||
|
||||
Using the engine's architecture, you might not even write any functions that are called
|
||||
Using this architecture, you might not even write any functions that are called
|
||||
from `main`. Most of the code that programs the engine's behavior should be called in
|
||||
your state's [update function](@ref nf::Gamestate::update).
|
||||
|
||||
To allow a translate unit to use the engine, you must include `NothinFancy.h`. This
|
||||
header contains every class and function you will need.
|
||||
|
||||
---
|
||||
|
||||
@section createConfigTut Creating a Config
|
||||
|
||||
The first step to creating an app is creating an nf::Config. A config describes how the
|
||||
@@ -51,7 +53,7 @@ We then pass this config to an nf::Application
|
||||
@section createAppTut Creating and Configuring an Application
|
||||
|
||||
The nf::Application class represents an instance of the engine. This is the point where
|
||||
you will attach your states and run the engine.
|
||||
you will attach your states and run your application.
|
||||
|
||||
@note In a program and on a single machine, there can only be one single instance of
|
||||
this class at a time. Attempting to create mulitple will result in an error.
|
||||
@@ -63,7 +65,7 @@ nf::Application app(conf);
|
||||
~~~
|
||||
|
||||
Constructing an application doesn't do much. It merely allows you to access the member
|
||||
functions to setup your application.
|
||||
functions to setup your application and run it later.
|
||||
|
||||
Here are some functions you might want to call at this point:
|
||||
|
||||
@@ -85,7 +87,7 @@ Once these functions have been called, the app can be run:
|
||||
|
||||
~~~cpp
|
||||
CustomGamestate* customState = new CustomGamestate; //Inherits nf::Gamestate
|
||||
app.addState(customState, "State 1"); //"State One" is this state's identifier.
|
||||
app.addState(customState, "State 1"); //"State 1" is this state's identifier.
|
||||
app.setDefaultState("State 1"); //Will error without this
|
||||
app.run(); //Blocks until exit
|
||||
~~~
|
||||
@@ -422,6 +424,18 @@ sound.setPosition(nf::Vec3(10.0, 25.0, 15.0));
|
||||
sound.setEntity(entity2);
|
||||
~~~
|
||||
|
||||
@section gamestateSwitchTut Switching Gamestates
|
||||
|
||||
To unload the current state and load another state, call:
|
||||
|
||||
~~~cpp
|
||||
app->changeState("State 2"); //String identifier we defined earlier
|
||||
~~~
|
||||
|
||||
@note The currently running state that calls [changeState](@ref nf::Application::changeState)
|
||||
does not stop running right away. The `update` and `render` functions of that state are called
|
||||
until the loading screen fades in completely.
|
||||
|
||||
@section debuggingTut Debugging Your App
|
||||
|
||||
NF has a number of @ref macros that you can use in your debug builds to help you develop
|
||||
@@ -447,5 +461,6 @@ Other than that, a build can be very simple:
|
||||
- **NFApp.exe** - The application binary which is named from the MSVC project
|
||||
- **assets** - The folder which holds your NFPacks
|
||||
- **base.nfpack** - The NFPack that holds both critical and default assets
|
||||
- **Your Assets** - The rest of the NFPacks your application needs
|
||||
|
||||
These are the only files you need to package in your build.
|
||||
+82
-1
@@ -28,6 +28,8 @@ function while passing in the name of the pack, including the extension.
|
||||
5. Call the [get](@ref nf::AssetPack::get) function with the name of the asset file
|
||||
to retrieve an Asset pointer to use in various `create` functions.
|
||||
|
||||
---
|
||||
|
||||
@section customModels Models
|
||||
|
||||
To import a custom model into NF, it must first meet some requirements:
|
||||
@@ -91,10 +93,89 @@ Used in the tutorial app, our model looks like this:
|
||||
|
||||
@image html custommodel.png "Our teapot in the engine" width=50%
|
||||
|
||||
---
|
||||
|
||||
@section customFonts Fonts
|
||||
|
||||
Custom fonts can be implemented very easily. All you need to do is include a TrueType
|
||||
`.ttf` font in your assets and reference it when you create texts:
|
||||
|
||||
~~~cpp
|
||||
text.create("Cool Font", nf::Vec2(0.1, 0.2), nf::Vec3(1.0f), 1.0f, 1.0f, ap.get("font.ttf"));
|
||||
~~~
|
||||
|
||||
@image html customfont.png "A text using the font \"Corsiva\"" width=30%
|
||||
|
||||
---
|
||||
|
||||
@section customButtons Button Textures
|
||||
|
||||
The default button textures can be overridden by adding textures with certain names
|
||||
to your assets where "name" can be anything you choose as an identifier.
|
||||
|
||||
- **name_buttonidle** - The texture that shows when the button is idle
|
||||
- **name_buttonhover** - The texture that shows when the mouse hovers over the button
|
||||
- **name_buttonpressed** - The texture that shows when the button clicked
|
||||
|
||||
These images can be of any accepted image format. They should all have the same dimensions.
|
||||
|
||||
@warning If a button texture set is incomplete, the engine will error when it reads the
|
||||
NFPack.
|
||||
|
||||
Once the textures are in place, they can be accessed in your nf::AssetPack like
|
||||
this:
|
||||
|
||||
~~~cpp
|
||||
//Text can still be added on top, but I already have text on my texture, so I'll leave it blank.
|
||||
button.create(nf::Vec2(0.1, 0.1), "", ap.get("name.button"));
|
||||
~~~
|
||||
|
||||
With these three textures:
|
||||
|
||||
@image html examplebuttonidle.png "Idle" width=20%
|
||||
@image html examplebuttonhover.png "Hover" width=20%
|
||||
@image html examplebuttonpressed.png "Pressed" width=20%
|
||||
|
||||
We get this result:
|
||||
|
||||
@htmlonly
|
||||
|
||||
<video src="buttondemo.mp4" autoplay loop muted width=50%>
|
||||
|
||||
@endhtmlonly
|
||||
|
||||
---
|
||||
|
||||
@section customCubemaps Cubemaps
|
||||
|
||||
@section customSounds Sounds
|
||||
Cubemaps are like button textures. Each cubemap consists of 6 textures that are mapped
|
||||
to the inside of a giant, unreachable cube in your scene. The engine takes care of rendering
|
||||
it. All you need to do is supply these 6 textures in your assets with specific filenames.
|
||||
Here, "name" can be anything you choose as an identifier.
|
||||
|
||||
- **name_cmfront** - The front texture (-Z direction)
|
||||
- **name_cmback** - The back texture (+Z direction)
|
||||
- **name_cmright** - The right texture (+X direction)
|
||||
- **name_cmleft** - The left texture (-X direction)
|
||||
- **name_cmtop** - The top texture (+Y direction)
|
||||
- **name_cmbottom** - The bottom texture (-Y direction)
|
||||
|
||||
Once the textures are in place, they can be accessed in your nf::AssetPack like
|
||||
this:
|
||||
|
||||
~~~cpp
|
||||
cubemap.create(ap.get("name.cm"));
|
||||
~~~
|
||||
|
||||
---
|
||||
|
||||
@section customSounds Sounds
|
||||
|
||||
Sounds are the easiest to include.
|
||||
|
||||
All you need to do is place the sound file in your assets and reference it by name
|
||||
when creating an nf::Sound object:
|
||||
|
||||
~~~cpp
|
||||
sound.create(ap.get("sound.ogg"));
|
||||
~~~
|
||||
+4
-3
@@ -1,8 +1,9 @@
|
||||
@tableofcontents
|
||||
|
||||
Nothin' Fancy (abbreviated as NF) is an experimental 3D game engine written in C++
|
||||
for Windows. It was created by Grayson Riffe in 2021. This manual aims to aid the end-user
|
||||
with using this engine to create games and visualizations. It contains the
|
||||
for Windows. The engine allows the user to program 3D applications with high-level
|
||||
C++. NF was created by Grayson Riffe in 2021. This manual aims to aid the user
|
||||
with using NF to create games and visualizations. It contains the
|
||||
[user guide](tutorial.html) and the [API reference](namespaces.html).
|
||||
|
||||
@image html logofull.png "Engine Logo" width=15%
|
||||
@@ -25,7 +26,7 @@ at any time.
|
||||
- Customizable UI
|
||||
- Text
|
||||
- Textures
|
||||
- Buttons also with customizable textures
|
||||
- Buttons with customizable textures
|
||||
|
||||
Example App
|
||||
===
|
||||
|
||||
Reference in new issue
Block a user