Search Results

Search found 2 results on 1 pages for 'sent1nel'.

Page 1/1 | 1 

  • Using std::ifstream to load in an array of struct data type into a std::vector

    - by Sent1nel
    I am working on a bitmap loader in C++ and when moving from the C style array to the std::vector I have run into an usual problem of which Google does not seem to have the answer. 8 Bit and 4 bit, bitmaps contain a colour palette. The colour palette has blue, green, red and reserved components each 1 byte in size. // Colour palette struct BGRQuad { UInt8 blue; UInt8 green; UInt8 red; UInt8 reserved; }; The problem I am having is when I create a vector of the BGRQuad structure I can no longer use the ifstream read function to load data from the file directly into the BGRQuad vector. // This code throws an assert failure! std::vecotr quads; if (coloursUsed) // colour table available { // read in the colours quads.reserve(coloursUsed); inFile.read( reinterpret_cast(&quads[0]), coloursUsed * sizeof(BGRQuad) ); } Does anyone know how to read directly into the vector without having to create a C array and copy data into the BGRQuad vector?

    Read the article

  • Move an object in the direction of a bezier curve?

    - by Sent1nel
    I have an object with which I would like to make follow a bezier curve and am a little lost right now as to how to make it do that based on time rather than the points that make up the curve. .::Current System::. Each object in my scene graph is made from position, rotation and scale vectors. These vectors are used to form their corresponding matrices: scale, rotation and translation. Which are then multiplied in that order to form the local transform matrix. A world transform (Usually the identity matrix) is then multiplied against the local matrix transform. class CObject { public: // Local transform functions Matrix4f GetLocalTransform() const; void SetPosition(const Vector3f& pos); void SetRotation(const Vector3f& rot); void SetScale(const Vector3f& scale); // Local transform Matrix4f m_local; Vector3f m_localPostion; Vector3f m_localRotation; // rotation in degrees (xrot, yrot, zrot) Vector3f m_localScale; } Matrix4f CObject::GetLocalTransform() { Matrix4f out(Matrix4f::IDENTITY); Matrix4f scale(), rotation(), translation(); scale.SetScale(m_localScale); rotation.SetRotationDegrees(m_localRotation); translation.SetTranslation(m_localTranslation); out = scale * rotation * translation; } The big question I have are 1) How do I orientate my object to face the tangent of the Bezier curve? 2) How do I move that object along the curve without just setting objects position to that of a point on the bezier cuve? Heres an overview of the function thus far void CNodeControllerPieceWise::AnimateNode(CObject* pSpatial, double deltaTime) { // Get object latest pos. Vector3f posDelta = pSpatial->GetWorldTransform().GetTranslation(); // Get postion on curve Vector3f pos = curve.GetPosition(m_t); // Get tangent of curve Vector3f tangent = curve.GetFirstDerivative(m_t); } Edit: sorry its not very clear. I've been working on this for ages and its making my brain turn to mush. I want the object to be attached to the curve and face the direction of the curve. As for movement, I want to object to follow the curve based on the time this way it creates smooth movement throughout the curve.

    Read the article

1