Jump to content

norbert

Developers
  • Posts

    43
  • Joined

  • Last visited

Posts posted by norbert

  1.  

    How do I access the camera in C++ when loading the map start.ultra? The hang is created in the ThirdPersonControls component and attached to the players. Is there a command for this or is it just a roundabout way?

    Kind regards, Norbert

     

     

  2.  

    Hello, I have just installed the UltraEngine. After creating a project, I open the test.sln in the editor. It starts Visual Studio 2022. When I now want to test the program I get the error message > Error (active) E1696 The file "Source" cannot be opened: "UltraEngine.h".

    Is anyone able to help me? Thanks

    Norbert

     

  3. Hello,

     

    if i use the point function and context->Sync(false) the memory usage increases continuously.

     

    As an example, we take the sample code:

     

    The only change is the (context->Sync(false))

     

     

     

    #include "App.h"
    using namespace Leadwerks;
    App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}
    App::~App() { delete world; delete window; }
    Entity* entity1 = NULL;
    Entity* entity2 = NULL;
    bool App::Start()
    {
     window = Window::Create();
     context = Context::Create(window);
     world = World::Create();
     camera = Camera::Create();
     camera->Move(0,1,-3);
     Light* light = DirectionalLight::Create();
     light->SetRotation(35,35,0);
    
     //Create a model
     entity1 = Model::Box();
     entity1->SetColor(0.0,0.0,1.0);
     entity1->SetRotation(0,-90,0);
    
    //Create another model to point at the one that goes in circles
     entity2 = Model::Box();
     entity2->SetColor(0.0,1.0,0.0);
     entity2->SetPosition(0,0,2);
    
     return true;
    }
    bool App::Loop()
    {
     if (window->Closed() || window->KeyDown(Key::Escape)) return false;
    
     //Make the model move in a circle
     entity1->Turn(0,Time::GetSpeed()*0.5,0);
     entity1->Move(0,0,0.1);
    
    //Point this at the moving box when the space key is pressed
    if (window->KeyDown(Key::Space))
    {
     entity2->Point(entity1,2,Time::GetSpeed()*0.1);
    }
    
     Time::Update();
     world->Update();
     world->Render();
     context->Sync(false);
    
     return true;
    }
    

  4. Hello There,

     

    I want to let light a sphere with a virtual light. For that I have adapted a shader. But the problem is that the beam moved on the sphere.

     

    maybe could give me yes explain what I'm doing wrong someone.

     

    thank Norbert

    
    


    https://youtu.be/ZujlT_cdUTY

    i copy and change the standart default.shader

    changes in Vertex Shader:
    top:
    out float Light_Intensity;
    const vec3 LightPos = vec3(-100,0,0);

    main:
    vec3 ecPosition = vec3(modelvertexposition);
    vec3 tnorm = normalize(nmat* vertex_normal);
    vec3 lightVec2 = normalize(LightPos-ecPosition);
    Light_Intensity = max(dot(lightVec2, tnorm), 0.0);


    changes in Fragment Shader:
    top:
    in float Light_Intensity;

    main:
    fragData0 = outcolor * Light_Intensity; // My Code
    fragData2 = vec4(vec3(fragData0),materialflags/255.0); // leuchten lassen


    Complett Shader
    #version 400
    #define MAX_INSTANCES 256
    //Uniforms
    //uniform mat4 entitymatrix;
    uniform vec4 materialcolordiffuse;
    uniform mat4 projectioncameramatrix;
    uniform mat4 camerainversematrix;
    uniform instancematrices { mat4 matrix[MAX_INSTANCES];} entity;
    uniform vec4 clipplane0 = vec4(0.0);
    //Attributes
    in vec3 vertex_position;
    in vec4 vertex_color;
    in vec3 vertex_normal;
    in vec3 vertex_binormal;
    in vec3 vertex_tangent;
    in vec2 vertex_texcoords0;
    //Outputs
    //out vec4 ex_color;
    out float ex_selectionstate;
    //out vec3 ex_VertexCameraPosition;
    //out vec3 ex_normal;
    //out vec2 ex_texcoords0;
    //Tessellation
    out vec4 vPosition;
    out vec2 vTexCoords0;
    out vec3 vNormal;
    out vec3 vBinormal;
    out vec3 vTangent;
    out vec4 vColor;
    out float clipdistance0;
    
    // My
    out float Light_Intensity;
    const vec3 LightPos = vec3(-100,0,0);
    
    void main()
    {
    mat4 entitymatrix = entity.matrix[gl_InstanceID];
    mat4 entitymatrix_=entitymatrix;
    entitymatrix_[0][3]=0.0;
    entitymatrix_[1][3]=0.0;
    entitymatrix_[2][3]=0.0;
    entitymatrix_[3][3]=1.0;
    
    vColor=vec4(entitymatrix[0][3],entitymatrix[1][3],entitymatrix[2][3],entitymatrix[3][3]);
    
    vec4 modelvertexposition = entitymatrix_ * vec4(vertex_position,1.0);
    //ex_VertexCameraPosition = vec3(camerainversematrix * modelvertexposition);
    //Clip planes
    if (length(clipplane0.xyz)>0.0001)
    {
    clipdistance0 = modelvertexposition.x*clipplane0.x + modelvertexposition.y*clipplane0.y + modelvertexposition.z*clipplane0.z + clipplane0.w;
    }
    else
    {
    clipdistance0 = 0.0;
    }
    vPosition = modelvertexposition;
    gl_Position = projectioncameramatrix * vPosition;
    
    mat3 nmat = mat3(camerainversematrix[0].xyz,camerainversematrix[1].xyz,camerainversematrix[2].xyz);//39
    nmat = nmat * mat3(entitymatrix[0].xyz,entitymatrix[1].xyz,entitymatrix[2].xyz);//40
    vNormal = normalize(nmat * vertex_normal);
    vBinormal = normalize(nmat * vertex_binormal);
    vTangent = normalize(nmat * vertex_tangent);
    
    vTexCoords0 = vertex_texcoords0;
    
    vColor = vec4(entitymatrix[0][3],entitymatrix[1][3],entitymatrix[2][3],entitymatrix[3][3]);
    vColor *= vec4(1.0-vertex_color.r,1.0-vertex_color.g,1.0-vertex_color.b,vertex_color.a) * materialcolordiffuse;
    
    
    // My Code
    
    vec3 ecPosition = vec3(modelvertexposition);
    vec3 tnorm	 = normalize(nmat* vertex_normal);
    vec3 lightVec2	 = normalize(LightPos-ecPosition);
    Light_Intensity = max(dot(lightVec2, tnorm), 0.0);
    
    }
    

     

    #version 400
    #define BFN_ENABLED 1
    //Uniforms
    uniform int lightingmode;
    uniform vec2 buffersize;
    uniform vec2 camerarange;
    uniform float camerazoom;
    uniform vec4 materialcolorspecular;
    uniform vec4 lighting_ambient;
    uniform samplerCube texture15;
    //Inputs
    in float ex_selectionstate;
    in vec2 vTexCoords0;
    in vec3 vNormal;
    in vec3 vBinormal;
    in vec3 vTangent;
    in vec4 vColor;
    in float clipdistance0;
    //Outputs
    out vec4 fragData0;
    out vec4 fragData1;
    out vec4 fragData2;
    out vec4 fragData3;
    
    // My
    in float Light_Intensity;
    void main(void)
    {
    //Clip plane discard
    if (clipdistance0>0.0) discard;
    
    vec4 outcolor = vColor;
    fragData0 = outcolor * Light_Intensity; // My Code
    
    vec3 normal=vNormal;
    
    #if BFN_ENABLED==1
    //Best-fit normals
    fragData1 = texture(texture15,normalize(vec3(normal.x,-normal.y,normal.z)));
    fragData1.a = fragData0.a;
    #else
    //Low-res normals
    fragData1 = vec4(normalize(normal)*0.5+0.5,fragData0.a);
    #endif
    fragData1.a = materialcolorspecular.r * 0.299 + materialcolorspecular.g * 0.587 + materialcolorspecular.b * 0.114;
    //int materialflags=1;
    //if (ex_selectionstate>0.0) materialflags += 2;
    //fragData2 = vec4(0.0,0.0,0.0,materialflags/255.0);
    
    int materialflags=1;
    if (ex_selectionstate>0.0) materialflags += 2;
    //fragData2 = vec4(0.0,0.0,0.0,materialflags/255.0);
    fragData2 = vec4(vec3(fragData0),materialflags/255.0); // leuchten lassen
    }
    

  5. Hello,

     

    when i call the command sqrt in lua script this error message is displayed:

     

    calling ´sqrt´ on bad self (number expected, got table)

     

    local test

     

    test = math:sqrt(2)

    System:Print(test)

     

    greeting norbert

  6. Hello Georjack,

     

    1. You can save and load your game state. you must write your own loader with this commands -->

    http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/stream/

     

    2. Yes you can create a simple gui by use the context commads-->

    http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/

     

    3. A Exe is included but the lua code ist not encrypted and everyone can read it.

    I have read but I think that this may soon be encrypted with leadwerks. if not you can use MoleBox indeed.

     

    4 and 5, I can not help you.

     

    greeting norbert

    • Upvote 1
  7. I would like to draw a image in the skybox cubemap.

    But has only a effect when i draw the image at position 0,0

    all others has no effect.

     

    in function App:Start()
    
    iam create the skybox
    
    --Create skybox
    sky = Model:Create()
    --just render a plane and project cubemap onto it
    local surface = sky:AddSurface()
    surface:AddVertex(-0.5,-0.5,0, 0,0,-1)
    surface:AddVertex(0.5,-0.5,0, 0,0,-1)
    surface:AddVertex(0.5,0.5,0, 0,0,-1)
    surface:AddVertex(-0.5,0.5,0, 0,0,-1)
    surface:AddTriangle(2,1,0)
    surface:AddTriangle(0,3,2)
    
    --position in front of camera but far out to near camera clip plane
    sky:SetPosition(self.FPS_CAM:GetPosition())
    sky:SetRotation(self.FPS_CAM:GetRotation())
    sky:Move(0,0,self.FPS_CAM:GetRange().y-50)
    sky:SetScale(self.FPS_CAM:GetRange().y*10)
    sky:SetParent(self.FPS_CAM)
    
    -- and paint it
    skymat=Material:Load("Materials/Sky/myskybox1.mat")
    sky:SetMaterial(skymat)
    
    
    
    self.skytexture = skymat:GetTexture()
    self.FPSbuffer = Buffer:Create(2048,1536,1,0,0)
    self.FPSbuffer:SetColorTexture(self.skytexture)
    

     

    in function App:Loop()
    
    
    self.FPSbuffer:Enable()
    self.FPSbuffer:Clear()
    self.context:DrawImage(self.sample,0,0)
    self.FPSbuffer:Disable()
    

     

     

    there is an extra command to sign in a cubemap?

    have seen there is also an extra shader.

     

    Shaders \ Drawing \ drawimagecubemap.shader

     

    greeting norbert

  8. Hi,

     

    Is there a tutorial for installing LuaJIT for leadwerks 3.1 indie edition?

    I have download and install the latest version of MinGW

    and i have downlad LuaJIT-2.0.2

     

    when i try to build with the command "mingw32-make"

     

    comes the following error:

     

    lbe.png

     

    does anyone have an idea what I'm doing wrong?

     

    greeting norbert

×
×
  • Create New...