Creating Hexagram using Rotation of Axis

From LuaSTG Wiki
Jump to navigation Jump to search

First we need to modify the boss_ui.lua (in older versions: boss.lua).

Info[edit | edit source]

eff_magicsquare.png

Most of the hexagram in full games in Touhou like Touhou 14 to present, Hollow Song of Birds, Book of Star Mythology and etc. If their files extracted, the hexagam there is only an image or an image with other sprites not like the the default LuaSTG "eff_magicsqare.png" which is a sprite sheet.

This is common on the Touhou Damakufu engine and Touhou Damakufu scripts like using the . Most of the math that is used are rotation of axis and trigonometry (mostly sine "sin()" and cosine "cos()").

Applying the Rotation of Axis[edit | edit source]

LuaSTG_ex_0.82b[edit | edit source]
Default 3D Hexagram in LuaSTG
This will be the used Hexagram.


You should find in boss_ui a line with the text 'boss_aura_3D' and you will encounter this.

   function aura:render()
       local b = self.system.boss
       if not (IsValid(b)) then
      return
       end
       local size = self.size * b.aura_scale
       for i = 1, 25 do
           SetImageState("boss_aura_3D" .. i, "mul+add", Color(b.aura_alpha, 255, 255, 255))
       end
       Render("boss_aura_3D" .. b.ani % 25 + 1, b.x, b.y, b.ani * 0.75,
           0.92 * size, (0.8 + 0.12 * sin(90 + b.ani * 0.75)) * size)
   end

You need to convert this into a comment or remove the matching line below:

    for i = 1, 25 do
           SetImageState("boss_aura_3D" .. i, "mul+add", Color(b.aura_alpha, 255, 255, 255))
    end
    Render("boss_aura_3D" .. b.ani % 25 + 1, b.x, b.y, b.ani * 0.75,
        0.92 * size, (0.8 + 0.12 * sin(90 + b.ani * 0.75)) * size)

And place these parameters. Note: Do not write the notes inside the parentheses. Write it like this: --size

    local dist_size = 35 (ellipse size rate)
    local turnspeed = 0.75 (image rotation speed)
    local sss = 150 (size)
    local e_rot = 0.325 (axis rotation ammount)
    local divt = 0.75 (time of ellipse horiontal scale size change)

and then the line of code:

    local anglex = b.ani*(turnspeed/5)
    local angley = b.ani*(turnspeed/5)
    local x0,y0 = cos(anglex) *     (sss-dist_size)-sin(b.ani*divt)*dist_size        , sin(angley)     * sss
    local x1,y1 = cos(anglex+90) *  (sss-dist_size)-sin((b.ani*divt)+90)*dist_size   , sin(angley+90)  * sss
    local x2,y2 = cos(anglex+180) * (sss-dist_size)-sin((b.ani*divt)+180)*dist_size  , sin(angley+180) * sss
    local x3,y3 = cos(anglex+270) * (sss-dist_size)-sin((b.ani*divt)+270)*dist_size  , sin(angley+270) * sss
    Render4V('image name',
         self.x + x0 * cos(b.ani*e_rot) - y0 * sin(b.ani*e_rot),self.y + y0 * cos(b.ani*e_rot) + x0 * sin(b.ani*e_rot),0.25,
         self.x + x1 * cos(b.ani*e_rot) - y1 * sin(b.ani*e_rot),self.y + y1 * cos(b.ani*e_rot) + x1 * sin(b.ani*e_rot),0.25,
         self.x + x2 * cos(b.ani*e_rot) - y2 * sin(b.ani*e_rot),self.y + y2 * cos(b.ani*e_rot) + x2 * sin(b.ani*e_rot),0.25,
         self.x + x3 * cos(b.ani*e_rot) - y3 * sin(b.ani*e_rot),self.y + y3 * cos(b.ani*e_rot) + x3 * sin(b.ani*e_rot),0.25)

This should be the result"

Result of Rotation of axis


Questions and Answers[edit | edit source]

You can ask here or in the disscusions.

What is the difference of the older hexagram from the rotation of axis one?[edit | edit source]

A: The difference here is the use of the image. You dont need a sprite sheet of hexagram rotating to do the 3D hexagram. You only need one image to do the 3D hexagram.