Jump to content

AggrorJorn

Members
  • Posts

    4,816
  • Joined

  • Last visited

Posts posted by AggrorJorn

  1. Well done, you are making progress.

    Some feedback on your code and a few suggestions:

    • Have an  array which holds enemy positions.
    • You are currently creating a new AABB from scratch, which is fine. The sphere however already has an AABB and you can simply retrieve it by using GetAABB(). Saves you from making an AABB from scratch. But that is up to you.
    • A Callback function no longer has acces to the 'self' variable. That is why you can simply provide an extra variable which either holds the script's entity.

    You can try it out. When that works, we have a look at the drawing part.

    **EDIT: added a simple timer in the update, so that you can control how often the enemy table is updated. 

    --An array which holds the enemies. This array is empties every update before being filled again.
    Script.enemyEntities = {}
    Script.timer = 0 
    Script.timeUntilMinimapUpdates = 0.2 
    
    function Script:Start()
        self.miniMapSphere = Model:Sphere(8,self.player)
        self.miniMapSphere:SetScale(50,50,50)
        self.miniMapSphere:SetPosition(self.player:GetPosition(true))
        
        --Parenting the sphere to the player, means we don't have to update the position ourselves again.
        self.miniMapSphere:SetParent(self.player)
        self.miniMapSphere:Hide()
    end
    
    function Script:UpdateWorld()
        self.timer = self.timer + Time:GetSpeed()
    
        if self.timer > self.timeUntilMinimapUpdates then
            self.timer = 0
            self.enemyEntities = nil
            local AABB = self.miniMapSphere:GetAABB(1)
    
            --We pass along the entity that our current script is attached to
            world:ForEachEntityInAABBDo(AABB, "Callback", self.entity) 
        end
    end
    
    --A callback function has lost the reference to 'self', that is why pass in the 'self.entity' at ForEachEntityInAABBDo
    function Callback(entity, extra)
        if entity:GetKeyValue("type") == "enemy" then
            table.insert(extra.script.enemyEntities, entity)
        end
    end

     

    • Like 2
  2. Try something like this.

    • You are currently using a certain area around you to show as a map. 
    • Place a sphere as a child of your player and make it invisible (or partially transparent for debugging)
    • The sphere needs to be roughly the size of the minimap you want to display. For example 4 meters wide.
    • In your minimap script, reference the sphere and perform ForEachEntityInAABBDo every second (or as often you would like to update the minimap).
    • The entities returned by the above function can now be looped over
      • Check if it is an enemy (GetKeyValue could be used)
      • Since AABB is a box and not a sphere, do a distance check to the enemy. If it is within the radius of the sphere, it should be shown on the minimap.
      • The method above is just a way to get a list of entities that are near you. The distance check is to further finetune the result. 

    See if you can get this working first before worrying about drawing the positions of the enemies.

    enemy.jpg.7fc5ad8bcbfcdb8428f048429346b210.jpg

    • Like 2
    • Upvote 1
  3. 15 hours ago, danidomen said:

    But now I want that when my VR controller collide with the door or the light,

    You want your character controller to collide with the door in order to open it? Your code suggest that you use a pick function to interact with objects.

    15 hours ago, danidomen said:

    Now, I replicated the code from FPSPlayer to interact with the E Key, and is "working" but is very awful

    Can you clarify what is working and what is not working. Do see anything that shouldn't happen. Error log? Perhaps a video recording?  

    1. The first thing you need to is gather information about which enemies are near you and should be projected on the minimap.
      1. one way is to gather enemies is using https://www.leadwerks.com/learn?page=API-Reference_Object_World_ForEachEntityInAABBDo
      2. Or you can loop over all enemies in an array, and check the distance to the player. 
    2. second step is adding this information to the shader. I have never added an array of positions to a shader (I recon something like this should be possible: uniform vec2 enemyPositions[2];) but as an alternative you can add several enemy positions.

     

  4. 7 minutes ago, imothep85 said:

     i save everything, i rename the files for leadwerks.

    So you are exporting the model and than rename the textures? If so, how would the model know that you renamed your textures. The texture need to have that name before you export the model.

  5. 23 minutes ago, imothep85 said:

     i just have a diffuse, why when object imported leadwerks doesnt use the diffuse, specular, bump maps from 3ds max??

    I am not entirely understanding this question. Your diffuse texture is visible in the screenshot your provided but you are sayin it is not using it?

    As for the bump and specular not automatically added to the material. I think Leadwerks uses a postfix to map bump and specular textures in a material. Try giving your textures the following names with a postfix:

    • myTexture_diff
    • myTexture_dot3
    • myTexture_spec

     

  6. In that case, I would file a bug report because that should be happening automatically. Are you using Linux btw? Because the automatic mapping only works in windows.

    As for not seeing any shadows. Open the material for your model. Is the Cast shadow option enabled? image.png.202a9bf2a3b489f7b4164343fa0c53d6.png

    Open the properties tab for your entity, under the appearance tab set cast shadows to Dynamic.

    appearance%20tab.png

     

  7. According to the documentation it should do this automatically, but there are some conditions:

    Quote

    ......Notice how the oilbarrel already has the texture applied to it.  This is because the texture information of the model is stored inside the original FBX file. The FBX file knows the names of the textures to be applied to the model. Leadwerks automatically checks if there are any textures in the same folder and matches those with the information stored in the model. When there is a match, a material is automatically created. The material is also automatically attached to the model.  This is one of those little things that just makes life easier.

    https://www.leadwerks.com/learn?page=Tutorials_Editor_Models-and-Animation

     

    Can you check if you have the following:

    • The fbx model references your texture.
    • That texture is in the same folder as you model.
  8. There is a materials folder by default.

    11 hours ago, imothep85 said:

    When the user install Leadwerks or run it he can just drag and drop files inside that folder and then Leadwerks convert every image to .tex wh ocan be directly used on 3d models by drag and drop.

    What you describe already happens.  However you need to make a material first. If you import a model with textures, material files are even created automatically. 

  9. 4 minutes ago, Core said:

    This is somewhat offtopic, but regarding the example provided on the API reference using Clear(), where it is actually used?

    You are correct. The sample lacks the actual demonstration of the function.

    Something like this would be needed. (haven't tested it)

    --Create a window
    window = Window:Create()
    context = Context:Create(window)
    world = World:Create()
    camera = Camera:Create()
    camera:Move(0,0,-3)
    local light = DirectionalLight:Create()
    light:SetRotation(35,35,0)
           
    model = Model:Box() 
    model:SetColor(0.0,0.0,1.0) 
    while true do        
    	if window:Closed() or window:KeyHit(Key.Escape) then return false end
    
    	if model ~= nil then
    		model:Turn(0,Time:GetSpeed(),0)
    	end
    	
    	--Clears the current world
    	if window:KeyHit(Key.Space) then
    		world:Clear()
    	end
    
    	Time:Update()
    	world:Update()
    	world:Render()
    	context:Sync(false)
    end

     

     

    • Like 1
  10. 18 minutes ago, M0lD said:

    The documentation is pretty much gone now becuse of Leadweks 5? Becuse the "Old documentation" links are talking if stuff thats gone now." (I found out leadwerks had an forum long after i started useing it) 

    Haveing everything documented and enableing users to add examples like comments would make a lot of the currently active questions non-existant...

    No. All the documentation found here: https://www.leadwerks.com/learn?page= is part of Leadwerks 4.x . It is just a new documentation system which was filled from scratch. So some information in the old documentation website might not be written in the new documentation system.

    Adding comments to pages would be nice, but for now we would have to file a bug report. Things get fixed very quickly if described properly. Example.

     

     

     

  11. 9 hours ago, Rick said:

    Honestly, it would be nice if there was a handy dandy function(s) for this kind of stuff. The function would return a list (since names can be the same). 

    This is something I have always found kinda odd when working with C++. I would have this massive switch/case list to get certain entities from my scene. Somehow that feels clunky. But even if there were an official function for this, it would probably do something similar in the background.

  12. I haven't tried it myself but it might be in a different template. What template did you select when creating your project? If you have chosen blank project, then it is not included. Look for a template that contains the VR/player model. Create a new project and just copy the models from there to your existing project.

×
×
  • Create New...