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 1 of 2 12 LastLast
Results 1 to 10 of 15

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

  1. #1
    Junior Member Newbie Tcll5850's Avatar
    Join Date
    Feb 2014
    Posts
    20

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

    so this is a little thing I'm doing for a rebuild of a project in the Python27 language.
    I'm worried more about quality than performance.

    so what I'm trying to do is design a vector class for 1D to 4D vectors and quaternions,
    and have the class be able to easily convert between their representative values.
    NOTE: this is a single class, not multiple classes for each vector type

    the class supports 4D:
    vertices - [X,Y,Z,W] (or quaternions)
    normals - [I,J,K,H]
    texCoords - [S,T,R,Q] (where Q is used for the 3D texCoord angle (sent to GL as [S,T,Q]))
    colors - [R,G,B,A]

    what and all do I to perform the proper conversions??
    _________________________________________________

    also...
    I've tried looking a few times, with no luck other than what I know above, excluding how [S,T,R] can also be [U,V,W].
    (but [U,V,W] can also be curve-surface representation)

    what exactly do vector letters stand for and what do they mean??
    I'm tired of finding bits and pieces of their meanings... google sucks >.<
    (we need a wiki on this or something)

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,101
    I do not know what you are asking. If you are asking how to create this class in Python you best ask on a Python forum

  3. #3
    Junior Member Newbie Tcll5850's Avatar
    Join Date
    Feb 2014
    Posts
    20
    oh I was only trying to hint at the code needing to be in python...

    I know nothing about proper vector methods, and I want to build a single vector class that can hold any type of 1D to 4D data and convert the properly.
    (such as converting a 4D quaternion to a 2D vertex)

    also note:
    I use the term "Vertex" standing for an XYZW position.
    where "FacePoint" is the combined weights,vert,normal,colors,UV's,NBTs,etc...

    anyways... what I'm asking is...
    what do I need to put into a class like this??
    and how would I go about building the methods??

    I'm currently trying to follow about 6 high-end to mid-end game-engine src's from engines such as CryEngine3 to Unity...
    I'm asking here because there's an quite overwhelming amount of src to look at,
    and it could take quite alot longer to figure out than from asking experienced developers.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,101
    First you have to ask yourself do I really need to do this when there are a lot of vector libraries out there like glm and the functions they have tend to cover what your need in practice.

    But if you think you want to write one then start small. Have a base class with some basic function then add more as you have needs.

    Libraries are best developed with a purpose in mind, ie, you have a need so you write it rather that writing it and trying to find where to use it.

  5. #5
    Junior Member Newbie Tcll5850's Avatar
    Join Date
    Feb 2014
    Posts
    20
    ok... the need is for an interface for converting data...
    and yes I do need to write it because it converts data types.

    for example, you store a vector as a bs24 (3-byte signed int) and want to convert it to a bf(5) (5-byte float)
    my data interface is already fully capable of this.

    I'm not mentioning the needs... I'm supporting future development...
    but now I need to know all of the things applied between vectors and quaternions to convert them appropriately.
    (this is for the scripting interface which handles the model data you're converting)
    ^ say... *.MDL0 >>> *.BLEND --- *.BLEND >>> *.DAT
    (Wii >>> Blender24 --- Blender26 >>> GCN)

    I basically need to convert between all vector types here, and need an interface that can do it.

    I WILL however take a look into a python translation of your GLM recommendation.
    thanks.

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,101
    ^ say... *.MDL0 >>> *.BLEND --- *.BLEND >>> *.DAT

    This is data conversion. It is not really relevant to this forum.
    know all of the things applied between vectors and quaternions

    vectors and quaternions aren't directly related; one is a direction and length, the other is a method of storing a rotation around an axis. (among other uses)
    I basically need to convert between all vector types

    How long is a piece of string.

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,136
    I'm not sure why you posted this in "OpenGL Advanced". It's nothing to do with OpenGL, and is certainly not advanced.

  8. #8
    Junior Member Newbie Tcll5850's Avatar
    Join Date
    Feb 2014
    Posts
    20
    Quote Originally Posted by mhagain View Post
    I'm not sure why you posted this in "OpenGL Advanced". It's nothing to do with OpenGL, and is certainly not advanced.
    well, ok, could this be moved to a more appropriate thread plox.
    I'm only a noob, so IDK this forum yet :P

    the reason I ask here is cause I assume you guys know more about vectors and quaternions than what I can find on google.

    it's only "advanced" because I associated this category with Modern GL... heh
    and I figured the coding was kindof advanced for it's level.

    Quote Originally Posted by tonyo_au View Post
    This is data conversion. It is not really relevant to this forum.
    exactly... the only relevence is me, trying to get this to work with GL...
    I need to know what I need so I can have a check-list... basically

    Quote Originally Posted by tonyo_au View Post
    [/COLOR]vectors and quaternions aren't directly related; one is a direction and length, the other is a method of storing a rotation around an axis. (among other uses)
    IK... but there's conversion methods between them... or maybe that's just BrawlBox... :P

    Quote Originally Posted by tonyo_au View Post
    How long is a piece of string.
    lol please :3

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,101
    trying to get this to work with GL...

    Have you read the OpenGL specs. You will see all the formats supported for vertices and textures. It is up to you what formats
    you want you are prepared to read and convert into these formats.
    there's conversion methods between them

    A quaternion has 4 components - anything that can contain 4 values can be thought of as a
    quaternion.
    A vector has n components, in graphics we think of 2 for 2D and 3 for 3D.

    If you are looking at a general converter, you should look at a component to component conversion not vector to vector since 2 vectors can have a different a
    number of components.


  10. #10
    Junior Member Newbie Tcll5850's Avatar
    Join Date
    Feb 2014
    Posts
    20
    I have the 4.4 reference off-hand, though I do need to look at it more often <.<

    anyways, yeh... not exactly what I need...
    component to component can already be done in my interface.
    (such as undoing a slew of floats as ints with an exponent (Nintendo-styled))

    what I'm having a problem with is my srcs...
    none of them defines a general class for handling everything that isn't WIP (not even working)...
    almost all of my srcs define classes for vec2, vec3, vec4, and quaternion, and bloat the code by defining methods for each...

    I just want 1 class for everything, with methods to adapt to the comparison or the conversion specs,
    but I wouldn't know what I'd need, or where to even start off at...

    I'm no math expert... I graduated at Algebra1 level, with SOME geometry knowledge I just knew (I wasn't even self-taught it).
    I surprised my teacher with the "college level geometry" I knew... but unfortunately, that's as far as I go...
    I havn't been in college, nor done anything much to get me much farther in math, other than looking at others srcs to try and decipher them.
    (I can't even read math on Wikipedia)

    so anyways...
    all I'm asking for is a checklist...
    what methods would I need for something like this??

Posting Permissions

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