Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About Ostsol

  • Rank
  1. Damn. Well, I was hoping that there was some rule or theorum in coordinate geometry that would make it easy to solve for the the final point in a right angle triangle. *shrugs* Thanks anyway.
  2. Assume one has a circle of radius r centred at point B (x0,y0) and another point A (x,y). What I need is to figure out the coordinates of the intersection points assuming a line from point A intersects with the circle only at a tangent. There are probably several relatively easy ways of going about this. I just need one that is reliable and quick. I understand that one way of looking at this is by treating it as a right angled triangle. For example, the intersection point is labeled C. Assuming a triangle ABC, the angle at C will be 90 degrees. The distance from point A to C can easily be found via Pythagorus and with a few trig functions its coordinates can be found. However, I prefer using trig functions in that manner outside of computer programs. Does anyone know of a good alternative?
  3. So the problem is more that I'm looking at using quaternions in the wrong way, I guess? They're meant to only represent the final orientation? If so, that does make things a heck of alot easier. I had been looking to use quaternions for everything rotation related for the sake of consistency. . .
  4. For the program I'm working on I need to be able to calculate the final orientation of an object, given it's current angular velocity and a rate of decelleration. The that I currently have working merely converts the final data from Euler angles into a quaternion, but what I want is to be able to do this with angular velocity and acceleration also represented as quaternions. Of course, with linear physics and with Euler angles it's simple: d = 0.5 * a * t^2 't', representing the time it takes decellerate to a stop, is found via the following: t = (v1 - v0) / a where 'v1' is the final velocity and v0 is the initial velocity. In the case of my problem 'v1' will be 0.0, of course, and 'a' will be negative to 'v0'. The problem with quaternions is everywhere. First of all, I can't even figure out how I'm going to calculate 't'. Once I've gotten that, I'm not sure how I would go about the final equation. Anyone know how I can do this?
  5. Hmm. . . I thought this might be the case. I'll take a look at those modules you mentioned. Thanks for the suggestions. I guess one other thing I could do is create some fairly robust base-classes to handle the reference management for the basic properties such that further extensions don't have to worry about it.
  6. Consider the following: from TestMod import Base class Another: def __init__ (self): print "Initializing Another" self.Funky = None def __del__ (self): self.Funky = None print "Finalizing Another" class Derived (Base): def __init__ (self): Base.__init__ (self) print "Initializing Derived" self.another = Another () self.another.Funky = self.Func def __del__ (self): self.another = None print "Finalizing Derived" def Func (self): print "Funky!" Base is a C++ class imported into Python via Boost. When Derived gives Another a reference to it Func, it also provides a reference to itself. As a result, when I destroy the reference to Derived in C++, the destructor is not called because there is still one reference remaining: in Another. Both reference each other and there are no other references beyond those. When I call Py_Finalize, Base's destructor is not being called. Is there a way to simply tell Python to clear all references and destroy all objects, calling their destructors? Right now, I have to clear all the references manually. from TestMod import Base class Another: def __init__ (self): print "Initializing Another" self.Funky = None def __del__ (self): self.Funky = None print "Finalizing Another" class Derived (Base): def __init__ (self): Base.__init__ (self) print "Initializing Derived" self.another = Another () self.another.Funky = self.Func def __del__ (self): self.Destroy () print "Finalizing Derived" def Destroy (self): self.another = None def Func (self): print "Funky!" I call the Destroy function in Derived before I delete its C++ reference. This will guarantee that the reference to Another is deleted and its destructor called. However, if there was a similar case with Another (where there was a reference to it an an object that contained a reference back to Another), it would also have to have a Destroy function and Derived would have to call it. I don't know whether or not this would be a problem for straight Python code. I don't know if Python full manages its memory and destroys all objects created. What I do know is that Py_Finalize isn't calling C++ destructors, which can lead to other issues. My own solution isn't -too- much trouble, but I'd like to know if there is something I've missed. Is there, for example, a function in Python's C-API to destroy everything and ensure destructors are properly called?
  7. Hmm. . . That's disappointing. Well, I guess I could parse through the result and eliminate any vertices that are total duplicates. There's bound to be alot when individual triangles are used. . .
  8. I've finally started to seriously work on implementing textured meshes into my engine, but am rather confused by certain model formats. I've downloaded Wings 3D ( and have created and skinned a model. I'm not using the internal model format and am taking advantage of the program's ability to export other formats. For now, I'm looking at the plain text formats. The problem is that all of them separate vertex attributes into coordinates, normals, and texture coordinates. This wouldn't be an issue except for the fact that there's more normals and texture coordinates than vertex coordinates, making it quite unfriendly to vertex arrays. I don't think there's any implementation that allows one to use a separate index array for each attribute, and I would prefer not to simply duplicate vertices. However, other than OpenGL display lists, is that the only solution?
  9. Ah. . . that worked! It also much more elegant and consistant with the rest of the code than my original solution. Thanks! :)
  10. Quote:Original post by SiCrane Back to the original question: I might be missing something, and it's been a while since I've used boost::python, but can't you just use operator() on a Python class in order to create a new object? ex: class_<CPythonObject> CPythonObject_class("CPythonObject" /* blah blah blah */); object new_CPythonObject = CPythonObject_class(); Just tried it and it didn't seem to work. In any case, that wouldn't quite help. What I need is to be able to instantiate a Python class, not merely the Python-exposed version of the C++ base-class. The Python class may be derived from a C++ class, but the class itself is defined in Python. That's what I need to instantiate. Thanks anyway, though. . .
  11. I don't like Lua's object oriented programming support. It's feels quite low-level. Java wouldn't be bad, I suppose, though it does have a much larger runtime environment. Still, in any case, does anyone have an answer to my original question? :)
  12. Ostsol

    Texture Loading Code

    Normal 2D texture sizes must be powers of two. There are extensions to get around this, such as ARB_texture_rectangle (formerly EXT_texture_rectangle and NV_texture_rectangle) and ARB_texture_non_power_of_two. The former has some limitations imposed upon them, such as no mip-mapping and the border clamping options are limited. The latter behaves entirely like normal textures, with the bonus of not restricting dimensions to powers of two. You'll have to check your extension string for support.
  13. Hmm. . . Fun. Is there a way to trim down Python to limit what it can do? If I could some how take away certain potentially dangerous capabilities and use Python as a static library (if that's possible), it should be more secure.
  14. Erg. . . Yeah, I'd found that, but I was kinda hoping for a Boost solution. :)
  15. I'm quite sketchy on this. The documentation doesn't seem to explicitly describe how to do this, though I'm sure I've missed something. I've noted a function in the C API for this, but I'm using Boost and would prefer some uniformity in my code. Boost, after all, has functionality for calling Python classes' member functions and extracting values from the main namespace. However, I can't find any documentation on instantiating a Python class. Here's what I've managed to hack together: handle<> (PyRun_String ("retObject = CPythonClass ()", Py_file_input, oMainNamespace.ptr (), oMainNamespace.ptr ())); object oRetObject = oMainNamespace["retObject"]; Basically, I instantiate the class in Python and retrieve the object. It doesn't seem particularly elegant and I'm hoping that there's a better way. Any tips, thoughts, etc? Background: I've posted before about my desire to incorporate a scripting language into my engine that will allow some capabilities similar to that provided by UnrealScript in Epic's Unreal Engine. I want all game content to be defined and scripted using the scripting language, each class being derived from a C++ class. As such, it becomes clear as to why I need to instantiate Python classes. The engine will keep track of all objects because it will need to access state from instances of the C++ base class and call certain functions, such as for drawing and triggering event handlers.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!