Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: [something fun] vector class, what do I need??

  1. #11
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    It sounds to me like you are looking for template classes (which are available in C++) but I don't know that Python can do that. But even with templates you eventually have to write code that will take for example
    a vec2(float,float) can convert to say vec2(int,int) vec2(float,int) vec2(int,float) vec2(double,float) vec2(float,double) vec2(double,double) vec2(int,double) vec2(double,int) if you want all those options - this is not bloat.

    There is no checklist other than what conversions you need. If you need only need vec2(float,float) to vec2(int,int) that's all you write. No one can tell you what you need. OpenGl has native support for float,int,doubles and bytes. But they are
    not all valid in all combinations. With shaders you can pack several things into 1 byte if you want and people do.

  2. #12
    Junior Member Newbie Tcll5850's Avatar
    Join Date
    Feb 2014
    Posts
    21
    ok, the inputs for my class are already pretty much figured out:
    Code :
    vector( BF32(0.0), BU8(0), BU8(0) ) # these are internal data types of my system
    vector( 0.0, 0.0, 0.0, 1.0 )
    vector( [0.0, 1.0] ) #or tuples
    vector( vector( 0, 0, 0 ) )
    the methods are my problem...
    what are all of the common conversion methods??
    Code :
    V = vector( 1.0 )
    print V.asVec( 3 ) # idk, just something I pulled out of my A (IDK what to define in the vector() class)
    # >>> vector( 1.0, 0.0, 0.0 )

    what I'm converting can be from anywhere, and I want to support as much as possible...
    that's why I'm coming to your guys, since I can minorly understand C++

    you guys know more than almost any C++ src could tell me, which is why I ask.
    _____

    keep in mind, I'm not the only one working on scripts that use this system...
    once dev5 of my program is released, it needs to be ready for anyone who wants to add support for a format.

    I'm trying to make the interface fully capable on either end.
    (pre-transformed (verts ready for animation (*.mdl0, *.dat)), or raw (posed verts (*.obj, *.dae)))

    the interface will automatically fill the opposite side once the initial side is filled.
    this will make exporting to a format fast and easy, while keeping your imported model properly stored.
    (your data will literally be readily handed to you in your script depending on which side you need)

  3. #13
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    You can read the specs for C++ but basically it only supports signed and unsigned 32 bit and 64 bit float, double, int plus 8 bit byte. But conversion between these don't always make sense for example a byte cannot hold all values of a double.

    Your little example of vec1 -> vec3 is straight forward, there are 4 commonly used - with 1 to 4 components with padding (ie vec1 -> vec3) done with 0.0.

    The glm template I mentioned does all of these conversions. Data conversion is handled through object constructors eg
    Code :
    glm::dvec3 v3 // 3 component vector each of size double
    glm::vec2 = glm::vec2(v3); // convert to 2 component float
    glm::vec3  v = glm::vec3(v2,0.0f) // convert to 3 componet float, set extra component to 0.0 float

  4. #14
    Junior Member Newbie Tcll5850's Avatar
    Join Date
    Feb 2014
    Posts
    21
    excuse me for the late reply, I'm kinda busy with my WinXP installation...
    (just removed a rootkit while removing all explorer.exe references (I have a new shell))

    anyways...
    Quote Originally Posted by tonyo_au View Post
    But conversion between these don't always make sense for example a byte cannot hold all values of a double.
    that's where percentage comes in. (depending on the exact conversion needed)

    but indeed, I'll take a look into GLM before saying anything else here
    thanks for that btw.
    Last edited by Tcll5850; 02-21-2014 at 08:18 AM.

  5. #15
    Junior Member Newbie Tcll5850's Avatar
    Join Date
    Feb 2014
    Posts
    21
    hey is this the right GLM library:??
    https://github.com/JuliaStats/GLM.jl

    also... from your example... glm doesn't look exactly like what I need, but it does look like it contains alot of what I need...

    what I mean is pre-defined types... what I need is 1 type with defined references.
    since what this class is used for is conversion specifically...

    the class stores the data in memory on both ends for use with exporting.

    I'm sure you're questioning the "both ends" part...
    what I mean there is transformed vs un-transformed.

    for example, un-transformed is the data you'd store in GPU-RAM while transformed is... yea, what's displayed... heh

    this is for use with the export interface, so you can get data from either side of the interface.
    the class, depending on what's needed from the function params you give in your export code, which tell the vertex format you need, is what returns the data you need secifically in it's format.
    (you don't do any conversion work in your import or export scripts, all you do is simply hand the data to the interface)

    the vector class manages verts, normals (including NBT), colors, and UVs all in one in whatever the required format is.
    this is to make co-representation easy in case there so happens to be any conversion work you need to do.

    the vector class stores everything in it's original quality (for GL usage and to keep memory low), but makes things easy for the requirements for export or co-rep usage.
    (co-rep as in displaying the colors of the normal values with maybe a few modifications)
    ^ handling normals as color vectors including RGBA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •