Jump to content

Tomas

Members
  • Posts

    40
  • Joined

  • Last visited

Posts posted by Tomas

  1. Thanks for reply. I tried the code, downloaded the shader, but it didnt worked for me as it should. Dont know why, but the shader wouldnt load into engine. I copied the shader contents into "drawimage.shader" that comes with engine, and then it worked. Theres my code:

    Script.Tx = Texture:Load("Materials/Compass/compass.tex")
    function Script:Start()
    self.camera = Camera:Create()
    self.camera:SetRotation(self.entity:GetRotation(true))
    self.camera:SetPosition(self.entity:GetPosition(true)+Vec3(0,1.8,0))
    self.imageshader = Shader:Load("Shaders/Drawing/drawimage.shader")
    end
    function Script:PostRender()
    local context=Context:GetCurrent()
    context:SetShader(imageshader)
    self.imageshader:SetVec2("pivotposition", Vec2(100.0,100.0))
    self.imageshader:SetFloat("angle",45)
    local rot=Vec3()
    rot=self.entity:GetRotation(true)
    --context:SetRotation(rot.y)
    context:DrawImage(self.Tx,100,100,200,200)
    context:DrawLine(100,100,200,200)
    end
    

     

    Any ideas what could be wrong?

  2. How i can rotate 2d image? I have this code, but it rotates viewport not image.

    Script.Tx = Texture:Load("Materials/Compass/compass.tex")
    function Script:Start()
    self.camera = Camera:Create()
    self.camera:SetRotation(self.entity:GetRotation(true))
    self.camera:SetPosition(self.entity:GetPosition(true)+Vec3(0,1.8,0))
    end
    function Script:PostRender()
    local context=Context:GetCurrent()
    local rot=Vec3()
    rot=self.entity:GetRotation(true)
    context:SetRotation(rot.y)
    context:DrawImage(self.Tx,100,100,10,100)
    end
    

  3. function Script:Start()
    self.camera = Camera:Create()
    self.camera:SetRotation(self.entity:GetRotation(true))
    self.camera:SetPosition(self.entity:GetPosition(true)+Vec3(0,1.8,0))
    end
    
    function Script:UpdateWorld()
    local context=Context:GetCurrent()
    context:SetColor(0,0,0)
    context:Clear()
    context:SetColor(0,1,0)
    context:DrawRect(0,0,100,100)
    context:Sync()
    end
    

     

    When i use this 3d view is gone. How to combine 2d and 3d?

  4. This is my code. Entity is not moving at all even with friction 0. Entity has collision box and shape box.

    Script.camPos=Vec3()
    Script.entPos=Vec3()
    Script.camRotation=Vec3()
    Script.mouseSensitivity = 15
    Script.mouseDifference=Vec2()
    Script.mouseOld=Vec2()
    Script.currentMousePos=Vec2()
    Script.mousepos=Vec2(0,0)
    function Script:Start()
    local window = Window:GetCurrent()
    local context = Context:GetCurrent()
    
    self.camera = Camera:Create()
    self:UpdateCamera()
    self.entity:SetFriction(1,1)
    end
    function Script:UpdateCamera()
    local context = Context:GetCurrent()
    local window = Window:GetCurrent()
    self.currentMousePos = window:GetMousePosition()
    window:SetMousePosition(Math:Round(context:GetWidth()/2), Math:Round(context:GetHeight()/2))
    self.currentMousePos.x = Math:Round(self.currentMousePos.x)
    self.currentMousePos.y = Math:Round(self.currentMousePos.y)
    self.mouseDifference.x = Math:Curve(self.currentMousePos.x - Math:Round(context:GetWidth()/2),self.mouseDifference.x,3)
    self.mouseDifference.y = Math:Curve(self.currentMousePos.y - Math:Round(context:GetHeight()/2),self.mouseDifference.y,3)
    self.camRotation.x = Math:Clamp(self.camRotation.x + self.mouseDifference.y / self.mouseSensitivity,-90,90)
    self.camRotation.y = self.camRotation.y + (self.mouseDifference.x / self.mouseSensitivity)
    
    self.camera:SetRotation(self.camRotation)
    self.entPos=self.entity:GetPosition()
    self.camera:SetPosition(self.entPos.x,self.entPos.y+1.8,self.entPos.z)
    self.entity:SetRotation(0,self.camRotation.y,0)
    
    
    end
    
    function Script:UpdateWorld()
    self:UpdateCamera()
    end
    function Script:UpdatePhysics()
    --Get the game window
    local window = Window:GetCurrent()
    self.entity:SetFriction(1,1)
    if window:KeyDown(Key.W) then self.entity:SetVelocity(0,0,10,false) end
    --if window:KeyDown(Key.W) then self.entity:AddForce(0,0,10,false) end
    --if window:KeyDown(Key.A) then self.entity:AddForce(-speed,0,0,false) end
    --if window:KeyDown(Key.D) then self.entity:AddForce(speed,0,0,false) end
    --if window:KeyDown(Key.S) then self.entity:AddForce(0,0,-speed,false) end
    end
    

×
×
  • Create New...