Add skinning
This commit is contained in:
@@ -7,6 +7,16 @@ function actor_player:on_init()
|
||||
self:create_body()
|
||||
|
||||
self:activate_camera()
|
||||
|
||||
local ent = engine.create_entity("test_object")
|
||||
engine.add_entity_to_world(ent)
|
||||
|
||||
self.m_weapon_entity_id = ent:get_id()
|
||||
|
||||
self.m_in_reload = false
|
||||
|
||||
--local ent2 = engine.get_entity_from_id(self.m_weapon_entity_id)
|
||||
--console.print(ent2:get_classname())
|
||||
end
|
||||
|
||||
function actor_player:on_shutdown()
|
||||
@@ -19,8 +29,39 @@ function actor_player:on_update(dt)
|
||||
self:update_camera_look()
|
||||
--self:update_camera_movement(dt)
|
||||
self:update_body_movement(dt)
|
||||
|
||||
local ent = engine.get_entity_from_id(self.m_weapon_entity_id)
|
||||
ent:set_relative_position_to_camera(self)
|
||||
|
||||
if self:get_action() == ACTION_FIRE and self.m_in_reload == false then
|
||||
ent:play_animation(ent:find_animation("shoot1"), ANIM_PLAYBACK_NONE)
|
||||
end
|
||||
|
||||
if self:get_action() == ACTION_RELOAD and self.m_in_reload == false then
|
||||
ent:play_animation(ent:find_animation("reload"), ANIM_PLAYBACK_NONE)
|
||||
self.m_in_reload = true
|
||||
end
|
||||
|
||||
|
||||
if ent:get_current_animation() == ent:find_animation("shoot1") and
|
||||
ent:get_current_animation_time() >= ent:get_animation_time(ent:find_animation("shoot1")) then
|
||||
ent:play_animation(ent:find_animation("idle1"), ANIM_PLAYBACK_REPEAT)
|
||||
end
|
||||
|
||||
if self.m_in_reload == true and ent:get_current_animation_time() >= ent:get_animation_time(ent:find_animation("reload")) then
|
||||
ent:play_animation(ent:find_animation("idle1"), ANIM_PLAYBACK_REPEAT)
|
||||
self.m_in_reload = false
|
||||
end
|
||||
-- if ent:get_current_animation() == ent:find_animation("reload") and
|
||||
-- ent:get_current_animation_time() >= ent:get_animation_time(ent:find_animation("reload")) then
|
||||
-- ent:play_animation(ent:find_animation("idle1"), ANIM_PLAYBACK_NONE)
|
||||
--end
|
||||
end
|
||||
|
||||
function actor_player:on_collide(other)
|
||||
console.print(string.format("actor_player:on_collide: %s", other:get_classname()))
|
||||
end
|
||||
end
|
||||
|
||||
function play_sound( filename, is_3d, posx, posy, posz )
|
||||
-- body
|
||||
end
|
||||
|
||||
@@ -3,14 +3,44 @@ test_object = inherit_table(game_object)
|
||||
|
||||
function test_object:on_init()
|
||||
game_object.on_init(self)
|
||||
|
||||
self:load_model("data/models/weapons/v_ump.iqm")
|
||||
|
||||
self.m_test_id = self:find_animation("idle1")
|
||||
console.print(string.format("test_object:on_init: self.m_test_id = %d", self.m_test_id))
|
||||
|
||||
|
||||
self:load_model("data/models/scene_walls.obj")
|
||||
|
||||
self.m_test = 0.0
|
||||
self:play_animation(self.m_test_id, ANIM_PLAYBACK_REPEAT)
|
||||
|
||||
-- self.m_test = 0.0
|
||||
end
|
||||
|
||||
function test_object:on_update(dt)
|
||||
game_object.on_update(self, dt)
|
||||
self:set_position(self.m_test, 0.0, 0.0)
|
||||
self.m_test = self.m_test + ( 0.2 * dt )
|
||||
end
|
||||
-- self:set_position(self.m_test, 2.0, 0.0)
|
||||
-- self.m_test = self.m_test + ( 0.2 * dt )
|
||||
end
|
||||
|
||||
function test_object:set_relative_position_to_camera( ent )
|
||||
local camX, camY, camZ = camera.get_position()
|
||||
local frontX, frontY, frontZ = camera.get_front()
|
||||
local rightX, rightY, rightZ = camera.get_right()
|
||||
local upX, upY, upZ = camera.get_up()
|
||||
|
||||
local yaw = camera.get_yaw()
|
||||
local pitch = camera.get_pitch()
|
||||
|
||||
self:set_rotation(pitch, -yaw, 0.0)
|
||||
|
||||
local offsetx = 0.0
|
||||
local offsety = 0.0
|
||||
local offsetz = 0.0
|
||||
|
||||
local x = camX + (rightX * offsetx) + (upX * offsety) + (frontX * offsetz)
|
||||
local y = camY + (rightY * offsetx) + (upY * offsety) + (frontY * offsetz)
|
||||
local z = camZ + (rightZ * offsetx) + (upZ * offsety) + (frontZ * offsetz)
|
||||
self:set_position(x, y, z)
|
||||
|
||||
-- force update transform
|
||||
self:update_transform()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user