Jump to content

Charrua

Developers
  • Posts

    247
  • Joined

  • Last visited

Everything posted by Charrua

  1. i'm using hinges only. to get wheel rotation, simply read the current joint angle and set it to some value ahead, having motor enabled speed is controlled by MotorSpeed wheels are cylinders ... made by segments and so the whell gets jumping constantly and so, the vehicle goes slower that it should... if you tell the camera to follow the vehicle, then you will see how unstable it is... i'm not applying forces/torque, just MotorSpeed, Limits, Angle also, to much or to less mass on the individual parts of the vehicle make it behave differently, bad/worse i'm doing some code-clean-up, then i will post the scripts i'm using. Not sure if it is the correct way of doing things, but problably some one can point me in the right direction... thank's for the comments
  2. @shadmar: nice unrelated shoot!, at least it gives some beauty to this thread... ok, now i'm controlling steer and speed not too much stable, but working
  3. thank's if i have time, my intention is to create some prefabs/scripts to play with. is a way of learning and have fun.
  4. sliders will came late... and balls also i'm still playing with hinges. 4 or 3 wheels: tricycle or car.. very elemental, with no control (until) a couple of captures, on the editor, and running the code. the video is uploading...
  5. thank's for share it just a small typo: on grid.lua, start function entities[x]:SetPosition(Math:Random(-500,500),0,SetPosition(Math:Random(-500,500)) should be entities[x]:SetPosition(Math:Random(-500,500),0,Math:Random(-500,500))
  6. not all is work! Here the code that does the magic: Create a sphere on start function Script:Start() --as this script is attached to the camera, here is a good place to --set a global camera variable and so, it can be used in any other script of this project. camera=self.entity --Create a sphere to indicate where the pick hits self.picksphere = Model:Sphere() self.picksphere:SetColor(1.0,0.0,0.0) self.picksphere:SetPickMode(0) self.picksphere:SetScale(pickradius*2.0) self.picksphere:Hide() System:Print("fly.lua start") end on the update world function: if appWindow:MouseHit(1) then local pickinfo = PickInfo() local p = appWindow:GetMousePosition() --do a camera pick --place a new instance of the picksphere ent at the picked position --place a hinge joint to keep the sphere and the picked object together if (camera:Pick(p.x,p.y,pickinfo,pickradius,true)) then local newEnt = self.picksphere:Instance() newEnt:SetPhysicsMode(Entity.RigidBodyPhysics) newEnt:SetMass(10) local shape = Shape:Sphere() newEnt:SetShape(shape) shape:Release() newEnt:SetPosition(pickinfo.position) local hingeVar = Joint:Slider(pickinfo.position.x, pickinfo.position.y, pickinfo.position.z, 0, 0, 0, pickinfo.entity, newEnt) hingeVar:SetLimits(0,0) hingeVar:EnableLimits() newEnt:Show() end end a note about: appWindow on app.lua, i declare this global variable and pass the window created there, so i can use it on any other script here the modification of app.lua: appWindow=nil --global variable, so fly.lua can reach and use the window created on start function App:Start() --Initialize Steamworks (optional) --Steamworks:Initialize() --Set the application title self.title="MyGame" --Create a window self.window=Window:Create(self.title) --self.window:HideMouse() --do not hide the mouse pointer appWindow=self.window --set the global variable appWindow with the window just created --rest of the script/function as default
  7. here are my settings: alpha is on the diffuse texture, compression DXT5 and a snapshoot of the perspective view
  8. yes, it works ok movement is very small, which i guess is ok. don't try to modify or find a variable inside the shader to evantually set via coding. it's fbx so placing it on the assets folder automatically convert it to mdl, mat etc have to manually create the material and set the texture as dtx5 if not alpha don't behaves as spected. (i first test it with other models, but they were bought from dexsoft, and has to manipulate them the same way)
  9. try a free one http://tf3dm.com/3d-model/tree-alan-2-68600.html remember to set diffuse texture as DTX5 (for alpha to work correctly), and naturally, to modify the material for the shader, specially texture 4 equal diffuse texture for the vegetation shader.
  10. thank's, understood. then, the Dynamic drop down box is for?, shouldn't it be omitted if the entity is a brush instead of a model? or the Shadows Dynamic has another purpose. naturally, a question needs an explanation but, if there is a solution is better: must i create a Shape and attach it to it? must i create a prefab? or the only solution is to use a 3d modeler, create a box, export as mdl and then import on the editor? thank's in advance
  11. just open the MyGame\Maps\start.map wrote the rotator.lua script of: http://www.leadwerks.com/werkspace/page/tutorials/_/script/creating-your-first-object-script-r110 and attach the script to Box2
  12. i used tree objects with two meshes, one for trunk and other for branches/leaves i used shaders applied to selected meshes which vasically read and modify vertex positions giving the illusion of movement. grass waving shader do the exact thing. i'm very new here and i'm in the stage of doing (or trying to do) simple things. When i have time, i'll try to see le shaders format and see if i can modify them easily. if not, will see or wait for some one else i should read the previous post...! sorry
  13. yes, after saving, no material appear to be applied. material control is empty (also, there are no chances of de-attach a shader) With a point light seems to work ok, shadows appear as supposed to be may it be a directional light bug?
  14. thank's disabling this checkbox makes it work again!
  15. should be good not only for grass, for trees also.
  16. i'm just rotating a box, is the start map with the rotator script from tutorials i try to modify Appeareance->Cast Shadows->Static/Dynamic, no difference i see that the material has no Shadow shadder applied, does it should be applied here the shadows, which seems to be created by the faces seen of the cube, when it started to ratate. i'm shure that i'm missing something. also, i noted that, no material seems to be applied to objects. if i apply one, the text box tells the material name, but i y quit and restart the editor, again the material textbox is empty. but the object has the correct material.
  17. 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?
  18. 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.
  19. 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
  20. 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
  21. Charrua

    Veg material

    thank's dxt5 does the difference for me too!
  22. ha!, that's the hard way, i was looking for an easier one but's better than nothing! thxs
  23. 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
  24. 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
  25. 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.
×
×
  • Create New...