12-22-2010, 09:45 PM
(This post was last modified: 09-19-2017, 03:32 AM by DerVVulfman.)
RMXP : H-Mode7 Engine
Version: 1.4.4
Version: 1.4.4
Introduction
This engine is an alternative to the NeoMode7 engine.
While the purpose of the NeoM7 is to emulate the Mode7 feature of the NES, this new engine go further in the 3D feeling.
The main cause of negative feedbacks regarding the NeoM7 is that the map seems too flat, like a paper sheet.
The HM7 engine is a response to these critics. It handles heightmaps so that the rendered map is embossed.
The relief is not very pronounced, so this engine is more suited for worldmaps-like maps, where graphical elements are small.
The script might be hard to master, because it requires specific graphics and it is important to understand how the elements are drawn to create them properly.
Therefore this script is not suited for RM beginners.
Features
- more 3D, more lag (don't even try this engine if you find the NeoM7 too laggy)
- adjustable slant angle
- 360° rotation
- zoom in, zoom out
- animated autotiles
- probably a throng of bugs since it's the first version
- works with 200 * 200 tiles² maps (HM7 won't activate if the width or height exceeds 200 tiles)
- open source code for the required dll now available
V1.2 :
- fixed transparency end blend types for events
- heightmaps are now in a "Heightmap" folder
- it's a new DLL (the script won't work with a previous version)
V1.2.1 :
- added an option to have less black cut elements, but it may lag. A lot.
- it's a new DLL (the script won't work with a previous version)
V1.2.2 :
- fixed a bug when transferring from a normal map to a HM7 map.
V1.3 :
LOOK AT THE BOTTOM OF THIS THREAD
V1.3.1 :
- fixed a bug with angles around 35° (DLL modified).
V1.3.2 :
- fixed a bug about the altitude of events that are not "Wall" events (DLL modified).
V1.4 :
- can now handle n layers (but the more layers, the more lag).
V1.4.1 :
- fixed the problem of events disappearing at the bottom of the screen.
V1.4.2 :
- fixed a very annoying bug in V.1.4 : crash when going back to the map (from the menu, a battle, etc.)
- added a camera option [C3] to have the player in the center of the map
V1.4.3 :
- fixed black areas on events at the bottom of the map
- fixed the camera option [C3]
V1.4.4 :
- fixed two bugs causing crash in the DLL
Screenshots
Download link
HERE (Script + DLL - V1.4)
and
The DLL's source code
How does it work ?
This script modifies a Bitmap object that represents the screen.
It's a 640*480/480*360/320*240 Bitmap object (depending on the chosen resolution),
contained in a sprite that is displayed over the panorama but below all other sprites.
For each pixel of this bitmap is calculated a corresponding map pixel to display, by a 3D projection of a textured polygon (the map).
Then a vertical offset is determined depending on the slant, the ground heightmaps and the tiles heightmaps for the three layers.
All the pixels between the original position and its offset are drawn : that makes the map "embossed".
Heightmaps :
A heightmap is a greyscale picture that contains heights data for each pixel.
Black areas mean no height offset, whereas white areas mean a maximum height offset.
The maximum height offset has a fixed value of 32 pixels, so a tile with an entirely white heightmap will be rendered as a cube.
- ground heightmap
You can associate a heightmap to a RMXP map (optionnal) that will be used to add an embossing effect independently to the 3-layers tiles.
The heightmap is automatically stretched to the dimensions of the RMXP map, by using a linear interpolation.
Ground heightmaps files, named "Heightmap_XXX" (XXX representing an identification number), shall be placed in the "Pictures" folder.
- tiles heightmaps
They are gathered into a set similar to the map tileset. A "heightmapset", named "[tileset name]_Hmap" and placed in the "Tilesets" folder, is mandatory for each tileset used in a HM7 map.
- autotiles heightmaps
It is the same system here. A heightmap that corresponds graphically to the autotile file, named "[autotile name]_Hmap", can be placed in the "Autotiles" folder (it's optionnal).
Is there an easy way to create heightmaps ?
Nope.
For simple patterns you can use your favorite image manipulation program.
For more complex objects, a solution is to use a 3D modeler, then apply a gradient texture and retrieve a top view picture.
Vertical textures :
By default, when drawing a screen pixel, all pixels between the "ground" (altitude 0) and the computed altitude are filled with the color of the target pixel.
When the slope is too important (vertical walls, by example), it is inelegant :
To solve this problem, you can use a texturemap per tile : it is a picture composed of five 32*32 px² areas : a colormap and four different vertical textures (one for each side).
The colormap is a four-color area (red, green, blue, black) that coincide with the tile : for a screen pixel, when the source pixel of the map is determined, the correponding pixel on the colormap
indicates which vertical texture shall be applied (Red => first texture, Green => second texture, Blue => third texture, Black => fourth texture).
A transparent pixel in a texturemap means that the color of the source pixel of the map will be used.
Texturesets must be placed in a "Tilesets/[tileset name]_Textures" folder, and must be named "Texture_[tile index]".
The tile index represents its position in the tileset (the first index is 0).
NEW (01/01/2011) : DerVVulman's help file for textures : Help file
- autotiles textures
There is only one colormap for all autotiles, named "Texture_Auto". It must be placed in a "Autotiles/Textures" folder (it is mandatory).
Texturesets, containing only the four vertical textures, must also be placed in that folder. They must be named "Texture_[autotile name]".
Misc :
- The automatic lighting effect is not adjustable for the moment (but you can deactivate it). That means that shadows have always the same orientation and length.
- As character sprites are always above the HM7 sprite, they are not used to display characters (otherwise characters could not be behind map elements).
Characters are rendered directly in the HM7 bitmap, and thus there are limitations : transparency and blend type are ignored.
- By default characters are drawn at the maximal altitude of their coordinates : ground + 3 layers.
You can activate the bush flag in the tilesets tab of the database to have the altitude of the tile ignored when drawing characters.
Instructions
What is required :
- the script (above main, as usual)
- the file MGC_Hmode7.dll at the root of your project
- specific autotiles, tilesets, textures and heightmaps
To activate the H-Mode7, you must add [HM7] to the map name.
The following tags are optionnal :
[HMAPXXX] : XXX is the identifier of the ground heightmap that must be used for the map
[#XX] : XX is the angle of slant (in degree) : 0 -> 80, 0 by default
[%XXX] : XXX is the angle of rotation (in degree) : 0 -> 359, 0 by default
[X] : enable horizontal map looping
[Y] : enable vertical map looping
[DA] : deactivate animated autotiles
[AFXXX] : XXX is the animations period for animated autotiles : 1 -> 999, 20 frames by default
[DL] : deactivate automatic lighting effects
[RX] : X = 1 -> high resolution (default)
X = 2 -> medium resolution (to increase performance)
X = 3 -> low resolution (to drastically increase performance)
[CX] : X = 0 -> no vertical offset (default)
X = 1 -> vertical offset so that the camera do not cut the ground at the bottom of the screen.
Should be used only when the horizon is visible.
X = 2 -> vertical offset so that the camera do not cut the map at the bottom of the screen.
Should be used only when the horizon is visible.
X = 3 -> vertical offset so that the player is always in the center of the screen.
[DF] : deactivate the filter (better quality, drastically decrease performance)
[HF] : refresh the map every two frames (less fluent, increase performance)
[E] (V.1.2.1) : edmhotta's request to have less cut elements at the bottom of the screen. May cause massive lag, especially when rotating.
[DB] (V.1.2.1) : cut elements at the bottom of the screen are not filled with black (but they're still cut).
You can also associate a keyword to a configuration at the beginning of the script.
For example, with the following command :
HM7::Maps_Settings["MyKeyword"] = ["#60", "X", "HMAP3"]
if a map name contains "MyKeyword", then the HM7 will be activated, with a slant angle of 60 degrees, horizontal looping,
and using the picture "Heightmap_003" as ground heightmap.
Commands
- To set a new angle of slant (0~80) :
$scene.hm7_set_alpha(new angle)
To slide progressively into a new angle of slant :
$scene.hm7_to_alpha(new angle, speed)
To increase/decrease the slant :
$scene.hm7_increase_alpha(value)
- To set a new angle of rotation (0~379) :
$scene.hm7_set_theta(new angle)
To slide progressively into a new angle of rotation :
$scene.hm7_to_theta(angle, speed, dir)
To increase/decrease the angle of rotation :
$scene.hm7_increase_theta(value)
- To set a new zoom level (in percentage - default = 100) :
$scene.hm7_set_zoom(new value)
To slide progressively into a new zoom level :
$scene.hm7_to_zoom(value, speed)
To increase/decrease the zoom level :
$scene.hm7_increase_zoom(value)
- To change the horizon light fading :
$scene.hm7_set_fading(red, green, blue, flag)
flag = 1 : the color determined by (red, green, blue) will be added to the horizon line
flag = 0 : the color determined by (red, green, blue) will be substracted to the horizon line
- To set the altitude of an event :
add a comment in the commands list with : "Altitude X", where X is the
height value ("Altitude 64" will draw the event 64 pixels above its original position)
- To set the altitude of the player :
use : $game_player.altitude = X
- To have a fixed altitude for an event (not dependant on the maps heights) :
add the comment "Floating" in the commands list
- To have a fixed altitude for the player :
use : $game_player.floating = true
VERSION 1.3 :
- "wall" events : the class HM7::Surface has some major changes, and the DLL part is entirely rewritten.
Add a comment "Wall" in the commands list (and check the "Direction Fix" flag) :
You can specify the angle with the comment "Angle XX", where XX is an angle value in degree.
Example : "Angle 30 "
By default, the character is drawn on the center of the tile.
You can specify new coordinates for the middle of the character with the comment "Pos X Y", where X and Y are respectively the horizontal and vertical positions in pixels (between 0 and 32 -default values are X=16 andY=16-)
Example : nothing specified then "Pos 32 0"
- animated vertical textures : use a picture with a width of n * 160px (or 128px for autotiles) for the vertical texture.
example (normal then auto) :
- lower resolutions handling : for those who use smaller resolutions (PSPDS users, for example), you can now specify the part of the screen that will be used to render HM7. At the bottom of the part "---- MGC : H-Mode7 ----", you can find the constants WIDTH, HEIGHT, X and Y. They specify the dimensions and the position of the HM7 rendering.
For example :
WIDTH = 288
HEIGHT = 216
X = 200
Y = 100
Using a small resolution can greatly decrease the lag.
- included the [OV] feature : add [OV] in the name of the map, and add a comment "OV" in events you wish to be resized.
The zoom value can be set with OV_ZOOM, at the bottom of the part "---- MGC : H-Mode7 ----"
- fixed a bug with several transluscent events
- included pivot manipulation (a NeoM7 feature) :
$scene.hm7_set_pivot(new value)
$scene.hm7_to_pivot(new value, speed)
$scene.hm7_increase_pivot(value)
Author's notes
For the moment there is only a handful of tileset elements compatible with this script.
It would be really great if anyone that creates such elements decides to share them.
Open Source DLL!
Now available, the source code for the DLL which handles the specially rendered
graphics is now available. The request for the source code was made by
finalholylight, and is now available in the link here, and just below the demo's own
download link.
The DLL's source code
Thanks
- DerVVulfman for his help file about textures
Some scripts :
Working on :