Git Product home page Git Product logo

b3view's People

Contributors

poikilos avatar

Watchers

 avatar

b3view's Issues

Add 3D texture painting.

/**
 * Calculate the UV point based on collision data (triangle and point) that you've already
 * obtained using irrlicht's CollisionManager and TriangleSelector.
 * 
 * Attribution-ShareAlike 3.0 Unported [CC BY SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/)
 * [Imm0](https://stackoverflow.com/users/1242688/imm0) and
 * [Matt Fenwick](https://stackoverflow.com/users/894284/matt-fenwick).
 * <https://stackoverflow.com/a/9516602>
 *
 * @param tri Check this triangle (get this via CollisionManager and TriangleSelector)
 * @param p Check this point (CollisionManager and TriangleSelector)
 * @param pMeshNode This is the mesh you have chosen beforehand and on which you've calculated the triangle and collision point.
 * @param pDriver Provide the current video driver.
 * @return The 2D point on the texture in UV coordinates.
 */
irr::core::vector2df getPointUV(irr::core::triangle3df tri, irr::core::vector3df p, irr::scene::IMeshSceneNode* pMeshNode, irr::video::IVideoDriver* pDriver)
{
    irr::core::matrix4 inverseTransform(
    pMeshNode->getAbsoluteTransformation(),
      irr::core::matrix4::EM4CONST_INVERSE);

    inverseTransform.transformVect(tri.pointA);
    inverseTransform.transformVect(tri.pointB);
    inverseTransform.transformVect(tri.pointC);

    irr::core::vector3df 
    v0 = tri.pointC - tri.pointA,
    v1 = tri.pointB - tri.pointA,
    v2 = p - tri.pointA;

    float dot00 = v0.dotProduct(v0),
    dot01 = v0.dotProduct(v1),
    dot02 = v0.dotProduct(v2),
    dot11 = v1.dotProduct(v1),
    dot12 = v1.dotProduct(v2);

    float invDenom = 1.f / ((dot00 * dot11) - (dot01 * dot01)),
    u = (dot11 * dot02 - dot01 * dot12) * invDenom,
    v = (dot00 * dot12 - dot01 * dot02) * invDenom;

    irr::video::S3DVertex A, B, C;
    irr::video::S3DVertex* vertices = static_cast<irr::video::S3DVertex*>(
      pMeshNode->getMesh()->getMeshBuffer(0)->getVertices());

    for(unsigned int i=0; i < pMeshNode->getMesh()->getMeshBuffer(0)->getVertexCount(); ++i)
    {
      if( vertices[i].Pos == tri.pointA)
      {
        A = vertices[i];
      }
      else if( vertices[i].Pos == tri.pointB)
      {
        B = vertices[i];
      }
      else if( vertices[i].Pos == tri.pointC)
      {
        C = vertices[i];
      }
    }

    irr::core::vector2df t2 = B.TCoords - A.TCoords;
    irr::core::vector2df t1 = C.TCoords - A.TCoords;

    irr::core::vector2df uvCoords = A.TCoords + t1*u + t2*v;

    return uvCoords;
}

template for sto* throws invalid argument but only when debugging in CodeBlocks

Debugger name and version: GNU gdb (Debian 8.2.1-2+b3) 8.2.1
In __cxa_throw () (/usr/lib/x86_64-linux-gnu/libstdc++.so.6)
#2  0x000055555558480f in __gnu_cxx::__stoa<long, int, char, int> (__convf=0x7ffff7155c20 <__strtol>, __name=0x5555555c774d "stoi", __str=0x555555600be0 "/home/owner/git/b3view/dist/ninja.b3d", __idx=0x7fffffffde08, __base#0=10) at /usr/include/c++/8/ext/string_conversions.h:83
��/usr/include/c++/8/ext/string_conversions.h:83:2500:beg:0x55555558480f
At /usr/include/c++/8/ext/string_conversions.h:83

Line 83 is std::__throw_invalid_argument(__name);

Add minetest-style attachments

  • Automatically load wielditem onto a sprite, using the same origin and orientation as Minetest would.
  • Use a similar or same attachment method for mobs as for the player model.
  • Implement armor for mobs (multiple copies of torso if necessary)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.