-
Posts
379 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by Masterxilo
-
It's not wrong in the wiki, if there are only two axis (like, for example on a plane) they're always called x, y. It's just confusing because the terrain actually lies in the xz plane.
-
Please put code in code tags. Yes, it is meant to be like that. You can't scale physics bodies.
-
The first way doesn't work because you use y as the z position, I think it should be: VObject::kiObject->Y = TerrainHeight(cTerrain, kiObject->X*2,kiObject->Z*2); // 2 is the Meter per tile and for the second way: make sure you use 0 as the pick radius, anything else doesn't work. (set your 5 to 0)
-
How can you be sure that the terrain is always the last child?
-
Might actually be useful to define a center for scaling as well. Here some updated versions: void ScaleMeshUV(TEntity mesh, TVec2 uvscale, TVec2 center = Vec2(0,0)) { for (int iSurf = 1; iSurf <= CountSurfaces(mesh); iSurf++) { TSurface surface = GetSurface(mesh, iSurf); for (int iVert = 0; iVert < CountVertices(surface); iVert++) { for (int texcset = 0; texcset < 2; texcset++) { TVec2 uv = (GetVertexTexCoords(surface, iVert, texcset) - center) * uvscale + center; SetVertexTexCoords(surface, iVert, uv, texcset); } } } UpdateMesh(mesh); } void RotateMeshUV(TEntity mesh, float angle, TVec2 center = Vec2(0,0)) { angle = deg2rad(angle); for (int iSurf = 1; iSurf <= CountSurfaces(mesh); iSurf++) { TSurface surface = GetSurface(mesh, iSurf); for (int iVert = 0; iVert < CountVertices(surface); iVert++) { for (int texcset = 0; texcset < 2; texcset++) { TVec2 uv = GetVertexTexCoords(surface, iVert, texcset); uv -= center; TVec2 rf = Vec2(cos(angle), sin(angle)); // roationFactor uv = Vec2(uv.X*rf.X - uv.Y*rf.Y, uv.X*rf.Y + uv.Y*rf.X); uv += center; SetVertexTexCoords(surface, iVert, uv, texcset); } } } UpdateMesh(mesh); }
-
Ah, ok. But how does that have to be something new the engine does? Can't you add that kind of functionality using lua?
-
Can't you scale objects in editor?
-
And I just wrote this for rotation (press the up/down keys to rotate the texture on the oil drum): #include "engine.h" #include "mathlib.h" #include <string> using namespace std; void RotateMeshUV(TEntity mesh, TVec2 rotationCenter, float angle) { angle = deg2rad(angle); for (int iSurf = 1; iSurf <= CountSurfaces(mesh); iSurf++) { TSurface surface = GetSurface(mesh, iSurf); for (int iVert = 0; iVert < CountVertices(surface); iVert++) { for (int texcset = 0; texcset < 2; texcset++) { TVec2 uv = GetVertexTexCoords(surface, iVert, texcset); uv -= rotationCenter; TVec2 rf = Vec2(cos(angle), sin(angle)); // roationFactor uv = Vec2(uv.X*rf.X - uv.Y*rf.Y, uv.X*rf.Y + uv.Y*rf.X); uv += rotationCenter; SetVertexTexCoords(surface, iVert, uv, texcset); } } } UpdateMesh(mesh); } int main(void) { // Init Initialize(); Graphics(640,480); TEntity world = CreateWorld(); TEntity buffer = CreateBuffer(640,480,BUFFER_COLOR0|BUFFER_DEPTH|BUFFER_NORMAL|BUFFER_COLOR2); // Cam TEntity camera = CreateCamera(); MoveEntity(camera, Vec3(0,0.5,-1.5) ); // Light TEntity light = CreateSpotLight(15,0); MoveEntity (light, Vec3(-1,5,-4) ); RotateEntity (light, Vec3(45,0,0), 0); SetShadowmapSize(light,512); AmbientLight(Vec3(.05)); // Ground TEntity plane = CreateCube(0); ScaleEntity (plane, Vec3(100,1,100) ); MoveEntity (plane, Vec3(0,-2.5,0) ); // Model TEntity m1 = LoadMesh("abstract::oildrum.gmf"); float angle = 0.0f; // Main Loop while(!KeyHit(KEY_ESCAPE) && !AppTerminate()) { if(KeyDown(KEY_UP) || KeyDown(KEY_DOWN)) { float fac = KeyDown(KEY_UP) - KeyDown(KEY_DOWN); RotateMeshUV(m1, Vec2(0,0), fac); angle += fac; } UpdateWorld(); SetBuffer(buffer); RenderWorld(); SetBuffer(BackBuffer()); RenderLights(buffer); DrawText(0,0,"angle: %f", angle); Flip(1); } // Terminate return Terminate(); }
-
I do this for uv scaling (move the mouse to set the uv scaling on the oil drum): #include "engine.h" #include "mathlib.h" #include <string> using namespace std; void ScaleMeshUV(TEntity mesh, TVec2 uvscale) { for (int iSurf = 1; iSurf <= CountSurfaces(mesh); iSurf++) { TSurface surface = GetSurface(mesh, iSurf); for (int iVert = 0; iVert < CountVertices(surface); iVert++) { for (int texcset = 0; texcset < 2; texcset++) { TVec2 uv = GetVertexTexCoords(surface, iVert, texcset) * uvscale; SetVertexTexCoords(surface, iVert, uv, texcset); } } } UpdateMesh(mesh); } int main(void) { // Init Initialize(); Graphics(640,480); TEntity world = CreateWorld(); TEntity buffer = CreateBuffer(640,480,BUFFER_COLOR0|BUFFER_DEPTH|BUFFER_NORMAL|BUFFER_COLOR2); // Cam TEntity camera = CreateCamera(); MoveEntity(camera, Vec3(0,0.5,-1.5) ); // Light TEntity light = CreateSpotLight(15,0); MoveEntity (light, Vec3(-1,5,-4) ); RotateEntity (light, Vec3(45,0,0), 0); SetShadowmapSize(light,512); AmbientLight(Vec3(.05)); // Ground TEntity plane = CreateCube(0); ScaleEntity (plane, Vec3(100,1,100) ); MoveEntity (plane, Vec3(0,-2.5,0) ); // Model TEntity m1 = LoadMesh("abstract::oildrum.gmf"); // ScaleMeshUV(m1, Vec2(3,2)); // some test scaling // Main Loop while(!KeyHit(KEY_ESCAPE) && !AppTerminate()) { TVec2 scale = Vec2((1.0f*Max(MouseX(),1)/GraphicsWidth())*10,(1.0f*Max(MouseY(),1)/GraphicsHeight())*10); ScaleMeshUV(m1, scale); UpdateWorld(); SetBuffer(buffer); RenderWorld(); SetBuffer(BackBuffer()); RenderLights(buffer); ScaleMeshUV(m1, Vec2(1,1)/scale); // undo above scaling Flip(1); } // Terminate return Terminate(); }
-
Nothing except the transformation matrix is passed per instance. The colored is stored in the 4th row of it (which is actually a "hack").
-
You just need to copy (maybe also renaming would work) all the files and then load these, this will give you a new model which is no instance of any other entity. Loading the same file does indeed always return just an instance. I wrote these utility functions that do exactly this: #include <string> using namespace std; TEntity LoadMeshUninstanced(str name, TEntity parent = 0) { // Prepare filename static int loadedMeshes = 0; loadedMeshes++; char buf[10]; string originalFilePath = AbstractPath(name); originalFilePath.erase(originalFilePath.length()-4, 4); string newFilePath = originalFilePath; newFilePath += "_meshInstance"; newFilePath += itoa(loadedMeshes, buf, 10); // # Copy all files CopyFile((originalFilePath+".gmf").c_str(), (newFilePath+".gmf").c_str(), false); // # Load model TEntity mesh = LoadMesh(const_cast<str>((newFilePath+".gmf").c_str()), parent); // # Delete temp files DeleteFile((newFilePath+".gmf").c_str()); return mesh; } TEntity LoadModelUninstanced(str name, TEntity parent = 0) { // Prepare filename static int loadedModels = 0; loadedModels++; char buf[10]; string originalFilePath = AbstractPath(name); originalFilePath.erase(originalFilePath.length()-4, 4); string newFilePath = originalFilePath; newFilePath += "_instance"; newFilePath += itoa(loadedModels, buf, 10); // # Copy all files // Models and lods long hr = 1; for(int lod = 0; hr != 0; lod++) { string lodAdd = ""; if(lod > 0) { lodAdd += "lod"; lodAdd += itoa(lod, buf, 10); } hr = CopyFile((originalFilePath+lodAdd+".gmf").c_str(), (newFilePath+lodAdd+".gmf").c_str(), false); } // Other files CopyFile((originalFilePath+".ini").c_str(), (newFilePath+".ini").c_str(), false); CopyFile((originalFilePath+".lua").c_str(), (newFilePath+".lua").c_str(), false); CopyFile((originalFilePath+".phy").c_str(), (newFilePath+".phy").c_str(), false); // # Load model TEntity model = LoadModel(const_cast<str>((newFilePath+".gmf").c_str()), parent); // # Delete temp files hr = 1; for(int lod = 0; hr != 0; lod++) { string lodAdd = ""; if(lod > 0) { lodAdd += "lod"; lodAdd += itoa(lod, buf, 10); } hr = DeleteFile((newFilePath+lodAdd+".gmf").c_str()); } DeleteFile((newFilePath+".ini").c_str()); DeleteFile((newFilePath+".lua").c_str()); DeleteFile((newFilePath+".phy").c_str()); return model; } Usage example: int main(void) { // Init Initialize(); Graphics(640,480); TEntity world = CreateWorld(); TEntity buffer = CreateBuffer(640,480,BUFFER_COLOR0|BUFFER_DEPTH|BUFFER_NORMAL|BUFFER_COLOR2); // Cam TEntity camera = CreateCamera(); MoveEntity(camera, Vec3(0,0,-2.5) ); // Light TEntity light = CreateSpotLight(15,0); MoveEntity (light, Vec3(-1,5,-4) ); RotateEntity (light, Vec3(45,0,0), 0); SetShadowmapSize(light,512); AmbientLight(Vec3(.05)); // Ground TEntity plane = CreateCube(0); ScaleEntity (plane, Vec3(100,1,100) ); MoveEntity (plane, Vec3(0,-2.5,0) ); // Model TEntity m1 = LoadModelUninstanced("abstract::oildrum.gmf"); PositionEntity (m1, Vec3(-1.5,0,0) ); TEntity m2 = LoadModelUninstanced("abstract::oildrum.gmf"); PositionEntity(m2, Vec3(1.5,0,0) ); PaintEntity(GetChild(m2,1), LoadMaterial("abstract::oakbranch.mat")); // Main Loop while(!KeyHit(KEY_ESCAPE) && !AppTerminate()) { UpdateWorld(); SetBuffer(buffer); RenderWorld(); SetBuffer(BackBuffer()); RenderLights(buffer); Flip(1); } // Terminate return Terminate(); } Notice both oil drums would have the "oakbranch.mat" applied if you used LoadModel.
-
And maybe all the palm types should have the same trunk/bark color.
-
Maybe he doesn't use Framewerk. What he posted is no standard terrain, it's just a mesh.
-
Is this your own program where you loaded that mesh? Make sure the buffer is created like: TEntity buffer = CreateBuffer(640,480,BUFFER_COLOR0|BUFFER_DEPTH|BUFFER_NORMAL|BUFFER_COLOR2); The last "|BUFFER_COLOR2" stores the specular intensity per pixel. Without it, you don't get any specular effects at all. This is new since some version after 2.2x (don't remember which one). Before that, specular lighting just worked.
-
Why so complicated? TVec3 *pHitForce = reinterpret_cast<TVec3*>(force);
-
^^ yeah, I wouldn't have posted just some stuff simulated using physx if it wouldn't use le for rendering. I know. And then I said that this is no argument since everything possible in the physics engine is possible in le.
-
This is just a matter of passing AppSpeed() to the update function. http://forum.leadwerks.com/download/file.php?id=969&mode=view ^^ those are held together by a distance joint. One can click on other oil-drums to make that thing "attract" these too. In the testing environment I have, I can drag bodies around with the same technique. (Is the clicking/selecting what you mean with "Selective collision system"?) Every joint in PhysX can be created with ease. Didn't have a look at these, but it would be as easy to do as it is in physx when using it with any other engine. If these are things that deform meshes (cloth, soft bodies) or create graphical effects (fluids) then it's more difficult beacause to either make them available (fluids) or make them work fast (mesh deformation), one would need better access to the rendering. Everything else that just controls entity matrices is easily possible. --- For example my system works this way: It attaches an le pivot entity to physx bodies. You can then parent any entity you want to that. You can use the rest of physx sdk as usual. --- Really, it's just a matter of using the physx sdk, there's no magic in there. Everything that works in physx will work in LE when using physx. If anyone wanted to use PhysX, there's nothing stopping him. It's just a waste of resources to have a second physics engine running at the same time. --- If that means, you think that other physic engines aren't as good/complete as newton then that statement is ok. If you're saying that it's not possible to use other physic engines to their full extent, then you're wrong.
-
sry, should have said, I was referring to
-
Any lossy compression, when used multiple times on the same data will result in noticeable quality loss sooner or later. Lossy compression is a bad thing. Unfortunately, hard-disks aren't big enough and internet connections not fast enough.
-
.gmf to .[...] (whatever, .obj, .3ds, .x, .fbx, etc.)
Masterxilo replied to Masterxilo's topic in Programming
Exactly. -
Put the mesh in another world and draw that on top of the rest, clearing the depth buffer in between.
-
This is because the gmf format stores not only raw geometry data but also transformation matrices.
-
GMFNodeSetProperty? Why would you need a GetProperty? The only way properties can be set is by your program... (The GMF sdk creates gmf files, it does not read them, so you can't edit existing files with it.)
-
That's still not the same as alpha blended textures.
-
Now that's bad to hear. Well thanks anyways, I'll have to go and optimize my mesh and the vertex weights. Thanks for the link, wailingmonkey, it'll help doing so for sure.