Jump to content

Charrua

Developers
  • Posts

    230
  • Joined

  • Last visited

Posts posted by Charrua

  1. well, i get what i was looking for!

     

    i made simple changes on the code posted by Shadmar (thxs! :)

     

    http://www.leadwerks.com/werkspace/topic/9464-rendering-backgroundsforegrounds/#entry72636

     

    i need just a photograph behind and the capability of render 3d objects over it.

     

    here is the code:

    #include "App.h"
    using namespace Leadwerks;
    App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}
    App::~App() { delete world; delete window; }
    Vec3 camerarotation;
    #if defined (PLATFORM_WINDOWS) || defined (PLATFORM_MACOS)
    bool freelookmode = true;
    #else
    bool freelookmode = false;
    #endif
    
    World* backworld = NULL;
    Buffer* foreground = NULL;
    Buffer* background = NULL;
    Texture* backtex = NULL;
    Texture* fortex = NULL;
    Texture* backImg = NULL;
    bool App::Start()
    {
    //Initialize Steamworks (optional)
    /*if (!Steamworks::Initialize())
    {
    System::Print("Error: Failed to initialize Steam.");
    return false;
    }*/
    //Create a window
    window = Leadwerks::Window::Create("cpp_worlds");
    //Create a context
    context = Context::Create(window);
    //Create a world
    world = World::Create();
    backworld = World::Create();
    //create buffer for background
    background = Buffer::Create(context->GetWidth(), context->GetHeight(), 1, 0, 0);
    backtex = Texture::Create(context->GetWidth(), context->GetHeight(), Texture::RGBA, 0, 1, 0);
    //create buffer for foreground
    foreground = Buffer::Create(context->GetWidth(), context->GetHeight(), 1, 1, 0);
    fortex = Texture::Create(context->GetWidth(), context->GetHeight(), Texture::RGBA, 0, 1, 0);
    //create camera for the foreground
    World::SetCurrent(world);
    camera = Camera::Create();
    camera->Move(0, 2, -5);
    //Hide the mouse cursor
    window->HideMouse();
    //Load the map
    std::string mapname = System::GetProperty("map", "Maps/start.map");
    Map::Load(mapname);
    //Move the mouse to the center of the screen
    window->SetMousePosition(context->GetWidth() / 2, context->GetHeight() / 2);
    
    //load the background image
    backImg = Texture::Load("Materials/backgrounds/backImg.tex");
    return true;
    }
    bool App::Loop()
    {
    //Close the window to end the program
    if (window->Closed()) return false;
    //Press escape to end freelook mode
    if (window->KeyHit(Key::Escape))
    {
     if (!freelookmode) return false;
     freelookmode = false;
     window->ShowMouse();
    }
    if (freelookmode)
    {
     //Keyboard movement
     float strafe = (window->KeyDown(Key:) - window->KeyDown(Key::A))*Leadwerks::Time::GetSpeed() * 0.05;
     float move = (window->KeyDown(Key::W) - window->KeyDown(Key::S))*Leadwerks::Time::GetSpeed() * 0.05;
     camera->Move(strafe, 0, move);
     //Get the mouse movement
     float sx = context->GetWidth() / 2;
     float sy = context->GetHeight() / 2;
     Vec3 mouseposition = window->GetMousePosition();
     float dx = mouseposition.x - sx;
     float dy = mouseposition.y - sy;
     //Adjust and set the camera rotation
     camerarotation.x += dy / 10.0;
     camerarotation.y += dx / 10.0;
     camera->SetRotation(camerarotation);
     //Move the mouse to the center of the screen
     window->SetMousePosition(sx, sy);
    }
    Leadwerks::Time::Update();
    background->Enable();
    // draw the background image
    context->DrawImage(backImg, 0, 0);
    background->Disable();
    //Render foreground
    foreground->Enable();
    world->Update();
    world->Render();
    foreground->Disable();
    //Draw both worlds.
    context->Enable();
    context->SetBlendMode(Blend::Alpha);
    context->DrawImage(background->GetColorTexture(), 0, 0);
    context->DrawImage(foreground->GetColorTexture(), 0, 0);
    context->SetBlendMode(Blend::Solid);
    context->Sync(false);
    return true;
    }
    

     

    and the result:

    background.png

     

    ok, nothing but a box on it, but this feature is what i was looking for

     

    thank's again

     

    Juan

    • Upvote 1
  2. i'm so new here to properly answer, but i would do a list of all the entities and handle them not depending on if they are seen by those functions.

     

    are you using c++ or lua?

     

    from a c++ tut i took the following:

     

    you may define a function (called when the map is loaded) which keeps track of each entity included on the map, and store references to them in a vector (defined as: vector<Entity*> entities;)

     

    //Store all entities when map is loaded

    void StoreWorldObjects(Entity* entity, Object* extra)

    {

    System::Print("Loaded an entity and stored it: " + entity->GetKeyValue("name"));

    entities.push_back(entity);

     

    }

     

    you have to call Load this way:

     

    Map::Load("Maps/start.map", StoreWorldObjects);

     

    then you can scan the vector:

     

    for( iter; iter != entities.end(); iter++)

    {

    Entity* entity = *iter;

    }

     

    and do whatever you have to do whit them

     

    (no idea if this work in lua)

  3. it's always nice to see some familiar faces (even ours...)

     

    doing my first steps on c++, lua and leadwerks, trying to figure out the whole thing, overwhelming at first as always with new environments.

     

    just got to send and receive data via serial port, a functionality i need for a project which perhaps is my first work with this engine.

     

    For a beginner in cpp, got to make work a code i found somewhere is very motivating (with some modifications about which .h files to include and some syntactic differences naturally).

  4. Solved!

     

    Ok, first problem: ME.

     

    when install vs express 2013, some warnings appear at the end. Telling me to solve this issues... which i ignore...

    the messages say: A certificate chain could not be built to a trusted root authority.

     

    looking how to solve this i found:

     

    http://support.microsoft.com/kb/2746268

     

    and ending runing: KB931125, and finally doing a Repair installation (control panel -> uninstall program)

     

    ha, never thought that a free camera showing me a couple of boxes would make me so happy!

     

    then, bye until i do my next step, in which for sure, i will do another error...

     

    thanks for the ones that try to help.

     

    best regards

     

    Juan

  5. it is supposed to be this way...

     

    i started LE, create a new c++ project, open the projects\windows folder and double click on the .sln file

    once VSE2013 open the solution, i open the app.cpp file and press the "green play button", then the warning MSB8003 appear

     

     

    i found that the same error is reported by other vs users:

     

    http://connect.microsoft.com/VisualStudio/feedback/details/762015/include-and-libraries-directories-not-setup-correctly-for-c-if-vs2010-already-installed

     

    http://helgeklein.com/blog/2010/01/visual-studio-fixing-broken-windowssdkdir-variable/

     

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/7c1c1d23-afd4-485d-aaec-ca82c078654d/problem-with-the-windowssdkdir-after-installing-vs2013?forum=vssetup

     

    it is just a bad variable setting/update when installing one version while other is present (i have 2010 already installed when i install 2013)

     

    does some one know how to uninstall both and do a clean up, so when i intall VSE 2013 the installation did not found any previous traces of an old version?

     

    thxs

     

    cpp%20warning.png

  6. i should have said:

     

    Visual Studio express 2013, that's the one i had installed.

     

    as the error mesage talk about sdk i looked to find it and install it, but i realised that VS express 2013 inludes the sdk.

     

    i look in program files and it is, the thing is that in the registry there are no WindowsSDKDir variable, i don't know why!

     

    Does some one can look for that variable and tell me the underneath structure?

     

    there are threads about the same issue with many different earlier versions of VS, but i couldn't find a solution.

  7. First, hi

     

    I'm new here, i;m a technician in electronics and my focus is to use 3d for electronics projects/interfaces.

     

    my first trouble (sincerely not the first but the first big one!) isn't related with leadwerks, instead is about the SDK

     

    i installed the Visual Studio 2013 which includes sdk and in my first run (build) i got:

     

    warning MSB8003: Could not find WindowsSDKDir variable from the registry....

     

    and many errors following....

     

    does someone has a solution for that?

     

    I'm running a W7 in a qosmio i5 64bit machine

     

    the problem is a registry variable related with the skd version (which is 7.1A)

     

    thank's in advance

     

    (and sorry for my bad english)

     

    Juan

×
×
  • Create New...