Jump to content

TylerH

Members
  • Posts

    525
  • Joined

  • Last visited

Everything posted by TylerH

  1. 500 milliseconds of lag, that lag in your log timing could be from the latency required to write the data to your log or print to the console...
  2. Would rendering particles before lighting give this effect?
  3. TylerH

    Progress Bar

    Here is some code I did a few months ago for Jeklynn that was based on Josh's Blitzmax code for Processing a Sandbox scene. It is in no way finished, but it shows you how to parse the SBX format and load some stuff, etc.: .CPP: #include "Game.h" #include "Platform.h" struct EntityInfo { TEntity entity; std::string id; std::string targetid[16]; }; std::list<EntityInfo> infolist; std::map<std::string,TEntity> idmap; void Tokenize(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters = " ") { // Clear the tokens list just incase tokens.clear(); // Skip delimiters at beginning. std::string::size_type lastPos = str.find_first_not_of(delimiters, 0); // Find first "non-delimiter". std::string::size_type pos = str.find_first_of(delimiters, lastPos); while (std::string::npos != pos || std::string::npos != lastPos) { // Found a token, add it to the vector. tokens.push_back(str.substr(lastPos, pos - lastPos)); // Skip delimiters. Note the "not_of" lastPos = str.find_first_not_of(delimiters, pos); // Find next "non-delimiter" pos = str.find_first_of(delimiters, lastPos); } } std::string Trim(const std::string& str) { size_t start = str.find_first_not_of(" \t\n\r"); if (start == string::npos) { return ""; } size_t end = str.find_last_not_of(" \t\n\r") - start + 1; return str.substr(start, end); } std::string StringToUpper(std::string strToConvert) { for(unsigned int i=0;i<strToConvert.length();i++) { strToConvert[i] = toupper(strToConvert[i]); } return strToConvert; } std::string StringToLower(std::string strToConvert) { for(unsigned int i=0;i<strToConvert.length();i++) { strToConvert[i] = tolower(strToConvert[i]); } return strToConvert; } void SetEntityPositionRotationScale(TEntity entity,std::map<std::string,std::string> map) { std::string s; std::vector<std::string> sarr; s = map["position"]; Tokenize(s, sarr, ","); if (sarr.size() > 2) { PositionEntity(entity, Vec3( atof(sarr[0].c_str()), atof(sarr[1].c_str()), atof(sarr[2].c_str()) ) ); } s = map["rotation"]; Tokenize(s, sarr, ","); if (sarr.size() > 2) { RotateEntity(entity, Vec3( atof(sarr[0].c_str()), atof(sarr[1].c_str()), atof(sarr[2].c_str()) ) ); } s = map["scale"]; Tokenize(s, sarr, ","); if (sarr.size() > 2) { ScaleEntity(entity, Vec3( atof(sarr[0].c_str()), atof(sarr[1].c_str()), atof(sarr[2].c_str()) ) ); } } TEntity CLevelManager::LoadScene(str filename) { std::ifstream stream; EntityInfo info; std::string s; std::string objectname; std::vector<std::string> sarr; std::string sbxversion; stream.open(AbstractPath(filename)); if (!stream) return 0; char buf[2048]; stream.getline(buf, 2048); Tokenize(std::string(buf), sarr, "_"); if (sarr[0] != "SBX") { stream.close(); return 0; } if (sarr[1] != "ASCII") { stream.close(); return 0; } sbxversion = sarr[2]; std::cout << "Parsing ASCII Sandbox Scene: " << filename << " , Version: " << sbxversion << "...\n"; TEntity root = CreatePivot(); TGroup rootgroup = CreateGroup(); while (!stream.eof()) { stream.getline(buf, 2048); s = buf; s = Trim(s); Tokenize(s, sarr, "//"); if (sarr.size() > 1) { s = sarr[0]; } Tokenize(s, sarr, "="); if (sarr.size() > 1) { SetEntityKey(root, (char*)Trim(sarr[0]).c_str(), (char*)Trim(sarr[1]).c_str()); } else { Tokenize(s, sarr, " "); if (sarr.size() > 0) { objectname = StringToLower(sarr[0]); ReadObject(objectname, stream, root, rootgroup); } } } for (std::list<EntityInfo>::iterator it = infolist.begin(); it != infolist.end(); ++it) { for (int n = 0; n < 16; ++n) { if ((*it).targetid[n] != "") { TEntity ent = idmap[(*it).targetid[n]]; if (ent) { SetEntityTarget(info.entity, ent, n); } } } } return root; } TEntity CLevelManager::ReadObject(std::string objectname, std::ifstream &stream, TEntity root, TGroup parentgroup) { TEntity entity; TBody body; TModel model; std::map<std::string,std::string> map; std::vector<std::string> sarr; std::string s; std::vector<TEntity> subobjects; TEntity o; TEntity child; TTerrain terrain; TTexture texture; char buf[2048]; while (!stream.eof()) { stream.getline(buf, 2048); s = Trim(std::string(buf)); Tokenize(s, sarr, "="); if (sarr.size() > 1) { size_t quotepos; while ((quotepos = sarr[1].find("\"")) != std::string::npos) { sarr[1].replace(quotepos, 1, ""); } map[stringToLower(sarr[0])] = sarr[1]; } else { if (s.find("{") != std::string::npos) { Tokenize(s, sarr, ""); if (sarr.size() > 1) { o = ReadObject(StringToLower(sarr[0]), stream, root, parentgroup); if (o) subobjects.push_back(o); } } if (s == "}") break; } } entity = NULL; if (objectname == "group") { } else if (objectname == "model") { std::string path = map["path"]; size_t quotepos; while ((quotepos = path.find("\"")) != std::string::npos) { path.replace(quotepos, 1, ""); } model = LoadModel((char*)(std::string("abstract::") + path).c_str()); if (!model) { AppLog((char*)("Failed to load model \""+path+"\".").c_str(),APPLOG_WARNING); } entity = model; } else if (objectname == "terrain") { } if (entity) { if (root) EntityParent(entity, root, 0); SetEntityPositionRotationScale(entity, map); if (subobjects.size() > 0) { for (std::vector<TEntity>::iterator it = subobjects.begin(); it <= subobjects.end(); ++it) { if ((*it)) EntityParent((*it), entity, 0); } } model = entity; // Lock the keys here ??? for (std::map<std::string,std::string>::iterator it = map.begin(); it != map.end(); ++it) { if ((*it).first.c_str()[0] == 34) { size_t quotepos; std::string k = (*it).first; std::string v = (*it).second; while ((quotepos = k.find("\"")) != std::string::npos) { k.replace(quotepos, 1, ""); } while ((quotepos = v.find("\"")) != std::string::npos) { v.replace(quotepos, 1, ""); } SetEntityKey(entity, (char*)(*it).first.c_str(), (char*)(*it).second.c_str()); } } // Unlock the keys here ??? SetEntityGroup(entity, parentgroup); if (map["id"] != "") { idmap.insert(make_pair(map["id"],entity)); } EntityInfo info; info.entity = entity; for (int n = 0; n < 16; ++n) { info.targetid[n] = map["target" + n]; } infolist.push_back(info); } return entity; } bool CLevelManager::LoadLevel(str sFileName) { m_sLevel = sFileName; return Load(); } unsigned __stdcall LoadLevelFunc( void* pArguments ) { printf( "In second thread...\n" ); Game::Globals:_LevelManager::getInstance()->m_eScene = LoadScene(Game::Globals:_LevelManager::getInstance()->m_sLevel); _endthreadex( 0 ); return 0; } //===================================================================== void CLevelManager::SetupLevel(str sFileName) { m_sLevel = sFileName; } //===================================================================== bool CLevelManager::Load() { if(m_sLevel == "") return false; //LoadScene(m_sLevel); m_eScene = ::LoadScene(m_sLevel); //m_eScene = NULL; //HANDLE hThread; //unsigned threadID; printf( "Creating second thread...\n" ); // Create the second thread. //hThread = (HANDLE)_beginthreadex( NULL, 0, &LoadLevelFunc, NULL, 0, &threadID ); //WaitForSingleObject( hThread, INFINITE ); Collisions(3,2,1); Collisions(2,3,1); Collisions(1,1,1); Collisions(3,1,1); Collisions(2,1,1); Collisions(3,3,1); Collisions(2,2,1); if(m_eScene!=NULL) { std::cout << "Scene Children: " << CountChildren(m_eScene) << "\n"; for(int i = 1; i<=CountChildren(m_eScene); i++) { ProcessEntity(GetChild(m_eScene, i)); } } return m_eScene!=NULL; } //===================================================================== void CLevelManager::ProcessEntity(TEntity eEntity) { str sClass = GetEntityKey(eEntity, "class", ""); str sClassName = GetEntityKey(eEntity, "classname", ""); if (sClass == "Terrain") { EntityShadowMode(eEntity, 1, 1); } //str sName = GetEntityKey(eEntity, "name", ""); //if (sName != "") //{ // SetGlobalObject(sName, eEntity); //} //float intensity = atof(GetEntityKey(eEntity, "intensity", "0.5")); //TVec4 color = StringToVec4(GetEntityKey(eEntity, "color","255 255 255 255"),0," "); //std::cout << sName << " " << GetEntityKey(eEntity, "color","255 255 255 255") << " " << GetEntityKey(eEntity, "intensity","0.5") << "\n"; //EntityColor(eEntity, Vec4(color.X/255.0*intensity,color.Y/255.0*intensity,color.Z/255.0*intensity,color.W/255.0),0); //if (sClass=="Model") //{ //int iCollisionType = atoi(GetEntityKey(eEntity, "collisiontype", "1")); //EntityType(eEntity, iCollisionType, 1); //std::cout << "Model CT: " << iCollisionType << "\n"; //SetBodyStepMode(eEntity, 1); //float fMass = (float)atof(GetEntityKey(eEntity, "mass", "0")); //SetBodyMass(eEntity,fMass); //} /*if(sClassName=="light_point") { TLight eLight = CreatePointLight((float)atof(GetEntityKey(eEntity, "range","100.0"))); PositionEntity(eLight, EntityPosition(eEntity,1),1); RotateEntity(eLight, EntityRotation(eEntity,1),1); } if(sClassName=="light_spot") { TLight eLight = CreateSpotLight((float)atof(GetEntityKey(eEntity, "range","100.0"))); PositionEntity(eLight, EntityPosition(eEntity,1),1); RotateEntity(eLight, EntityRotation(eEntity,1),1); }*/ } //===================================================================== void CLevelManager::CleanUp() { ClearWorld(); } //===================================================================== void CLevelManager::Update() { UpdateFramework(); } //===================================================================== void CLevelManager::Pause(bool bPaused) { //// pause //if (bPaused) // PauseApp(); //// unpause //else // ResumeApp(); m_bPaused = bPaused; } //===================================================================== void CLevelManager::Start() { m_bPaused = false; } //=========== .H: #if _MSC_VER > 1000 #pragma once #endif #ifndef __CLEVELMANAGER_H__ #define __CLEVELMANAGER_H__ #include "Singleton.h" #include "CTime.h" class CLevelManager { private: friend Singleton<CLevelManager>; CLevelManager(){ m_bPaused = true; } ~CLevelManager(){} public: TEntity m_eScene; bool m_bPaused; str m_sLevel; /* Loads a .sbx scene file from the path specified Returns: Success bool */ bool LoadLevel(str sFileName); /* sets the level to be loaded */ void SetupLevel(str sFileName); /* Loads the .sbx scene file that was set with SetupLevel */ bool Load(); TEntity LoadScene(str filename); TEntity ReadObject(std::string objectname, std::ifstream &stream, TEntity root, TGroup parentgroup); void ProcessEntity(TEntity eEntity); /* Deletes the previous scene, ready for another */ void CleanUp(); /* Starts game for this level */ void Start(); /* Updates the scene based on the pause state */ void Update(); /* Pauses or unpasuses the current game */ void Pause(bool bPaused); /* Saves the current game progress to a file */ void SaveState(str sFileName); /* Loads game state from a file Returns: Success bool */ bool LoadState(str sFileName); TEntity GetWorld() {return m_eScene;} bool IsPaused() { return m_bPaused; } }; #endif // __CLEVELMANAGER_H__
  4. That would be due to the resolution of the depth buffer. You can fix that by flipping it from 0-1 to 1-0, since there is more resolution towards 0 floating point than 1 floating point (according to a few documents I have read on Depth Buffer inaccuracies in OpenGL). Also, if you use overlay=1 and zsort=1 in the material file for the decal it should help fix the Z-Fighting.
  5. If it isn't class, it would have to be classname as the key. It works, I used it in Jeklynn Heights in C++ for the 3rd person camera collision. It would react differently to terrain and meshes, based on a check against the key. Not sure if something has changed regarding this between 2.30 and 2.31, so I guess I can say I haven't tried it "yet/now". Let me test...
  6. GetEntityKey(entity,"class") should return "Mesh" or "Model" for a mesh type entity, and "Terrain" for terrain.
  7. I'm not sure where I ultimately uploaded it to, so here is the Lua Script (I think it works from my last trial...) EDIT: Yep, works nicely. From what I can tell, with a higher than 1 tessellation (in the properties) it will match terrain perfectly. Choose tessellation based on the resolution and meters per tile of your terrain. Decal.zip
  8. Interesting, still free for non-commercial use, for the win.
  9. I made a terrain decal patch a while back, in Lua, that was a thingoid that could be dragged around with the mouse. Sounds like exactly what you are trying to do...and it was optimized over a week of trials by myself and others, so it renders with little effect on FPS, if any.
  10. TylerH

    Menus in LE

    I used to have a nice set of code and a UI menu for binding keys and/or mouse buttons to different actions, but it was in C#. I will look for it if anyone is interested.
  11. I think you need to have the position non-transformed first, I had to experiment with variations of the position code in my particular implementation because I modify entity positions and undo them, hence all the transforms I have. I would try just placing the decal at 0,0,0 on an entity, then try 0,0,0 transformed between various spaces. Hope that helps!
  12. In 2D: angle *= rand() * 6.28; // Pi*2, rand() should be a float between 0 and 1 float cosa = cos(angle); float sina = sin(angle); return vec2(cosa * x - sina * y, sina * x + cosa * y); In 3D: (up should be the local up vector, or a vector perpendicular to the vector you are testing against) // Rotate up vector by random amount around this Quaternion q; q.FromAngleAxis( rand() * 6.28, v ); up = q * up; // Finally rotate this by given angle around randomised up q.FromAngleAxis( angle, newUp ); return vec2(q * v); (Slightly modified from OGRE) NOTE: The above will give you deviant vectors that are offset by the angle, you can place some simple limits on the 0-1 random value to make it a cone shape, and then iterate a step function over however many segments of the cone you want to have (64 super precise, or 8 not so much).
  13. I think Josh's point in creating the project is that the engine has a nice set of features, and no fully playable game has been completed entirely. I think he wants to see what the community can do to produce a stunning game by working with him and his engine, and provide something that will benefit everyone in all time to come. Once you have a working codebase for a game layer, focusing all your time on bugs and new features becomes rudimentary, not to mention all the improvements that will come about during the progression of the game project.
  14. Not sure, I was being a huge jerk right before my inactive period started? And it is all good, I am all for just keeping your single wrapper, updated and improved to a single, community tool.
  15. That is always an option. Did I miss something during my inactive period that made entity messages obsolete?
  16. I would like to help relieve some of your burden with the C# wrapper (namely getting all the 1.2 features listed there done). I am back to developing with C#, for reasons beyond anyone's concern (Still using C/C++ and UnrealScript and Lua primarily, but you can't beat C# to just write applications for whatever reason...). If everyone here utilizing C# wouldn't mind letting me in to the society, I would be glad to devote more of my time specifically to C#, the wrapper, answering questions, porting code, and writing cool stuff for C#. Cheers, Tyler
  17. Wait, what did I do? Edit: Nevermind, heh.
  18. TylerH

    lgui

    Not sure if the Lua UI you are talking about is the stuff that has been there for a while and has the dark blue gradient theme. You can all shoot me for that. I coded it for Josh as some contract work, and the more I look back on it, the more I see how I could have done better. I feel like I let everyone, especially Josh, down with it
  19. This is a simple poll, that can have lasting, constructive results on the community and how we can continue developing thingoids and other entities, both in Lua and C/C++, across multiple developers who may not even know each other, but can build off of other published entities and communicate with them due to a standardized format for message handling. My proposal is this (the theory, not the example formatting I am using): Even though we have the single-state Lua development model for the Editor and the Engine now, entities still will have a level of communication via the Leadwerks Entity Message System. This is key, because it is core in the engine, and works across all language barriers, namely Lua <---> C/C++/Blitzmax. The key theory here, is to have a standard format for the names, values, purpose, function, etc. of various messages, and code base entity classes that have hooks for interface, not necessarily functionality and implementation, of all of these standards. The main points of the idea are as such: A community-managed, standardized, extended core class.lua type file that contains all of the to-be-mentioned functionality A standard form of communication, via messages, between entities through the entity SendMessage, ReceiveMessage, etc. set of methods and callbacks Some type of standard format that all message names would share, that is human-readable/friendly, informs purpose, and provides description. Such an example would be: "Info_Position_Update",a message that an entity would send to another entity to give it its position as an update. Another example could be: "Game_AI_PlayerSeen". Squad AI thingoids could send this message and relay it to other squad members to alert them that the player is seen. Those are VERY specific examples, but standards always help with things like this. You could have a general purpose prefix, like Info, Game, Engine, Render, etc. to indicate what the message will be relaying or functioning FOR. Follow that with a topic, such as Entity, [Position,Rotation,Scale], Model, Force, Joint, Weapon, Projectile, etc. to tell WHAT the message is ABOUT. Follow that with more and more WHAT's to describe the message further (Game_Vehicle_Tank is more descriptive than Game_Vehicle, e.g.). End it with a WHAT it is DOING, for example Update, Kill, Alert, DriveForward, Expload, Enter, Exit, Spawn, etc. (these are the specific parts). This would form a hierarchy similar to: FOR -> WHAT [specific What] -> HOW/WHY It would simulate: Namespace -> Class -> Method, but in a message form that all entities could support and share. Someone developing a weapon thingoid, would know from checking the standard that the AI and Player thingoids have messages the Weapon thingoid can utilize to interact with said pawn thingoids (AI and player). And vice versa, and so on. So, what do you all think?
  20. Yeah, I got sidetracked by life, for approximately 2-3 months.
  21. I found that a while back, we have been utilizing that code, in a GLSL shader, for loads of things. The updated Saturation, Contrast, Brightness shader I posted a while back utilized that guy's code.
  22. I remember when I accidentally applied the sway shader from the hair of the Jeklynn Heights barborshop to the entire barborshop building, and had the whole thing looking like it was made of jello because of the massive poly count.
  23. That does make sense. UDK has like 50 different light types.
  24. Josh: Can you compile a version of the editor using a Debug build? May make it easy to find any leaks if there are in fact any. I just couldn't think of any other reason for the exponential decay of the AppSpeed over time (I am talking days to weeks of having the editor application open).
  25. I found out that Leadwerks does a few things that, overtime, kill your computer and all Leadwerks apps (until you restart): - Something is wrong with the OpenAL implementation, it eats up all the buffers and for some reason won't close them all when the application is terminated, so over time, no other audio applications can use them (if they use OPenAL), and your speakers will start to play load-pitched static, and the sounds from Leadwerks that were cached (usually from the editor I hear the underwater loop and the barrel impact sounds). - Overtime, the amount of RAM Leadwerks is using increases, and even after ending the processes or closing the programs, that RAM usage is still there. - Overtime, the Application Speed degrades (THIS IS WHAT CAUSES THE JERKY MOVEMENT). Anything in any Leadwerks application that is modified by AppSpeed, will have that jerky movement, rotation, interpolation, etc. I can't say what causes this, but I can assume that the timer Leadwerks is using internally degrades after a while for whatever reason, and you start to get ridiculous AppSpeed returns: It will fluctuate, for me, anywhere between -5 and 500000, until I restart.
×
×
  • Create New...