Jump to content

Charrua

Developers
  • Posts

    230
  • Joined

  • Last visited

Everything posted by Charrua

  1. the following script fragment, were working ok, today i update LE3 and logFile is nil, and the file isn;t created (this fragment is just for testing that the entities table has the correct ones) local logFile logFile = FileSystem:WriteFile("log.txt") if logFile ~= nil then for key,value in pairs(entities) do logFile:WriteLine(key) local pos = value:GetPosition() logFile:WriteLine(pos.x) end logFile:Release() end does any one why?
  2. I'll look that carefully when i'll get back home. Thxs I already use a hook on map.load but it has it's limitations. It would be good to have an easy way of intercomunication between both.
  3. is it good practice to mix both? does cpp can call lua functions, use lua variables? does lua scripts get access to cpp variables, objects, methods for example, if i made an scene in the editor, attach some scripts to some objects, create and place the camera, etc how can i get the reference to the editor's camera from cpp the other way, if i create the camera with cpp, how can i reach it from a lua script. thank's in advance Juan
  4. hi you have to define a Vec3 variable to hold the position, then you can set/test/change individual values Vec3 Position Position = Entity:GetPosition() Then.... Position.x = Position.x+1 i wrote a simple script using Sin and Cos to simulate a Circular movement, you may change speedFactor on x and y coords Script.xVel=1.0--float x_velocity Script.yVel=1.0--float y_velocity Script.entPos=Vec3 Script.initialPos=Vec3 function Script:Start() --store initial position initialPos = self.entity:GetPosition(false) end function Script:UpdateWorld() --read current position entPos = self.entity:GetPosition(false) --calc new position, relative to the initial one entPos.y = initialPos.y + Math:Sin(Time:GetCurrent()/10.0) * self.yVel entPos.x = initialPos.x + Math:Cos(Time:GetCurrent()/10.0) * self.xVel --update new position self.entity:SetPosition(entPos.x, entPos.y, entPos.z) end create or use a map with one box, and attach this script to the box to create and attach a script (start form zero) read: http://www.leadwerks.com/werkspace/page/tutorials/_/script/creating-your-first-object-script-r110
  5. Charrua

    Veg material

    thank's dxt5 does the difference for me too!
  6. ha!, that's the hard way, i was looking for an easier one but's better than nothing! thxs
  7. i realize that 2 worlds aren't needed. i already have an image for background, so i don't need a background world to render. i simplify the code above (with no mouse look) and with only one world basically what is needed is a buffer to render 3d objects and a background image, the magic is done combining the 2 images with //Draw image, then foreground context->Enable(); context->SetBlendMode(Blend::Alpha); context->DrawImage(backImg, 0, 0); context->DrawImage(foreground->GetColorTexture(), 0, 0); context->SetBlendMode(Blend::Solid); here the code: #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } Buffer* foreground = NULL; Texture* backImg = NULL; bool App::Start() { //Create a window window = Leadwerks::Window::Create("cpp_worlds"); //Create a context context = Context::Create(window); //Create a world world = World::Create(); //create buffer for foreground foreground = Buffer::Create(context->GetWidth(), context->GetHeight(), 1, 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; //Render foreground foreground->Enable(); world->Update(); world->Render(); foreground->Disable(); //Draw image, then foreground context->Enable(); context->SetBlendMode(Blend::Alpha); context->DrawImage(backImg, 0, 0); context->DrawImage(foreground->GetColorTexture(), 0, 0); context->SetBlendMode(Blend::Solid); context->Sync(false); return true; } btw, where is the buffer documentation? i understand what is happening but i wish to read/know wich other functions/methods are available for buffers
  8. 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: ok, nothing but a box on it, but this feature is what i was looking for thank's again Juan
  9. thank's for your fast response. i'll read carefully the other threads and see what happens, but being watched them on the fly i guess that there is no solution, atm. i need this feature, guess it will be implemented soon.
  10. as the topic say. render, clears any 2d graphics already drawn. in blitz, this is done with: CameraClsMode Camera, 0, 1 is there any way/technique in LE of doing this? thank's Juan
  11. 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)
  12. i got this but after more than 4 hours, it happens suddenly when i intend to delete an object. not again after a couple of ours.
  13. 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).
  14. 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
  15. look for this app, but not found
  16. 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
  17. 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.
  18. 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...