Jump to content

Rick

Members
  • Posts

    7,936
  • Joined

  • Last visited

Everything posted by Rick

  1. Does the SetFriction() function even work? The value I pass to the keneticfriction param (the one that as I understand stops the physics body when I stop applying force) is 50000000 but no matter how many more zeros I add the body still slides way too long after I let go, and I was able to cap the velocity of movement so it's not moving that fast.
  2. I'm playing around with a physics camera for an RTS style (top/down angled). I'm setting a high friction value but that still doesn't seem to make the camera stop smoothly when I release the keys that move the camera. Any ideas on how to get a smooth start/stop using a physics camera? When I let go of the keys I'd want maybe 1-2 seconds of small movement in the same direction from the point at which I let go of the keys. Also I'm just adding force while the keys are down so it gets faster and faster. I like the idea of acceleration but only to a point where I'd want to maintain that velocity and never go over it.
  3. Rick

    Access violation

    Nevermind, this was all being created before LE was initialized. All good now
  4. Rick

    Access violation

    So I'm trying to get a RTS style camera where W always move forward, S moves backwards, etc but the camera is angled pointing down. I can't get the camera to move though. <man can we get the code formatting fixed for these forums > header #pragma once #include "Leadwerks.h" using namespace Leadwerks; class RTSCamera { private: Pivot* pivot; Shape* shape; public: RTSCamera(void); ~RTSCamera(void); void StartingPosition(Camera& camera); void Update(Window& window, Camera& camera); }; source #include "RTSCamera.h" RTSCamera::RTSCamera(void) { shape = Shape::Sphere(); pivot = Pivot::Create(); pivot->SetShape(shape); shape->Release(); pivot->SetPhysicsMode(Entity::RigidBodyPhysics); pivot->SetMass(1); //pivot->SetGravityMode(false); } RTSCamera::~RTSCamera(void) { shape->Release(); pivot->Release(); pivot = NULL; shape = NULL; } void RTSCamera::StartingPosition(Camera& camera) { pivot->SetPosition(camera.GetPosition(true), true); } void RTSCamera::Update(Window& window, Camera& camera) { Vec3 velocity = Vec3(); Vec3 currentVelocity = pivot->GetVelocity(); Vec3 finalVelocity = Vec3(); if(window.KeyDown(Key::W)) velocity.z++; velocity *= 20; velocity = Transform::Vector(velocity, &camera, NULL); finalVelocity = (velocity - currentVelocity) * 60; if(finalVelocity.Length() > 0) pivot->AddForce(velocity); camera.SetPosition(pivot->GetPosition(true), true); }
  5. Rick

    Access violation

    I still get access violation with the below code. TJ I'm using a Sphere not a Box as in your example. I removed the params as the default does have a size but I get the same error. shape = Shape::Sphere(); pivot = Pivot::Create(); pivot->SetShape(shape); shape->Release(); pivot->SetPhysicsMode(Entity::RigidBodyPhysics); pivot->SetMass(1); pivot->SetGravityMode(false); // access violation
  6. My understanding of this is that when we are passing pointers of LE objects to other LE objects we have to make sure all those objects that were passed the pointer know if the pointer is still valid or not before it uses it. So I assume inside these LE objects it calls RefCount() before using any external LE object to make sure it's > 0. 1) Why not just have the LE functions call AddRef() for the functions that accept pointers to other LE objects on the passed in object so we don't have to remember to do this manually? Is it because we want to give them a chance to use objects in multiple places? How often is this really done? Is it really hard to use objects for only 1 thing? It's much more common, and required in some cases, that we need to pass LE objects to other LE objects. 2) I think we aren't supposed to call delete on any LE pointers but just Release() which would reduce the count and if it's the last usage the count would be 0. When does LE actually delete the underlying LE resource then? 3) I assume calling ::Create() sets the internal ref count to 1 (or the ctor of the Entity class)? 4) Why not have LE objects look at the RefCount() inside the destructor and decide if it should actually delete the resources or not if the RefCount() = 0? This way we can still use the normal C++ 'delete object' instead of release. ie -- LE Code class Entity { private: Shape* _shape; public: void SetShape(Shape* shape) { _shape = shape; // le doing it automatically for us because we know it needs to be done anyway so why make the programmer remember to do this? shape.AddRef(); } virtual ~Entity() { if(RefCount() == 0) { // actually delete the contents of this class } } void Release() { // if a shape was passed into SetShap() then we know it has to be released so let's do it for the programmer if(_shape != NULL) _shape->Release(); } };
  7. Normally the access violation happens when we try to call a method of a pointer that's not pointing to anything. Below I get this on SetGravityMode() of the pivot. The pivot variable is valid as SetMass() works. What am I missing? RTSCamera::RTSCamera(void) { shape = Shape::Sphere(0, 0, 0, 1, 1, 1, 0, 0, 0); pivot = Pivot::Create(); pivot->SetShape(shape); shape->AddRef(); pivot->SetMass(1); pivot->SetGravityMode(false); /// gives me access violation }
  8. Is it really sabotage? I mean they don't have to support OpenGL if they don't want to. I think they just don't put as much effort into OpenGL vs DX which is understandable given they own DX and not OpenGL.
  9. For normal C++ stuff, all pointers should be set to null when finished with them and before accessing you should also check against null before trying to use it.
  10. That almost always means a variable isn't initialized correctly. My guess is finding this bug and if it's an init issue, you'll always init every variable from now on if you don't already Read the first answer to this to understand more. http://stackoverflow.com/questions/312312/what-are-some-reasons-a-release-build-would-run-differently-than-a-debug-build
  11. You are most likely using a pointer that points to nothing. You could put some logging in your game and start narrowing it down to where it's happening. I usually put some printf()'s in major sections of my game and then start putting printf()'s in a more specific area as things narrow down.
  12. Because C++ is better than C? I mean it has 2 pluses after it... (begin language flamewar!)
  13. I would be wanting to mix 2 animations. All the character models we can buy always have a run animation and almost all their attacks are when standing still. So if I want to play their attack animations while they are running I would want to play the run animation on the lower 1/2 and the attack animation on the upper 1/2.
  14. See that's interesting because that animates the entire mesh first, then the upper body, but Josh just said to animate lower body and upper body separate right now. Does it really matter? Are there differences between the 2 methods?
  15. OK, then I'll make the system I have in mind where linking actor state to animation(s) and all the animation stuff is done in the setup instead of during an update. I really crave a way to just say actor state run = run animation, or actor state run+shoot plays the run on bottom 1/2 and shoot on top 1/2 where I just do all this in the setup and don't have to handle it myself for each situation in the main loop. Thanks
  16. Let's say I have a run animation and a shoot animation (separate animations). If I want to play the shoot animation while running would I need to get the lower body bone and play the run animation on that and then get the upper body bone and play the shoot animation on that or would I play the entire run animation on the entire model and then get the upper body bone and play the shoot animation after the entire body run animation, or would that cause them to fight with each other? I know the LE 2 doc had a section on this but can't remember what it said or where it is. If it's getting both sub bones for upper and lower and playing them, then I have a method to manage transitions in mind but if I can just play the entire run animation on the model and then layer on top of that the shoot animation for upper body then my idea isn't really needed.
  17. if animation.mode==0 then frame = currenttime * animation.speed + self.frameoffset else mode 0 being loop I think. How does this work? I would think this would keep increasing the frame past the max frame value of the given animation sequence. Wouldn't/shouldn't that throw some kind of error?
  18. I thought the publish created the project for that platforms IDE?
  19. http://www.codeproject.com/Articles/363338/Factory-Pattern-in-Cplusplus Notice this section in the factory: AnimalFactory::AnimalFactory() { Register(“Horse”, &Horse::Create); Register(“Cat”, &Cat::Create); Register(“Dog”, &Dog::Create); Register(“Spider”, &Spider::Create); } With a stl::map you can link a string to a static class function called something like Create() that returns a pointer to that class type (note the return type of the Create function needs to be a pointer to a base class). Just note instead of a switch to decide you are moving it to a stl::map and having to call a Register() method for each possible type. I think this is cleaner than a switch, but more complicated as you're storing a function pointer in a map.
  20. Following tutorials is a good idea. The first thing that stands out is the #ifndef stuff at the top. I think that's pretty old school these says where you can just use #pragma once instead, which is cleaner and I think most all modern compilers support it.
  21. Factory pattern? but in any case (as far as I know) in C++ you'll have to add some kind of code for a new class since it lacks reflection itself. Either a switch like you have, or registering a class object by creating it for the factory pattern.
  22. You can put multiple class definitions in a file but it's very common practice to use 1 header/source file per class. I would stick with that if I were you. A class doesn't really have scope because it's a blueprint of a type. When you create an object of a given class the scoping of that object follows the same rules as any other variable, which means you can make the variable global if you want (I would avoid this however). Look at a C++ project in Leadwerks 3. Notice how it has an App class which an object of the App class gets created in int main() inside Main.cpp. The scope of that app object created from the App class is local to the int main() function. Then we call app->Start() to init some stuff then app->Loop()? (Update maybe? can't remember the name), and this is where the game runs. Now as far as structuring your game with classes this is a really big topic in which people have strong opinions about based on efficiency and maintainability of the project. Normally you will want to put your class declarations in the header file like: class Foo { private: int i; public: void Update(); }; Then in the source file of the same name as the header file just different extension void Foo::Update() { // actually do something } So classes just group variables and functions into a common object. Think of real world objects like a stapler. It has variables like color, size, paperClip count. It has functions like Staple(), Reload(), etc. You can represent this in plain C but nothing really links them together in C. In C++ the class is a way to link the variables and classes together in a way that makes sense. In a LE3 C++ project in main.cpp. App* app = new App; // create a variable of the App blueprint if (app->Start()) // call this classes Start function { while (app->Loop()) {} // call this classes Loop() function delete app; // delete the app variable }
  23. You'd probably have to code that yourself, but I've always used a special frame callback. This would be a frame that once it goes past during playing the animation a callback function is called so you can do certain things. I used it for RPG type games where normally at a certain frame in a casting spell (for example) you want to make a particle effect happen or whatever.
  24. Because it's not working yet on Unbuntu? Everyone will have a chance once it's up...for a price.
×
×
  • Create New...