Jump to content

Joshua

Members
  • Posts

    44
  • Joined

  • Last visited

Posts posted by Joshua

  1. Is it possible to perform a single raycast (Pick Event) and return a collection of pointers to intersected Entities by using the available pickevent? From my understanding, the current pickevent will either return a single pointer to the closest intersection result, or the first intersection result found.

     

    The only way that I can think of to do this would be to implement a recursive raycast in which the pickevent would return the closest intersection between p0 and p1, then do another pickevent using p1 as p0 and using a new point as p1. The method would continue in a similar fashion until there was no intersection between the raycast and an entity. I think this method would work, however it seems very daunting and may create a lot of overhead to perform one raycast. I understand that the current pickevent has a recursive parameter, however I believe that the recursive method, if true, will recurse inside the Entities Hierarchy and not past the initial intersected entity. Please advise.

     

    Syntax

    • bool Pick(const Vec3& p0, const Vec3& p1, Pick& pick, float radius = 0.0, bool closest=false, bool recursive=false, int collisiontype=0)

    Parameters

    • p0: the origin of the ray in global coordinates.
    • p1: the terminal end of the ray in global coordinates.
    • pick: a pick object to contain pick information.
    • radius: the radius of the ray. If the radius is greater than 0.0, a slower swept sphere collision will be performed.
    • closest: if set to true, the closest intersection will be found, otherwise the operation will return as soon as a single intersection is found.
    • recursive: if set to true, the entity's sub-hierarchy will be tested recursively.
    • collisiontype: if specified, the entity collision type of all children will be tested against this, and non-colliding entities will be skipped.

  2. I was trying to open my Leadwerks 3.0 Editor and I received an Exception Access Violation when it started loading the 'grid.shader' file. I do have a copy of Leadwerks 3.1 under Steam which is installed under the steamApps directory. My initial install directory for Leadwerks 3.0 is in the root directory of my (E:) partition. Both editions were working earlier today so I am unsure what the problem might be. I was not using the Leadwerks editor of either version prior to the error. I was programming my project from within Visual Studios 2010 Ultimate Edition.

     

    I have never tired running both editions at the same time. I have noticed that sometimes Leadwerks 3.1 under Steam will try and access the files/projects from the Leadwerks 3.0 directory but usually it results in a message box displaying the editor is unable to load the project.

     

    I looked for a possible .log file within the Leadwerks 3.0 directory that might contain any error reports but could not find one. I will try repatching the Leadwerks 3.0 installer with the Leadwerks 3.0 Updater later this evening to see if it resolves my problem. Please let me know if there is anything further information I can supply.

  3. I actually think the best method would be to apply the raycast to my previous method. To adjust the method, I would preform a raycast a maximum view distance from the NPC's forward direction. I would then check for any collision with scene objects and adjust the far plane to be just before the location of the collision. Using a position just before the collision would prevent any abnormal detection for example, if the player was pressed up on the other side of the wall. I think the use of planes is better then just using a raycast because we want to check a certain area for a player and an exact position is not needed right away.

     

    For example, I would check if there is a PlayerObject within the visible region of the NPC. If true, I would poll for the PlayerObject's position and through the use of the Vec3 class I would get the distance to\angle to etc and run any game logic from there.

  4. I would suggest you use three Plane objects. Project two planes(YZ) outward from your NPC's forward direction at the appropriate angles. then, create the third plane(YX) that is parallel to the NPC's forward direction at a specified distance away from the player, effectively creating an enclosed triangle. You would then check to see if the player is inside the enclosed triangle. Best of Luck!

  5. For iron sights, you can use a couple Vec3 or Mat4 to represent a m_weaponOffset and m_weaponOffsetRotation while idle and while aiming. you could then use Math::Curve(..) to interpolate between the offsets to allow a smooth transition between the two positions/rotations.

     

    For crouching, you can have a bool m_isCrouching value to indicate if the player is crouching, say if Key::ControlKey is pressed. If the player is crouching you set something like m_playerHeight to something like m_crouchHeight and position your camera accordingly.

     

    My code is in C++ but I am sure it can easily be translated to Lua.

     

    crouching ex.

     

    // Check for crouching.
    m_isCrouching = window->KeyDown(Key::ControlKey);
    // Set height appropriately
    SetHeight(( m_isCrouching ? m_crouchHeight : m_standHeight));
    // Get a pointer to the game's camera
    Camera* gameCamera = GetCamera();
    // Get the existing camera's position
    Vec3 newCamPos = gameCamera->GetPosition();
    // set the new camera position and smooth the y-Position
    newCamPos = Vec3(GetPosition().x, Math::Curve(GetPosition().y + GetHeight(), gameCamera->GetPosition().y, m_viewSmoothing), GetPosition().z);
    // apply the final results to the viewing camera
    gameCamera->SetPosition(newCamPos);
    

  6. Is there a way to get the handle of the application instance in Leadwerks 3.0? I would think that this would be under the System class or through the template App class but I see no official documentation in the command reference. I also have been unable to find anything similar in other class documentation, or in existing threads on the forum.

  7. It is my assumption that a CharacterController is considered an 'infinite-mass' object which would prevent any external force from being applied to it or, the SetInput(...) method will negate any forces applied to the object because the SetInput(...) uses the objects position, rotation etc. What you might be able to do is use the SetInput(...) method and incorporate applied-forces into the method. Doing something like this should allow you to still apply forces without changing the character controller, or modifying the mass of the object.

  8. I have found working a full time job ex. 6am to 5pm Monday through Friday with a one hour commute time both ways does not leave adequate time for any sort of successful development. I will definitely post my project to the asset store once complete but half completed core components is not worthy of entry. Best of luck!

×
×
  • Create New...