Jump to content

VicToMeyeZR

Members
  • Posts

    570
  • Joined

  • Last visited

Posts posted by VicToMeyeZR

  1. Hey. Rick, I thought I would help a little with this.

     

    require("scripts/class")
    require("Scripts/hooks")
    
    
    local class=CreateClass(...)
    
    
    function class:InitDialog(grid)
    self.super:InitDialog(grid)
    
    group = grid:AddGroup("Character")
    group:AddProperty("model", PROPERTY_FILE, "GMF Files (*.gmf):gmf", "", "Model Files")
    group:AddProperty("controller_height", PROPERTY_FLOAT, "Controller Height")
    group:AddProperty("controller_radius", PROPERTY_FLOAT, "Controller Radius")
    group:AddProperty("controller_step_height", PROPERTY_FLOAT, "Controller Step Height")
    group:AddProperty("controller_max_slope", PROPERTY_FLOAT,  "Controller Max Slope")
    group = grid:AddGroup("Animations")
    group:AddProperty("idle_start", PROPERTY_INTEGER, "Idle Start Frame")
    group:AddProperty("idle_end", PROPERTY_INTEGER, "Idle End Frame")
    group:AddProperty("walk_start", PROPERTY_INTEGER, "Walk Start Frame")
    group:AddProperty("walk_end", PROPERTY_INTEGER, "Walk End Frame")
    group:AddProperty("run_start", PROPERTY_INTEGER, "Run Start Frame")
    group:AddProperty("run_end", PROPERTY_INTEGER, "Run End Frame")
    group:AddProperty("jump_start", PROPERTY_INTEGER, "Jump Start Frame")
    group:AddProperty("jump_end", PROPERTY_INTEGER, "Jump End Frame")
    group:AddProperty("crouch_start", PROPERTY_INTEGER, "Crouch Start Frame")
    group:AddProperty("crouch_start", PROPERTY_INTEGER, "Crouch End Frame")
    
    group:Expand(1)
    end
    
    function class:CreateObject(model)
    local object=self.super:CreateObject(model)
    
    object.model = model
    object.height = tonumber(object:GetKey("controller_height", "1.8"))
    local radius = tonumber(object:GetKey("controller_radius", "0.4"))
    local step = tonumber(object:GetKey("controller_step_height", "0.5"))
    local slope = tonumber(object:GetKey("controller_max_slope", "45.0"))
    
    object.oneTime = false
    object.controller = CreateController(object.height, radius, step, slope)
    object.controller:SetMass(1.0)
    EntityType(object.controller, 1)
    
    -- set the position of the controller to the editor object
    local pos = object.model:GetPosition()
    object.controller:SetPosition(Vec3(pos.x, pos.y + (object.height/2), pos.z))
    object.characterModel = nil
    
    object.move = 0
    object.strafe = 0
    object.rotate = 0
    object.jump = 0
    object.moveSpeed = 2
    object.strafeSpeed = 2
    object.framestart = 0
    object.frameend = 0
    
    function object:StartAnimations(movement)
    	object.framestart = self.model:GetKey(movement .. "_start")
    	return object.framestart
    end
    function object:EndAnimations(movement)
    	object.frameend = self.model:GetKey(movement .. "_end")
    	return object.frameend
    end
    
    function object:SetKey(key,value)
    	if key=="model" then
    		local pos = self.model:GetPosition()
    		self.characterModel = LoadModel("abstract::"..value)
    		self.characterModel:SetPosition(Vec3(pos.x, pos.y, pos.z))
    	else
    		return self.super:SetKey(key,value)
    	end
    	return 1
    end
    
    function object:GetKey(key,value)
    	if key=="" then
    	else
    		return self.super:GetKey(key,value)
    	end
    	return value
    end
    
    function object:Update()
    
    	if object.frameend ~= 0 then
    		object:StartAnimations("idle")
    		object:EndAnimations("idle")
    	else
    		object.framestart = 0
    		object.frameend = 100
    	end
    
    	if self.characterModel ~= nil then
    		if object.frameend ~= 0 then
    		     object.frame = math.fmod(AppTime()/35, object.frameend-object.framestart)+object.framestart
    		     Animate(self.characterModel, object.frame, 1.0, 0, true)
    		end
    	end
    
    	if GetGlobalString("mode") == "GAME_MODE" then
    		if self.characterModel ~= nil then
    			if object.oneTime == false then
    				object.oneTime = true
    
    				object.controller:SetPosition(object.model:GetPosition())
    			end
    
    			self.controller:Update(self.rotation, self.move, self.strafe, self.jump, 5000, 10)
    			self.jump = 0		-- reset
    
    			-- the character model must follow the controller
    			-- for the 3rd person camera to work we must also move the object model, which is stupid
    			self.model:SetPosition(Vec3(object.controller.position.x, object.controller.position.y - (object.height/2), object.controller.position.z))
    			self.characterModel:SetPosition(Vec3(object.controller.position.x, object.controller.position.y - (object.height/2), object.controller.position.z))
    		end
    	else
    		-- constantly update the controller to the object in the editor
    		local pos = object.model:GetPosition()
    		object.controller:SetPosition(Vec3(pos.x, pos.y + (object.height/2), pos.z))
    
    
    		-- make the model follow
    		if self.characterModel ~= nil then
    			self.characterModel:SetPosition(Vec3(pos.x, pos.y, pos.z))
    		end
    	end
    
    end
    
    function object:UpdateMatrix()
    
    end
    
    --[[
    function object:LockKeys(model)
    
    	self.super:LockKeys()
    end
    ]]--
    
    --[[
    function object:UnlockKeys(model)
    
    	self.super:UnlockKeys()
    end
    ]]--
    
    --[[
    function object:UpdateMatrix()
    
    end
    ]]--
    
    --[[
    function object:Reset()
    
    end
    ]]--
    
    --[[
    function object:SetTarget(target,index)
    
    end
    ]]--
    
    --[[
    function object:Collision(entity,position,normasl,force,speed)
    
    end
    ]]--
    function object:ReceiveMessage(message,extra)
    	if message == "move" then
    		object.move = tonumber(extra) * self.moveSpeed
    		object:GetAnimations("walk")
    	elseif message == "jump" and object.controller:IsAirborne() == 0 then
    		object.jump = tonumber(extra)
    		object:GetAnimations("jump")
    	elseif message == "strafe" then
    		object.strafe = tonumber(extra) * self.strafeSpeed
    	else
    		self.super:ReceiveMessage(message,extra)
    	end
    
    end
    
    
    function object:Free(model)
    	object.controller:Free()
    
    	if object.characterModel ~= nil then
    		object.characterModel:Free()
    	end
    
    	--Notify("Inside free")
    	self.super:Free()
    end
    
    end
    
    --[[
    function class:Free()
    
    self.super:Free()
    end
    ]]--
    

     

    What this does so far;

    Add's the fields in the property to add the animation frames for input.

    Debugs to check if inputs are 0, will not crash "Unhandled Exception"

    Deafults to idle frames.

     

    Needed:

     

    Way to check what the message recieved from key board controller for movement animation

     

    Let me know what you think

  2. that one is much easier than the lua site. :angry: thanks

     

    also..

     

     

    I call

    group:AddProperty("idle_start", PROPERTY_INTEGER, "", "Idle Start Frame")
    

     

    but when I try to reference that value, it always pulls the default value only?

     

    object.framestart = object:GetKey("idle_start", "450")
    

     

    Is this not the right syntax?

  3. @Rick..

     

    Using your character thingoid if you assign the character to it, would the character lua code, then become the child of the character controller?

     

    I am wondering, because the animation sequences would be in the update() part of the character script, but trying to find the way to assign when key pressed play this sequence..

  4. ok.

    Leadwerks Engine 2.3
    Initializing Renderer...
    OpenGL Version: 2.1.8787
    GLSL Version: 1.30
    Render device: ATI Radeon HD 4800 Series 
    Vendor: ATI Technologies Inc.
    DrawBuffers2 supported: 1
    16 texture units supported.
    GPU instancing supported: 1
    Max batch size: 1024
    Shader model 4.0 supported: 1
    Conditional render supported: 0
    Loading shader "zip::c:/tools/leadwerks engine sdk/shaders.pak//query.vert", ""...
    Invoking script "C:/Tools/Leadwerks Engine SDK/Scripts/start/collisions.lua"...
    Invoking script "C:/Tools/Leadwerks Engine SDK/Scripts/start/globals.lua"...
    Loading shader "zip::c:/tools/leadwerks engine sdk/shaders.pak//postfilters/postfilter.vert", "zip::c:/tools/leadwerks engine sdk/shaders.pak//postfilters/depthblit.frag"...
    Loading texture "incbin::noise.dds"...
    Loading shader "zip::c:/tools/leadwerks engine sdk/shaders.pak//postfilters/postfilter.vert", "zip::c:/tools/leadwerks engine sdk/shaders.pak//lighting/directionallight.frag"...
    Loading mesh "c:/tools/leadwerks engine sdk/models/characters/cyber/character_visor_full.gmf"...
    Loading material "c:/tools/leadwerks engine sdk/models/characters/cyber/sword_col.mat"...
    Loading texture "c:/tools/leadwerks engine sdk/models/characters/cyber/sword_col.dds"...
    Loading shader "zip::c:/tools/leadwerks engine sdk/shaders.pak//mesh/mesh_diffuse_bumpmap_skin.vert", "zip::c:/tools/leadwerks engine sdk/shaders.pak//mesh/mesh_diffuse.frag"...
    Loading shader "zip::c:/tools/leadwerks engine sdk/shaders.pak//mesh/mesh_shadow_skin.vert", ""...
    Loading material "c:/tools/leadwerks engine sdk/models/characters/cyber/visor_col.mat"...
    Loading texture "c:/tools/leadwerks engine sdk/models/characters/cyber/visor_col.dds"...
    Loading material "c:/tools/leadwerks engine sdk/models/characters/cyber/gun_col.mat"...
    Loading texture "c:/tools/leadwerks engine sdk/models/characters/cyber/gun_col.dds"...
    Loading material "c:/tools/leadwerks engine sdk/models/characters/cyber/cyber_col.mat"...
    Loading texture "c:/tools/leadwerks engine sdk/models/characters/cyber/cyber_col.dds"...
    Mesh loaded in 131 milliseconds.
    Loading shader "zip::c:/tools/leadwerks engine sdk/shaders.pak//guide.vert", "zip::c:/tools/leadwerks engine sdk/shaders.pak//editor/guide.frag"...
    

     

    still black in the ModelViewer.

  5. I have yet to be able to get any of the 100's of models I have to render in the editor or game with the textures or materials.

     

    I have a character, exported from Fragmotion, opened into UU3D and saved in GMF. I converted the DDS to MAT files. I made sure the file locations were saved as relative to the mesh, and both MAT and DDS files are in the same directory, but all my models are still black. Here is the log from the Model Viewer

     

    Leadwerks Engine 2.3
    Initializing Renderer...
    OpenGL Version: 2.1.7169 Release
    GLSL Version: 1.20
    Render device: ATI Mobility Radeon X1300 (Omega 3.8.442)
    Vendor: ATI Technologies Inc.
    DrawBuffers2 supported: 0
    16 texture units supported.
    GPU instancing supported: 0
    Shader model 4.0 supported: 0
    Conditional render supported: 0
    Loading shader "zip::c:/leadwerks engine sdk/test_chat/shaders.pak//query.vert", ""...
    Invoking script "C:/Leadwerks Engine SDK/Scripts/start/collisions.lua"...
    Invoking script "C:/Leadwerks Engine SDK/Scripts/start/globals.lua"...
    Loading shader "zip::c:/leadwerks engine sdk/test_chat/shaders.pak//postfilters/postfilter.vert", "zip::c:/leadwerks engine sdk/test_chat/shaders.pak//postfilters/depthblit.frag"...
    Loading texture "incbin::noise.dds"...
    Loading shader "zip::c:/leadwerks engine sdk/test_chat/shaders.pak//postfilters/postfilter.vert", "zip::c:/leadwerks engine sdk/test_chat/shaders.pak//lighting/directionallight.frag"...
    Loading mesh "c:/documents and settings/hx11433/my documents/cyber infiltrator - final/mesh/gmf/character_visor_full.gmf"...
    Loading material "c:/documents and settings/hx11433/my documents/cyber infiltrator - final/mesh/gmf/sword_col.mat"...
    Loading texture "c:/documents and settings/hx11433/my documents/cyber infiltrator - final/mesh/gmf/sword_col.dds"...
    Loading shader "zip::c:/leadwerks engine sdk/test_chat/shaders.pak//mesh/mesh_diffuse.vert", "zip::c:/leadwerks engine sdk/test_chat/shaders.pak//mesh/mesh_diffuse.frag"...
    Loading material "c:/documents and settings/hx11433/my documents/cyber infiltrator - final/mesh/gmf/visor_col.mat"...
    Loading texture "c:/documents and settings/hx11433/my documents/cyber infiltrator - final/mesh/gmf/visor_col.dds"...
    Loading material "c:/documents and settings/hx11433/my documents/cyber infiltrator - final/mesh/gmf/gun_col.mat"...
    Loading texture "c:/documents and settings/hx11433/my documents/cyber infiltrator - final/mesh/gmf/gun_col.dds"...
    Loading material "c:/documents and settings/hx11433/my documents/cyber infiltrator - final/mesh/gmf/cyber_col.mat"...
    Loading texture "c:/documents and settings/hx11433/my documents/cyber infiltrator - final/mesh/gmf/cyber_col.dds"...
    Mesh loaded in 998 milliseconds.
    Loading shader "zip::c:/leadwerks engine sdk/test_chat/shaders.pak//mesh/mesh_shadow.vert", ""...
    Loading shader "zip::c:/leadwerks engine sdk/test_chat/shaders.pak//guide.vert", "zip::c:/leadwerks engine sdk/test_chat/shaders.pak//editor/guide.frag"...
    
    

  6. the original didn't have the property field at all, so it wasn't changeable..

     

    Line 453 didn't really change, I just changed material to Material, to make sure it selected the property field correctly.

  7. I modified the Road node lua file slightly.

     

    Open file: Raod_node.lua

     

    Add on line 26

     

    group:AddProperty("Material", PROPERTY_FILE, "MAT Files (*.mat):mat", "", "RoadMaterial Files")
    

     

    Find line 453 or

    material=LoadMaterial("abstract::"..self.model:GetKey("material"))
    

     

    And change the material to Material

     

    I have not tested this extensively, but it should allow you to change the road material easily.

     

    If some one wants to confirm, or show I better solution. :blink:

  8. alrighty..

     

    Well I am looking at using the cfg file for settings graphics for my game testing, instead of hard coding it into the start up file every time.

     

    So I would have

     

    [GraphicsSettings]

    GraphicsWidth=

    GraphicsHeight=

    etc....

     

    so I got

    GameSettings=io.open("graphics.cfg")
    .......
    
    

×
×
  • Create New...