Jump to content

T0X1N

Members
  • Posts

    127
  • Joined

  • Last visited

Posts posted by T0X1N

  1. I don't think I quite understand this yet.

     

    Do I have to write a Entity::CallFunction function in my c++ source code? If I do, how would I go about adding the int "damage" to the code since I cannot create a new declaration to the Entity:: class. Plus, would this function act as a Hook function?

     

    What is the "extra" object? Can't I use that to store the data in? If so, how could I go about storing the 'damage' variable into an Object class variable?

     

    Also, is it possible to have an example source code snippet that calls a function in LUA from C++ with custom parameters that I can look at to learn off of? That would be extremely helpful as I learn by example mainly.

     

    Thanks for the help! smile.png

  2. How do I specify parameters in C++ with Entity::CallFunction?

     

    Example, I have a "Hurt" function defined as the following:

     

    function Script:Hurt( damage )

     

    In my C++ program, I want to call the "Hurt" function and specify the "damage". I found an old forum post (http://www.leadwerks.com/werkspace/topic/10745-passing-parameters-to-lua-via-callfunction/page__hl__entity::callfunction#entry78846), but I still do not understand how to specify parameters.

     

    I would like to do the following in my C++ program:

     

    entity->CallFunction("Hurt", damage)

  3. I wish you could draw/modify CSG brushes in the perspective mode. This would allow users to just use 1 perspective for GUI simplicity and the convenience of not having to constantly switch to and from 2D graph perspectives to get the shape you need. You can just basically build your map in 3D visual form.

     

    Also, this can be useful when maps start getting large and the 2D graphs start getting cluttered with wires from other brushes. Looking at that 2D wireframe graph on large maps are sort of a pain.

     

    This type of editing could be compared to the Unreal Engine's editor or Autodesk Maya where you can draw in 3D space.

     

    Drawing CSG from scratch in 3D space could go like click LMB and drag the shape in perspective view, release to make it. The height of the brush would be determined from the last brush you selected (just like how the editor does this now).

     

    Here is a mock-up screenshot of how I think it could look like:

    post-17-0-32114300-1480017741_thumb.jpg

     

    Or, instead of the anchor points on the edges, have them positioned on the faces, like so:

    post-17-0-03711800-1480017999_thumb.jpg

    • Upvote 3
  4. Can't you duplicate your directional light into the second world to make it affect the gun?

     

    The problem with that is you will not have any shadows. You would have lights in that world, but there would not be anything that would cast a shadow on to the gun.

  5. One way off the top of my head, which can be buggy, is to turn off the Depth Test in the guns material settings, I believe, but the only downside to that is your weapon cannot have child entities, only 1 entity. If it does, then the entities behind each other will appear. It would look like your camera has X-Ray vision. Since I never tested this route, I could be wrong on this one.

     

    Another way is to, like Josh said, scale the gun so small and position the weapon model really close to the camera so that it will not clip through anything. However, shadows will not appear on the gun model correctly because the model is so small. This will become more apparent when you have longer weapons like a rifle or shotgun.

     

    Another way, which is more realistic, is to have the weapon normal size, but perform a raycast so that if the weapon comes close to a surface, perform an animation that it will bring up the weapon so it does not go through the surface. One game that did this was Call of Juarez: Bound in Blood. I think Crysis did this as well.

  6. Thanks for replying Evayr! That issue would be easy to solve since if the camera is not looking at the point, it would return a -Z value, so I would just stop drawing it if it was just one point.

     

    However, the problem here is I want to draw a line of two points. If one point goes off camera, I have want to keep drawing the line, same would be if both points are off screen, but I am looking at the path.

     

    Like I said in my previous post, I think the problem is that when the Z axis goes negative, the X & Y coordinates are mirrored on the screen. I just need to mirror them back and BINGO! I should have it fixed. smile.png

     

    I'll keep working at this and see if I can fix it. If anybody has a solution before me, please chime in! smile.png

  7. Thanks for the reply, Maryj. Odd thing is it does not matter what p1 nor what p2 is on the 3D space. I tried p1 as a 3D point on the grid (-10 Z units away from p2) and used Camera::Project to grab the 2D coordinates so I can draw the line, but same issue.

     

    I think I know what the issue is, but I don't know the solution. I have the scene setup that you can fly the camera around using WASD and mouse to look. If one of the 3D points, of which I am using Camera::Project to get 2D coordinates to draw the line, go behind the camera, the Camera::Project basically returns a mirrored value and a negative Z axis. I am no math guru and I don't know of a formula to mirror those values back to where they should be so the program can draw the line correctly.

     

    The end goal here is to draw a 2D grid in the 3D space, just like how the Leadwerks Editor has. I could use a large 3d plane with a grid texture to make the grid, but I would rather do it with 2D lines so I don't use any polygons nor material loaded in memory to draw it.

  8. I am trying to use Camera::Project and Context::DrawLine to draw a 2d grid in 3d space for an map editor I am working on, but if 1 of the points go behind the camera, the grid gets goofy and is not drawing the line to connect to where it should in 3D space. Is this a bug or am I doing something wrong?

     

    I see that the "Z" axis goes to a negative number when the point is behind the camera, but I don't understand why the X & Y axis go way out of what they are supposed to be nor how to get them to what they are supposed to be.

     

     

    I have written a simple code snippet that does the same issue:

     

    Vec3 p1 = Vec3(context->GetWidth()/2, context->GetHeight()/2, 0);
    Vec3 p2 = camera->Project(Vec3(0, 0, 10));
    
    context->DrawLine(p1.x, p1.y, p2.x, p2.y);

     

    Here is a screenshot of what I am experiencing with the code above:

     

    post-17-0-18601600-1465445065_thumb.jpg

  9. Does anybody know of a way to get the model class from an Entity class?

     

    I want to get the model from the parent entity of the surface I picked in my program, but with the GetParent() function, it returns Entity, but I want the Model class so I can edit it's geometry. I also would like to do the same would for GetChild().

  10. The collision type ("collisiontype") in the Pick function is the 7th parameter. The default is set to pick all objects. You would set the "collisiontype" parameter to something that does not pick the terrain.

     

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

     

    http://www.leadwerks.com/werkspace/page/api-reference/_/command-reference/collision-r778

     

    Unfortunately, I am not sure what collision type is set for terrain as I have not worked with terrain much.

  11. Sorry, I forgot to mention I am using the Windows beta build as well. I just edited my post.

     

    I think I may have found the problem. I have a model loaded with a "collisionhull" child for custom collision shape. So the model is loaded as the following:

     

    Parent:

    1. visual mesh

    2. "collisionhull".

     

    When I use the selection marquee to select the object, it only selects the visual mesh child and not the "collisionhull" child nor the parent. When it does this, I cannot delete since the model is not really selected, only the visual mesh child. When I use the CTRL-Click method, it selects all within that model then allows me to delete.

    • Upvote 1
  12. When I use the Shift-Click-Drag selection box (or selection marquee) over models in the grid view, then try to delete those models selected (not CSG), they will not delete. I can only delete them when I click on the models individually while holding CTRL then delete them. I found this bug is only for models. The selection marquee method then deletion will work for CSG objects.

     

    Using Windows Beta Build.

  13. I would like to have a feature that if you right click on an entity in either the grid or perspective view then click on "Frame Selection" not only would it go to the entity on all viewports, but also auto-scrolls the scene tree to the selection. Or maybe have a separate selection in the menu for "Go To In Scene Tree". This would be very handy to have when inspecting the entity (children and/or parents) or wanting to add it to the Flowgraph Editor.

    • Upvote 5
  14. I wrote a LUA script to setup frame by frame animation, but if I try to change the material for a CSG brush during the game loop, it will not appear on the object in the game. I applied the same script I wrote to a sprite object and a cube model I exported from Blender and the material for each changed just fine during the loop. Am I doing something wrong for CSG brushes or is this a bug? Thanks!

     

    Here is the script I wrote for testing purposes:

     

    Script.speed = 10.0 -- float "Animation Speed"
    Script.material1 = "" --path "Material (Frame 1)" "Material File (*mat):mat|Material"
    Script.material2 = "" --path "Material (Frame 2)" "Material File (*mat):mat|Material"
    Script.material3 = "" --path "Material (Frame 3)" "Material File (*mat):mat|Material"
    Script.material4 = "" --path "Material (Frame 4)" "Material File (*mat):mat|Material"
    Script.material5 = "" --path "Material (Frame 5)" "Material File (*mat):mat|Material"
    Script.frames = 0
    Script.currTime = 0.0
    Script.currFrame = 0;
    Script.mat1 = nil;
    Script.mat2 = nil;
    Script.mat3 = nil;
    Script.mat4 = nil;
    Script.mat5 = nil;
    
    function Script:Start()
    if(self.material1 ~= "") then self.frames = self.frames + 1; self.mat1 = Material:Load(self.material1); end;
    if(self.material2 ~= "") then self.frames = self.frames + 1; self.mat2 = Material:Load(self.material2); end;
    if(self.material3 ~= "") then self.frames = self.frames + 1; self.mat3 = Material:Load(self.material3); end;
    if(self.material4 ~= "") then self.frames = self.frames + 1; self.mat4 = Material:Load(self.material4; end;
    if(self.material5 ~= "") then self.frames = self.frames + 1; self.mat5 = Material:Load(self.material5); end;
    end
    function Script:UpdateWorld()
    if(self.currTime >= self.speed) then
     self.entity:SetMaterial(self.mat2)
    
     self.currFrame = self.currFrame + 1;
     if( self.currFrame > self.frames ) then
      self.currFrame = 1
     end
     if( self.currFrame == 1 ) then
      self.entity:SetMaterial(self.mat1)
     end
    
     if( self.currFrame == 2 ) then
      self.entity:SetMaterial(self.mat2)
     end
    
     if( self.currFrame == 3 ) then
      self.entity:SetMaterial(self.mat3)
     end
    
     if( self.currFrame == 4 ) then
      self.entity:SetMaterial(self.mat4)
     end
    
     if( self.currFrame == 5 ) then
      self.entity:SetMaterial(self.mat5)
     end
    
     self.currTime = 0;
    
    else
     self.currTime = self.currTime + Time:GetSpeed();
    end
    end
    

×
×
  • Create New...