Skip to content
Snippets Groups Projects
Commit 627179a0 authored by dg's avatar dg
Browse files

shader and textures in MO

git-svn-id: http://svn.net-core.org/repos/t-engine4@748 51575b47-30f0-44d4-a5cc-537603b46e54
parent e6b99bc7
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,8 @@
-- An entity is anything that goes on a map, terrain features, objects, monsters, player, ...
-- Usually there is no need to use it directly, and it is betetr to use specific engine.Grid, engine.Actor or engine.Object
-- classes. Most modules will want to subclass those anyway to add new comportments
local Shader = require "engine.Shader"
module(..., package.seeall, class.make)
local next_uid = 1
......@@ -156,7 +158,7 @@ function _M:makeMapObject(tiles)
if self._mo and self._mo:isValid() then return self._mo end
-- Create the map object with 1 + additional textures
self._mo = core.map.newObject(1 + (self.textures and #self.textures or 0))
self._mo = core.map.newObject(1 + (tiles.use_images and self.textures and #self.textures or 0))
_M.__mo_repo[#_M.__mo_repo+1] = self._mo
-- Setup tint
......@@ -164,6 +166,24 @@ function _M:makeMapObject(tiles)
-- Texture 0 is always the normal image/ascii tile
self._mo:texture(0, tiles:get(self.display, self.color_r, self.color_g, self.color_b, self.color_br, self.color_bg, self.color_bb, self.image, self._noalpha and 255))
-- Setup additional textures
if tiles.use_images and self.textures then
for i = 1, #self.textures do
local t = self.textures[i]
if type(t) == "function" then self._mo:texture(i, t(self, tiles))
elseif type(t) == "table" then
if t[1] == "image" then self._mo:texture(i, tiles:get('', 0, 0, 0, 0, 0, 0, t[2]))
end
end
end
end
-- Setup shader
if tiles.use_images and self.shader then
self._mo:shader(Shader.new(self.shader, self.shader_args).shad)
end
return self._mo
end
......
......@@ -21,7 +21,6 @@ require "engine.class"
local Entity = require "engine.Entity"
local Tiles = require "engine.Tiles"
local Particles = require "engine.Particles"
local Shader = require "engine.Shader"
local Faction = require "engine.Faction"
local DamageType = require "engine.DamageType"
......
......@@ -62,7 +62,7 @@ newEntity{
newEntity{
define_as = "WALL",
-- shader = "water", shader_args = {},
-- shader = "water", textures = { function() return core.noise.new(3):makeTexture3D("simplex", 128, 128, 128, 4, 0, 0, 0) end },
name = "wall", image = "terrain/granite_wall1.png",
display = '#', color_r=255, color_g=255, color_b=255, back_color=colors.GREY,
always_remember = true,
......
......@@ -285,6 +285,7 @@ static const struct luaL_reg noise_reg[] =
{"fbm_wavelet", noise_fbm_wavelet},
{"turbulence_wavelet", noise_turbulence_wavelet},
{"makeTexture2D", noise_texture2d},
{"makeTexture3D", noise_texture3d},
{NULL, NULL},
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment