Page 1 of 1

Strange graphic behavior

Posted: Mon May 15, 2017 6:36 am
by LethargicChii
So I'm using blender to create my own custom entity for my Rocket Turret mod and as you can see with use of the base gun turret it's still very much WIP. Currently the entity works okay-ish, but is a bit glitchy and gets cut off sometimes and the shadow is not right. I've set the resolution for the camera in blender to x:49 Y:89 to match the width and height of a vanilla gun turret shadow.
rocket-turret-gun-extension-shadow
rocket-turret-gun-extension-shadow
rocket-turret-gun-extenstion-shadow.png (2.81 KiB) Viewed 1261 times
Above is my shadow sprite sheet. First off I can't get the mod to launch if I set the X and Y to 49, 89. I can set the X to 49, but anything above 66 Y causes the mod to fail to load. I get a nice little error that reads:

The given sprite position (left_top = 272x0) is completely outside the actual sprite image (size=265x372)
Sprite name:__rocket_turret__/graphics/entity/rocket-turret-gun-extension-shadow.png

It will load if I set the Y lower, but, it looks all funky:
Capture.PNG
Capture.PNG (495.79 KiB) Viewed 1261 times
The shadow sprite gets cut off. And if you notice there is some weird issue with the circled turret. All the rest look fine, but, this one is shifted way down. I don't understand the "shift =" code very well so if someone could explain it to me, maybe I could fix these issues?

Here is the code for my entity:

Code: Select all

function rocket_turret_extension(inputs)
return
{
  filename = "__rocket_turret__/graphics/entity/rocket-turret/rocket-turret-gun-extension.png",
  priority = "medium",
  width = 65,
  height = 63,
  direction_count = 4,
  frame_count = inputs.frame_count and inputs.frame_count or 5,
  line_length = inputs.line_length and inputs.line_length or 0,
  run_mode = inputs.run_mode and inputs.run_mode or "forward",
  shift = {0.015625, -0.859375},
  axially_symmetrical = false
}
end

function rocket_turret_extension_shadow(inputs)
return
{
  filename = "__rocket_turret__/graphics/entity/rocket-turret/rocket-turret-gun-extenstion-shadow.png",
  width = 66,
  height = 49,
  direction_count = 4,
  frame_count = inputs.frame_count and inputs.frame_count or 5,
  line_length = inputs.line_length and inputs.line_length or 0,
  run_mode = inputs.run_mode and inputs.run_mode or "forward",
  shift = {1.20313, 0.015625},
  axially_symmetrical = false,
  draw_as_shadow = true
}
end

function rocket_turret_attack(inputs)
return
{
  layers =
  {
    {
      width = 66,
      height = 64,
      frame_count = inputs.frame_count and inputs.frame_count or 2,
      axially_symmetrical = false,
      direction_count = 64,
      shift = {0, -0.875},
      stripes =
      {
        {
          filename = "__rocket_turret__/graphics/entity/rocket-turret/rocket-turret-gun-1.png",
          width_in_frames = inputs.frame_count and inputs.frame_count or 2,
          height_in_frames = 32,
        },
        {
          filename = "__rocket_turret__/graphics/entity/rocket-turret/rocket-turret-gun-2.png",
          width_in_frames = inputs.frame_count and inputs.frame_count or 2,
          height_in_frames = 32,
        }
      }
    },
    {
      width = 91,
      height = 50,
      frame_count = inputs.frame_count and inputs.frame_count or 2,
      axially_symmetrical = false,
      direction_count = 64,
      shift = {1.23438, 0},
      draw_as_shadow = true,
      stripes =
      {
        {
          filename = "__rocket_turret__/graphics/entity/rocket-turret/rocket-turret-gun-shadow-1.png",
          width_in_frames = inputs.frame_count and inputs.frame_count or 2,
          height_in_frames = 32,
        },
        {
          filename = "__rocket_turret__/graphics/entity/rocket-turret/rocket-turret-gun-shadow-2.png",
          width_in_frames = inputs.frame_count and inputs.frame_count or 2,
          height_in_frames = 32,
        }
      }
    }
  }
}
end

data:extend({
  {
    type = "ammo-turret",
    name = "rocket-turret",
    icon = "__rocket_turret__/graphics/icons/rocket-turret.png",
    flags = {"placeable-player", "player-creation"},
    minable = {mining_time = 0.5, result = "rocket-turret"},
    max_health = 1000,
	resistances =
	{
		{
			type = "physical",
			decrease = 2,
			percent = 0
		},
		{
			type = "explosion",
			decrease = 5,
			percent = 90,
		},
		{
			type = "fire",
			decrease = 0,
			percent = 100,
		}
	},
    corpse = "medium-remnants",
    collision_box = {{-0.7, -0.7 }, {0.7, 0.7}},
    selection_box = {{-1, -1 }, {1, 1}},
    rotation_speed = 0.015,
    preparing_speed = 0.08,
    folding_speed = 0.08,
    dying_explosion = "medium-explosion",
    inventory_size = 1,
    automated_ammo_count = 10,
    attacking_speed = 0.5,
	turret_base_has_direction = true,
    folded_animation = 
    {
      layers =
      {
        rocket_turret_extension{frame_count=1, line_length = 1},
        rocket_turret_extension_shadow{frame_count=1, line_length = 1}
      }
    },
    preparing_animation = 
    {
      layers =
      {
        rocket_turret_extension{},
        rocket_turret_extension_shadow{}
      }
    },
    prepared_animation = rocket_turret_attack{frame_count=1},
    attacking_animation = rocket_turret_attack{},
    folding_animation = 
    { 
      layers = 
      { 
        rocket_turret_extension{run_mode = "backward"},
        rocket_turret_extension_shadow{run_mode = "backward"}
      }
    },
    base_picture =
    {
      layers =
      {
        {
          filename = "__rocket_turret__/graphics/entity/rocket-turret/rocket-turret-base.png",
          priority = "high",
          width = 90,
          height = 75,
          axially_symmetrical = false,
          direction_count = 1,
          frame_count = 1,
          shift = {0, -0.046875},
        },
      }
    },
    vehicle_impact_sound =  { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 },
    
    attack_parameters =
    {
      type = "projectile",
      ammo_category = "rocket",
      cooldown = 80,
      projectile_creation_distance = 1.39375,
      projectile_center = {0, -0.0875}, -- same as gun_turret_attack shift
      shell_particle =
      {
        name = "shell-particle",
        direction_deviation = 0.1,
        speed = 0.1,
        speed_deviation = 0.03,
        center = {-0.0625, 0},
        creation_distance = -1.925,
        starting_frame_speed = 0.2,
        starting_frame_speed_deviation = 0.1
      },
      range = 28,
	  min_range = 8,
	  turn_range = .45,
      sound = 
		{
			{
				filename = "__base__/sound/fight/rocket-launcher.ogg",
				volume = 0.5
			}
		}
    },

    call_for_help_radius = 40
}})

Re: Strange graphic behavior

Posted: Wed May 17, 2017 6:35 pm
by LethargicChii
For anyone interested, I figured out the issue. It seems when I use blender and set the resolution to the numbers seen in the code for width and height (X and Y in blender) and then use spritify addon in blender that the sprite sheet will not come out at the exact resolution as the base games sprite sheets for the gun turret. So I have here a list of relevant X and Y that you can use if creating your own turret extension and shadows sheets and you run into the same odd issue:

turret-extension = x61 y59
turret-gun-1 & -2 x62 y60
extension-shadow x85 y45

The shadow one you may have to actually scale your model down and or re-position it to center view of the camera. I hope this helps someone out there :D

Edit: A Y value was incorrect