Jump to content

DarthRaff

Members
  • Posts

    152
  • Joined

  • Last visited

Everything posted by DarthRaff

  1. Hello, Can someone, please, tell me what am i doing wrong ? i'm trying to translate it from lua with no success, thank you very much. if (KeyHit(KEY_E)) { TPick pick; pick = CameraPick(&pick,cam,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,3.0),0,0); if (pick) { do { if (GetEntityKey(pick.entity,"class") == ENTITY_MODEL) { break; } pick.entity = pick.entity.parent; } while (!pick.entity); if (pick.entity) { SendEntityMessage(pick.entity,"use"); } } }
  2. Ok, thank you very much
  3. Thank you very much Macklebee, it's working at last
  4. DarthRaff

    Messages

    Hello, I can't find any example of an object receiving a message of "use" ( sent by the player, i suppose ), and how it works. I found how to send a message when a key is pressed but not how to receive it, can someone, please, help me with that ? I'm very confused with that, thank you
  5. Well, my intention is to check the door system in the editor without use any game or controller script, but don't know if it's possible. I tried a pick function i found in a script but, don't know if i can do it that way. Actually there is no message sending or received, yet. Is this code correct ? if KeyHit(KEY_E)==1 then pick=CameraPick(fw.main.camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,2.0),0,0) if pick~=nil then repeat if pick.entity:GetClass()==ENTITY_MODEL then break end pick.entity=pick.entity.parent until pick.entity==nil if pick.entity~=nil then --pick.entity:SendMessage("use",controller,0) self:CheckDoor() self.model:SetKey("estado",self.estado) end end end i' d like to know if it's correct and can do it that way before do the next step, sorry for being bored and thank you.
  6. Ok, thank you for the advise, i changed the spelling and the position of the functions in the script. Thank you very much for the answer Macklebee, i will try the pick and message.
  7. Hey, I tried this and works perfectly but just in the first object i created. If i try to put more than one object then it doesn't work in the others , just in the first one. But the position, rotation, and all that props works in all the objects. How to do, please, for have the other functions working in all the objects of the same class ? Here is the code: require("scripts/class") require("Scripts/constants/engine_const") local class=CreateClass(...) function class:InitDialog(grid) self.super:InitDialog(grid) --group=grid:AddGroup("type") --group:AddProperty("tipo",PROPERTY_STRING) group=grid:AddGroup("estados") group:AddProperty("initialrot",PROPERTY_INTEGUER) group:AddProperty("finalrot",PROPERTY_INTEGUER) --group:AddProperty("rot",PROPERTY_INTEGUER) group:AddProperty("estado",PROPERTY_STRING) group:AddProperty("speed",PROPERTY_FLOAT,"-1,1,1") group:Expand(1) end function class:CreateObject(model) local object = self.super:CreateObject(model) --object.model:SetKey("tipo","") object.model:SetKey("initialrot",90) object.model:SetKey("finalrot",0) object.model:SetKey("estado","0") object.model:SetKey("speed",0.6) function object:UnlockKeys() self.estado = self.model:GetKey("estado") end function object:Update() if KeyHit(KEY_E)==1 then self:CheckDoor() self.model:SetKey("estado",self.estado) end end function object:CheckDoor() if EntityDistance(fw.main.camera,self.model) < 3 then if self.estado == "0" then self.estado = "1" --self.model:OpenDoor() else self.estado = "0" end end end end I tried my self but can't find the solution, thank you
  8. Yes, i'm agree with Mack and Pixel, i tried it before, out of the editor, and works very well.
  9. Ok, thank you everybody, i will try
  10. Thank you very much, that's what i looking for by now. I'm try to translate a door system in lua. I have it working on c++ but i want to see the behaviour of the system in the editor. Thank you again
  11. Hello, I have that code that works perfect: require("scripts/class") require("Scripts/constants/engine_const") local class=CreateClass(...) function class:InitDialog(grid) self.super:InitDialog(grid) group=grid:AddGroup("Rotation") group:AddProperty("rotationspeed",PROPERTY_VEC3) --group:AddProperty("rotationspeed",PROPERTY_FLOAT) end function class:CreateObject(model) local object = self.super:CreateObject(model) object.model:SetKey("rotationspeed","0.0,1.0,0.0") --object.model:SetKey("rotationspeed","1.0") function object:SetKey(key,value) if key=="rotationspeed" then self.rotationspeed = StringToVec3(value) --self.rotationspeed=(value) else return self.super:SetKey(key,value) end return 1 end function object:Update() if KeyHit(KEY_E) == 1 then self.rotationspeed.y=self.rotationspeed.y*-1 --self.rotationspeed=self.rotationspeed*-1 end model:Turn(self.rotationspeed,0) end end If i comment the rotationspeed Vec3 property and uncomment the rotationspeed float property, and the other changes, it doesn't work. I try to look in the scripts and models folders to do my self but can't find the solution. I want to use just a float version of the rotationspeed property. can someone, please, help me ? thank you
  12. DarthRaff

    KeyHit

    Ok, thank you very much
  13. DarthRaff

    KeyHit

    Hello everybody and very happy new year !! i usually program in c++ but i wanted to try lua for doors in the editor. I have a door sistem writed in c++ that works and i changed a little the code to addapt it to lua but not work. <So i decided to try something easier and wrote a simple program that creates a cube rotating to the right and when hit key e the rotation direction have to change but the direction changes from the beggining and does nothing when press e. So, please, what am i doing wrong ? here is the code and thanks in advance require("Scripts/constants/engine_const") RegisterAbstractPath("") Graphics(1024,768) fw=CreateFramework() cam=fw.main.camera cam:SetPosition(Vec3(0,0,-2)) light1 = CreateDirectionalLight() light1:SetRotation(Vec3(45,45,0)) mesh=CreateCube() mesh:SetPosition(Vec3(0,0,0)) vel=0.5 while KeyHit(KEY_ESCAPE)==0 do if KeyHit(KEY_E) then vel=-0.5 end mesh:Turn(Vec3(0,vel,0)) fw:Update() fw:Render() Flip(0) end
  14. DarthRaff

    River Editor

    impressive, and necessary. very good work .
  15. Aha, ok, thank you very much. b3d2gmf is that i use, i just wanted to try the obj converter. Thank you very much for your replies.
  16. not working, thank you. But if i try without +mesh like this : obj2gmf "name.obj" +scale 0.1 -nocolor, then it works but not performs the scale, don't know why.
  17. hello, thank you for the answer. I tryied without +mesh and works but doesn't scale, and i need to scale.
  18. Hello, can someone tell me how can i use the obj converter from cmd, please? I'm trying like this: obj2gmf +mesh "name.obj" +scale 0.1 -nocolor, and it doesn't work, but if i use it by clicking in it, then works but can't scale. thank you.
  19. Hello, Here you go ( and thank you ) : Projector spot.rar
  20. aha, ok, thank you for the advise.
  21. Hello, sorry, because i'm not a great programmer, and, if it was so simple, maybe it just was already made, but when you open the editor and have a new object that not was in the list last time you opened the editor, it make a phy file of that object, automatically. And, if you close the editor, erase the phy file, scale the object and open again the editor, a new phy file of that object, is created and works perfectly. So why is so difficult or impossible to make a script that erases and creates a new phy file from the object you scale, like when the editor is opened? or just the same part of program that creates the file when open the editor? Sorry again because probably it's not possible.
  22. Yes feeling stupid more and more. You are right now Framewerk working. I hate when i forget things thinking i have all correctly copied. I make other users, who kindly helps me, waste theire time. Sorry thousand times. Very angry with myself. Sorry again and thank you very much.
  23. Sorry, i'm feeling so stupid. I copied the shaders.pak the first time but then i forgot it the following time. Now working all except the transparency. I need to set it correctly but i don't know how to set the layer or whatever by now. Thank you very much and sorry .
  24. Well, copying framewerk.cpp and all the necessary .cpp's and .h's doesn't work so i can't use framewerk any more (what a pity so easy of use ). And framework gime me problems, please help
  25. Thank you very much for your answers. Not tryed copy the files because i thought that if it's a new version framewerk.cpp and framewerk.h don't will work. but i will try. Yes i found the page and i'm try the appropriate changes but i have an error. Here is the code: //#include "framewerk.h" #include "engine.h" #include <math.h> #include <string> #include <vector> #include "monsterfuncs.h" //#include <iostream> #include <sstream> using namespace std; string nametext; string picname; int countimage=0; #pragma warning(disable:4996) int state; float fb; float fe; int animtex; TController player; TMesh mirillasprite; TMaterial mirillamat[2]; TTexture mirillatex; TMesh telaranya1; TTexture electrictex[5]; TTexture electrictexdot[5]; TMaterial electricmat; //TTexture electrictex; //TTexture electrictexdot; string StringToInt(int number) { stringstream ss;//create a stringstream ss << number;//add number to the stream return ss.str();//return a string with the contents of the stream //return (str)ss.c_str(); } class Monster { public: TController monstercont; TMesh monsterent; TVec3 monsterpos; TVec3 monsterrot; int monsterstate; float mstartframe; float mendframe; //TMaterial monstermat; }; vector<Monster> monsterarray; vector<Monster>::iterator monsteriter; void LoadTextureSeq(string name,int num) { string tn; string tndot; int n=0; for(n=0;n!=num;n++) { tn="objs/monsters/DK1/"; tn+=name; tn+=StringToInt(n+1); tn+=".dds"; electrictex[n]=LoadTexture((str)tn.c_str()); tndot="objs/monsters/DK1/"; tndot+=name; tndot+=StringToInt(n+1); tndot+="dot3"; tndot+=".dds"; electrictexdot[n]=LoadTexture((str)tndot.c_str()); } } void UpdateTexture(int num) { animtex++; if(animtex > num-1) { animtex=0; } SetMaterialTexture(electricmat,electrictex[animtex],0); SetMaterialTexture(electricmat,electrictexdot[animtex],1); } void UpdateMonsters() { for(monsteriter=monsterarray.begin();monsteriter!=monsterarray.end();monsteriter++) { SlowPointEnt((*monsteriter).monstercont,player,.5); //PointEntity((*monsteriter).monstercont,player,3,0.5f,.0f); (*monsteriter).monsterrot=EntityRotation((*monsteriter).monstercont); UpdateController((*monsteriter).monstercont,(*monsteriter).monsterrot.Y,0.0f,0.0f,0.0f,500); RotateEntity((*monsteriter).monsterent,(*monsteriter).monsterrot); PositionEntity((*monsteriter).monsterent,Vec3((*monsteriter).monsterpos.X,(*monsteriter).monsterpos.Y-1.02,(*monsteriter).monsterpos.Z)); if(KeyHit(KEY_UP)) { if((*monsteriter).monsterstate <3) { monsteriter->monsterstate++; } else { monsteriter->monsterstate=0; } } if(KeyHit(KEY_DOWN)) { if((*monsteriter).monsterstate >0) { monsteriter->monsterstate--; } else { monsteriter->monsterstate=3; } } switch ((*monsteriter).monsterstate) { case 1: monsteriter->mstartframe=41.0f; monsteriter->mendframe=85.0f; break; case 2: monsteriter->mstartframe=90.0f; monsteriter->mendframe=117.0f; break; case 3: monsteriter->mstartframe=149.0f; monsteriter->mendframe=184.0f; break; default: monsteriter->mstartframe=1.0f; monsteriter->mendframe=40.0f; break; } AnimeEntitySeq((*monsteriter).monsterent,(*monsteriter).mstartframe,(*monsteriter).mendframe,3.0f,100.0f); //PaintEntity((*monsteriter).monsterent,electricmat); } } float IntToFloat1(int n) { return(float(float(n)/float(255.0))); } TVec4 StringToVec4(string s, int noconv=0) { flt a[4], cf=0; int p=0, q=0, i=0, ci=0; string c; if(s.length()>0) { while(p<=(signed)s.length()) { q=p+1; p=(s+" ").find(" ",q)+1; c=s.substr(q-1,p-q); if((c.find(".")!=-1)|(noconv)) { sscanf(c.c_str(),"%f",&cf); a[i]=cf; } else { sscanf(c.c_str(),"%d",&ci); a[i]=IntToFloat1(ci); } i++; } } return(Vec4(a[0],a[1],a[2],a[3])); } void ProcessSceneObjects(TEntity scene) { TEntity ent; TModel entmesh; TVec3 entpos; string s=""; string cname; string cname2; TVec4 color; int intensity; //TMaterial doormat; for (int i = 1; i <= CountChildren(scene); i++) { ent = GetChild(scene,i); cname=GetEntityKey(ent,"classname",""); if(cname=="room") { EntityType(ent,2); } if(cname=="playerstart") { PositionEntity(player,EntityPosition(ent)); } } } int main( int argn, char* argv[] ) { int screenx=1280, screeny=960, camx=screenx/2, camy=screeny/2; Initialize() ; //Create a graphics context Graphics(screenx,screeny); TFramework framework=CreateFramework(); TLayer layer = GetFrameworkLayer(0); TCamera cam=GetLayerCamera(layer); PositionEntity(cam,Vec3(0,0,0)); TListener listener=GetFrameworkListener(); EntityParent(listener,cam); //Set Lua variable BP L=GetLuaState(); lua_pushobject(L,framework); lua_setglobal(L,"fw"); lua_pop(L,1); // Setup Initial Post Processing FX SetGodRays(1); SetHDR(0); SetSSAO(1); SetBloom(0); SetAntialias(1); SetStats(2); // Setup Collisions Collisions(1, 1, 1); Collisions(1, 2, 1); Collisions(1, 3, 1); Collisions(2, 2, 1); Collisions(2, 3, 1); Collisions(3, 3, 1); Monster m; m.monstercont=CreateController(2.7f,0.9f,0.25f,45); //GetFrameworkLayer(1); m.monsterent=LoadMesh("objs/monsters/DK1/Material4/dk1.gmf"); //GetFrameworkLayer(0); m.monsterrot=Vec3(0.0f,0.0f,0.0f); m.monsterpos=Vec3(0.0f,1.5f,-2.0f); m.monsterstate=0; RotateEntity(m.monstercont,m.monsterrot); RotateEntity(m.monsterent,m.monsterrot); PositionEntity(m.monstercont,m.monsterpos); PositionEntity(m.monsterent,m.monsterpos); EntityType(m.monstercont,2); SetBodyMass(m.monstercont,80.0f); //electricmat=LoadMaterial("objs/monsters/DK1/electric1.mat"); //PaintEntity(m.monsterent,electricmat); monsterarray.push_back(m); int sequence=1; float framebegin; float frameend; float frame; ////Load Texture Seq //LoadTextureSeq("electric",5); //Create a physics body TBody body=CreateBodyBox(); SetBodyMass(body,10.0f); TMesh mesh=CreateCube(); EntityParent(mesh,body); PositionEntity(body,Vec3(-6,5,0)); EntityType(body,2); TMaterial meshmat=LoadMaterial("objs/Pruebas/a1.mat"); PaintEntity(mesh,meshmat); //Create another physics body TModel oildrum=LoadModel("scene/oildrum.gmf"); PositionEntity(oildrum,Vec3(6,5,0)); EntityType(oildrum,2); SetBodyMass(oildrum,10.0f); player=CreateController(1.84f,0.50f,0.5f,45); //player=CreateController(1.84f,0.50f,0.5f,45); EntityType(player,1); //SetBodyDamping(player,.5f,.5f); SetBodyMass(player,60.0f); //SetWorldGravity(Vec3(0,-9.8f,0)); float move=0.0; float strafe=0.0; bool crouch=0; float cameraheight=1.74f; TVec3 camrotation=Vec3(0); TVec3 playerpos; float mx=0; float my=0; HideMouse(); //MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); MoveMouse(camx,camy); PositionEntity(player,Vec3(0.0f,3.0f,-3.0f)); GetFrameworkLayer(1); mirillasprite=LoadMesh("Sprites/simplesprite1.gmf",GetLayerCamera(layer)); mirillamat[0]=LoadMaterial("Sprites/white.mat"); mirillamat[1]=LoadMaterial("Sprites/green.mat"); mirillatex=mirillamat[0]; PaintEntity(mirillasprite,mirillatex); PositionEntity(mirillasprite,Vec3(0,0,0.15)); ScaleEntity(mirillasprite,Vec3(.08f,.08f,1.0f)); telaranya1=LoadMesh("Sprites/simplesprite2.gmf"); ScaleEntity(telaranya1,Vec3(2.0f,2.0f,1.0f)); PositionEntity(telaranya1,Vec3(3.0f,1.5f,.0f)); RotateEntity(telaranya1,Vec3(.0f,45.0f,.0f)); GetFrameworkLayer(0); LoadScene("scene/prueba5.sbx"); int debphy=0; //Main loop // Game loop while( !KeyHit(KEY_ESCAPE) && !AppTerminate() ) { if( !AppSuspended() ) // We are not in focus! { if(KeyHit(KEY_P)){debphy=1-debphy;DebugPhysics(debphy);} move=(KeyDown(KEY_W)-KeyDown(KEY_S)); strafe=(KeyDown(KEY_D)-KeyDown(KEY_A)); //Jumping float jump=0.0; if (KeyHit(KEY_SPACE)) { if (!ControllerAirborne(player)) { jump=4.0; } } //Run if (KeyDown(KEY_LSHIFT)||KeyDown(KEY_RSHIFT)) { if (!ControllerAirborne(player)) { move/=2.0; strafe/=2.0; } } //crouch if (KeyHit(KEY_C)){ //if (ControllerCrouched(player)){ if (crouch==1){ crouch=0; cameraheight=1.74f; } else{ crouch=1; cameraheight=0.80f; } } playerpos=EntityPosition(player); //Camera looking mx=Curve(MouseX()-GraphicsWidth()/2,mx,6); my=Curve(MouseY()-GraphicsHeight()/2,my,6); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); camrotation.X=camrotation.X+my/5.0; if (camrotation.X < -90){ camrotation.X = -90;} if (camrotation.X > 90){ camrotation.X = 90;} camrotation.Y=camrotation.Y-mx/5.0; RotateEntity(cam,camrotation); ////Set controller input UpdateController(player,camrotation.Y,move*3.0,strafe*3.0,jump,500,1,crouch); PositionEntity(cam,Vec3(playerpos.X,playerpos.Y+cameraheight,playerpos.Z)); TVec3 camerapos=EntityPosition(cam); TVec3 poscont=EntityPosition(player); if(MouseDown(2)) { mirillatex=mirillamat[1]; } else { mirillatex=mirillamat[0]; } GetFrameworkLayer(1); PaintEntity(mirillasprite,mirillatex); GetFrameworkLayer(0); UpdateAppTime(); UpdateWorld(AppSpeed()) ; PositionEntity(cam,camerapos); //UpdateTexture(5); UpdateMonsters(); UpdateFramework(); RenderFramework(); if(KeyHit(KEY_F1)) // Press F1 to save a screenshot { countimage+=1; picname="Pics/ScreenShoot_"; picname+=StringToInt(countimage); picname+=".jpg"; char fn[32] = {0}; _snprintf(fn, 31, (str)picname.c_str(), GetTickCount()); SaveBuffer(BackBuffer(), fn, 100); } // Send to screen Flip(0) ; } } //// Done ////exitapp: FreeFramework(framework); return Terminate() ; } and the error (it's not an error but it appears in the engine text): Leadwerks Engine 2.40 Initializing Renderer... OpenGL Version: 3.0.0 GLSL Version: 1.30 NVIDIA via Cg compiler Render device: GeForce 9800 GT/PCI/SSE2 Vendor: NVIDIA Corporation DrawBuffers2 supported: 1 32 texture units supported. GPU instancing supported: 1 Max batch size: 64 Shader model 4.0 supported: 1 Conditional render supported: 0 Error: Shader file "abstract::query.vert" not found. i don't know what is that file because i never had that error before. Thank you
×
×
  • Create New...