コード例 #1
0
BEGIN_JLIB_GRAPHICS_IMPLICIT_NAMESPACE

vector::vector( entityG *p, math::colour4 cA, math::colour4 cB, JFLOAT length ) : entityG( p ), _hL( 0 ), line( this ), point( this ), _length( length ), _colourA( cA ), _colourB( cB )
    {
    setDrawable( );
    rebuild( );
    }
コード例 #2
0
BEGIN_JLIB_GRAPHICS_IMPLICIT_NAMESPACE

vectorPlane::vectorPlane( entity::entityG *p, math::colour4 cXA, math::colour4 cYA, math::colour4 cXB, math::colour4 cYB, JFLOAT lengthX, JFLOAT lengthY ) : entityG( p ), vectorA( this, cXA, cXB, lengthX ), vectorB( this, cYA, cYB, lengthY ), angleLine( this ), angleQuad( this )
    {
    vectorB.setOrientation( math::quaternion::fromEulerAngles( math::triple( 0, 0, DEGTORAD*90 ) ) );
    setDrawable( );
    rebuild( );
    }
コード例 #3
0
BEGIN_JLIB_GRAPHICS_PIXEL_NAMESPACE

imagePlane::imagePlane( entity::entityG *p, image cI, JFLOAT width ) : triangleCloud( p ), currentImage( 0, 0 ), _currentTexture( 0 ), _facing( FALSE )
    {
    setWidth( width );
    setImage( cI );
    setDrawable( );
    alphaBlend = TRUE;
    }
コード例 #4
0
ファイル: GameState.cpp プロジェクト: John-Chan/crush
//private
void GameState::addBlock(const sf::Vector2f& position, const sf::Vector2f& size)
{
    auto blockNode = std::make_unique<Node>("blockNode");
    blockNode->setPosition(position);
    blockNode->setDrawable(m_mapController.getDrawable(MapController::MapDrawable::Block));
    blockNode->setCategory(Category::Block);
    blockNode->setCollisionBody(m_collisionWorld.addBody(CollisionWorld::Body::Type::Block, size));
    blockNode->addObserver(m_players[0]);
    blockNode->addObserver(m_players[1]);
    blockNode->addObserver(m_scoreBoard);
    blockNode->addObserver(m_audioController);
    m_scene.addNode(blockNode, Scene::DynamicRear);
}
コード例 #5
0
ファイル: GameState.cpp プロジェクト: John-Chan/crush
void GameState::addPlayer(const sf::Vector2f& position, Player& player)
{
    auto playerNode = std::make_unique<Node>("Player");
    playerNode->setPosition(position);
    playerNode->setDrawable(player.getSprite());
    playerNode->setCategory(player.getType());
    playerNode->setCollisionBody(m_collisionWorld.addBody(CollisionWorld::Body::Type::Player, player.getSize()));
    playerNode->addObserver(player);
    playerNode->addObserver(m_npcController);
    playerNode->addObserver(m_scoreBoard);
    playerNode->addObserver(m_particleController);
    playerNode->addObserver(m_audioController);
    m_scene.addNode(playerNode, Scene::DynamicRear);

    player.setSpawnable(false);
}
コード例 #6
0
ファイル: llface.cpp プロジェクト: MattoDestiny/Zero-One
void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp)
{
	mLastUpdateTime = gFrameTimeSeconds;
	mLastMoveTime = 0.f;
#if MESH_ENABLED
	mLastSkinTime = gFrameTimeSeconds;
#endif //MESH_ENABLED
	mVSize = 0.f;
	mPixelArea = 16.f;
	mState      = GLOBAL;
	mDrawPoolp  = NULL;
	mPoolType = 0;
	mCenterLocal = objp->getPosition();
	mCenterAgent = drawablep->getPositionAgent();
	mDistance	= 0.f;

	mGeomCount		= 0;
	mGeomIndex		= 0;
	mIndicesCount	= 0;
	mIndicesIndex	= 0;
	mIndexInTex = 0;
	mTexture		= NULL;
	mTEOffset		= -1;

	setDrawable(drawablep);
	mVObjp = objp;

	mReferenceIndex = -1;

	mTextureMatrix = NULL;
	mDrawInfo = NULL;

	mFaceColor = LLColor4(1,0,0,1);

	mLastVertexBuffer = mVertexBuffer;
	mLastGeomCount = mGeomCount;
	mLastGeomIndex = mGeomIndex;
	mLastIndicesCount = mIndicesCount;
	mLastIndicesIndex = mIndicesIndex;

	mImportanceToCamera = 0.f ;
	mBoundingSphereRadius = 0.0f ;
}
コード例 #7
0
ファイル: GameState.cpp プロジェクト: John-Chan/crush
void GameState::addNpc(const sf::Vector2f& position, const sf::Vector2f& size)
{
    auto npcNode = std::make_unique<Node>();
    npcNode->setPosition(position);
    npcNode->setDrawable(m_npcController.getDrawable());
    npcNode->setCategory(Category::Npc);
    npcNode->setCollisionBody(m_collisionWorld.addBody(CollisionWorld::Body::Type::Npc, size));
    npcNode->addObserver(m_npcController);
    npcNode->addObserver(m_scoreBoard);
    npcNode->addObserver(m_particleController);
    npcNode->addObserver(m_audioController);
    
   /* auto light = m_scene.addLight(sf::Vector3f(1.f, 0.5f, 0.f), 200.f);
    if (light)
    {
        light->setDepth(50.f);
        npcNode->setLight(light);
        //npcNode->addObserver(*light);
    }*/
    m_scene.addNode(npcNode, Scene::DynamicRear);
}
コード例 #8
0
ファイル: GLWidget.cpp プロジェクト: Salamek/Shadow-of-Dust
void idGLConsoleWidget::init() {
    setDrawable(&console);
}
コード例 #9
0
ファイル: GameState.cpp プロジェクト: John-Chan/crush
void GameState::addMapBody(const Map::Node& n)
{
    switch (n.type)
    {
    case Category::Block:
        addBlock(n.position, n.size);
        break;
    case Category::Solid:
    {
        auto node = std::make_unique<Node>();
        node->setPosition(n.position);
        node->setCollisionBody(m_collisionWorld.addBody(CollisionWorld::Body::Solid, n.size));
        m_scene.addNode(node, Scene::Solid);
    }
        break;
    case Category::Water:
    {
        auto node = std::make_unique<Node>();
        node->setPosition(n.position);
        auto drawable = static_cast<WaterDrawable*>(m_mapController.getDrawable(MapController::MapDrawable::Water));
        drawable->setSize(n.size);
        node->setDrawable(drawable);
        node->setCollisionBody(m_collisionWorld.addBody(CollisionWorld::Body::Water, n.size));
        node->addObserver(m_particleController);
        m_scene.addNode(node, Scene::Water);
    }
        break;
    case Category::Item:
    {
        auto node = std::make_unique<Node>();
        node->setPosition(n.position);
        node->setCategory(Category::Item);
        node->setDrawable(m_mapController.getDrawable(MapController::MapDrawable::Item));
        node->setCollisionBody(m_collisionWorld.addBody(CollisionWorld::Body::Item, n.size));
        node->addObserver(m_particleController);
        node->addObserver(m_audioController);

        auto light = m_scene.addLight(sf::Vector3f(0.34f, 0.96f, 1.f), 400.f);
        if (light)
        {
            light->setDepth(50.f);
            node->setLight(light);
        }
        node->setBlendMode(sf::BlendAdd);
        m_scene.addNode(node, Scene::DynamicFront);
    }
        break;
    case Category::Light:
    {
        auto node = std::make_unique<Node>();
        node->setCategory(Category::Light);
        //TODO magix0r numb0rz
        auto light = m_scene.addLight(colourToVec3(n.colour), 700.f);
        light->setDepth(50.f);
        node->setLight(light);
        node->setPosition(n.position + (n.size / 2.f));
        node->addObserver(*light);
        node->setDrawable(&lightDrawable);
        node->setBlendMode(sf::BlendAlpha);

        //if (n.anchorOffset) //TODO make not broken (see contraint solve())
        //{
        //    //we want a constraint on this light
        //    node->setCollisionBody(m_collisionWorld.addBody(CollisionWorld::Body::Type::FreeForm, { lightDrawable.getRadius(), lightDrawable.getRadius() }));

        //    auto anchorNode = std::make_unique<Node>();
        //    anchorNode->setPosition(n.position);
        //    anchorNode->move(0.f, -n.anchorOffset);
        //    anchorNode->setCollisionBody(m_collisionWorld.addBody(CollisionWorld::Body::Type::Anchor, { lightDrawable.getRadius(), lightDrawable.getRadius() }));
        //    anchorNode->setDrawable(&c1);

        //    m_collisionWorld.addConstraint(anchorNode->getCollisionBody(), node->getCollisionBody(), n.anchorOffset);
        //    m_scene.addNode(anchorNode);
        //}

        m_scene.addNode(node, Scene::Background);
        break;
    }

    case Category::HatDropped:
    {
        auto node = std::make_unique<Node>();
        node->setPosition(n.position);
        node->setDrawable(m_mapController.getDrawable(MapController::MapDrawable::Hat));
        node->setCollisionBody(m_collisionWorld.addBody(CollisionWorld::Body::Type::FreeForm, n.size));
        node->setCategory(n.type);
        auto light = m_scene.addLight(sf::Vector3f(1.f, 0.9f, 0.f), 200.f);
        light->setDepth(50.f);
        node->setLight(light);

        node->addObserver(m_particleController);
        node->addObserver(m_audioController);
        node->addObserver(m_mapController);
        node->addObserver(m_scoreBoard);
        node->addObserver(m_players[0]);
        node->addObserver(m_players[1]);

        m_scene.addNode(node, Scene::DynamicFront);
        break;
    }
    case Category::Bat:
    case Category::Bird:
    {
        auto node = std::make_unique<Node>();
        node->setPosition(n.position);
        node->setCategory(n.type);
        node->setDrawable(m_mapController.getDrawable((n.type == Category::Bat) ? MapController::MapDrawable::Bat : MapController::MapDrawable::Bird));
        m_scene.addNode(node, Scene::FrontDetail);
        break;
    }
    default: break;
    }
}
コード例 #10
0
    std::shared_ptr<gameplay::Node> Room::createSceneNode(gameplay::Game* game,
                                                          size_t roomId,
                                                          const level::Level& level,
                                                          const std::vector<std::shared_ptr<gameplay::Texture>>& textures,
                                                          const std::map<loader::TextureLayoutProxy::TextureKey, std::shared_ptr<gameplay::Material>>& materials,
                                                          const std::map<loader::TextureLayoutProxy::TextureKey, std::shared_ptr<gameplay::Material>>& waterMaterials,
                                                          const std::vector<std::shared_ptr<gameplay::Model>>& staticMeshes,
                                                          render::TextureAnimator& animator)
    {
        RenderModel renderModel;
        std::map<TextureLayoutProxy::TextureKey, size_t> texBuffers;
        std::vector<RenderVertex> vbuf;
        auto mesh = std::make_shared<gameplay::Mesh>(RenderVertex::getFormat(), vbuf.size(), true);

        for( const QuadFace& quad : rectangles )
        {
            const TextureLayoutProxy& proxy = level.m_textureProxies.at(quad.proxyId);

            if( texBuffers.find(proxy.textureKey) == texBuffers.end() )
            {
                texBuffers[proxy.textureKey] = renderModel.m_parts.size();
                renderModel.m_parts.emplace_back();
                auto it = isWaterRoom() ? waterMaterials.find(proxy.textureKey) : materials.find(proxy.textureKey);
                Expects(it != (isWaterRoom() ? waterMaterials.end() : materials.end()));
                renderModel.m_parts.back().material = it->second;
            }
            const auto partId = texBuffers[proxy.textureKey];

            const auto firstVertex = vbuf.size();
            for( int i = 0; i < 4; ++i )
            {
                RenderVertex iv;
                iv.position = vertices[quad.vertices[i]].position.toRenderSystem();
                iv.color = vertices[quad.vertices[i]].color;
                iv.texcoord0 = proxy.uvCoordinates[i].toGl();
                vbuf.push_back(iv);
            }

            animator.registerVertex(quad.proxyId, {mesh, partId}, 0, firstVertex + 0);
            renderModel.m_parts[partId].indices.emplace_back(firstVertex + 0);
            animator.registerVertex(quad.proxyId, {mesh, partId}, 1, firstVertex + 1);
            renderModel.m_parts[partId].indices.emplace_back(firstVertex + 1);
            animator.registerVertex(quad.proxyId, {mesh, partId}, 2, firstVertex + 2);
            renderModel.m_parts[partId].indices.emplace_back(firstVertex + 2);
            animator.registerVertex(quad.proxyId, {mesh, partId}, 0, firstVertex + 0);
            renderModel.m_parts[partId].indices.emplace_back(firstVertex + 0);
            animator.registerVertex(quad.proxyId, {mesh, partId}, 2, firstVertex + 2);
            renderModel.m_parts[partId].indices.emplace_back(firstVertex + 2);
            animator.registerVertex(quad.proxyId, {mesh, partId}, 3, firstVertex + 3);
            renderModel.m_parts[partId].indices.emplace_back(firstVertex + 3);
        }
        for( const Triangle& tri : triangles )
        {
            const TextureLayoutProxy& proxy = level.m_textureProxies.at(tri.proxyId);

            if( texBuffers.find(proxy.textureKey) == texBuffers.end() )
            {
                texBuffers[proxy.textureKey] = renderModel.m_parts.size();
                renderModel.m_parts.emplace_back();
                auto it = isWaterRoom() ? waterMaterials.find(proxy.textureKey) : materials.find(proxy.textureKey);
                Expects(it != (isWaterRoom() ? waterMaterials.end() : materials.end()));
                renderModel.m_parts.back().material = it->second;
            }
            const auto partId = texBuffers[proxy.textureKey];

            const auto firstVertex = vbuf.size();
            for( int i = 0; i < 3; ++i )
            {
                RenderVertex iv;
                iv.position = vertices[tri.vertices[i]].position.toRenderSystem();
                iv.color = vertices[tri.vertices[i]].color;
                iv.texcoord0 = proxy.uvCoordinates[i].toGl();
                vbuf.push_back(iv);
            }

            animator.registerVertex(tri.proxyId, {mesh, partId}, 0, firstVertex + 0);
            renderModel.m_parts[partId].indices.emplace_back(firstVertex + 0);
            animator.registerVertex(tri.proxyId, {mesh, partId}, 1, firstVertex + 1);
            renderModel.m_parts[partId].indices.emplace_back(firstVertex + 1);
            animator.registerVertex(tri.proxyId, {mesh, partId}, 2, firstVertex + 2);
            renderModel.m_parts[partId].indices.emplace_back(firstVertex + 2);
        }

        mesh->rebuild(reinterpret_cast<float*>(vbuf.data()), vbuf.size());
        auto resModel = renderModel.toModel(mesh);
        node = std::make_shared<gameplay::Node>("Room:" + boost::lexical_cast<std::string>(roomId));
        node->setDrawable(resModel);

        for( Light& light : lights )
        {
            const auto f = std::abs(light.specularIntensity) / 8191.0f;
            BOOST_ASSERT(f >= 0 && f <= 1);

            switch( light.getLightType() )
            {
                case LightType::Shadow:
                    BOOST_LOG_TRIVIAL(debug) << "Light: Shadow";
                    light.node = gameplay::Light::createPoint(light.color.r / 255.0f * f, light.color.g / 255.0f * f, light.color.b / 255.0f * f, light.specularFade);
                    break;
                case LightType::Null:
                case LightType::Point:
                    BOOST_LOG_TRIVIAL(debug) << "Light: Null/Point";
                    light.node = gameplay::Light::createPoint(light.color.r / 255.0f * f, light.color.g / 255.0f * f, light.color.b / 255.0f * f, light.specularFade);
                    break;
                case LightType::Spotlight:
                    BOOST_LOG_TRIVIAL(debug) << "Light: Spot";
                    light.node = gameplay::Light::createSpot(light.color.r / 255.0f * f, light.color.g / 255.0f * f, light.color.b / 255.0f * f, light.specularFade, light.r_inner, light.r_outer);
                    break;
                case LightType::Sun:
                    BOOST_LOG_TRIVIAL(debug) << "Light: Sun";
                    light.node = gameplay::Light::createDirectional(light.color.r / 255.0f * f, light.color.g / 255.0f * f, light.color.b / 255.0f * f);
                    break;
            }

            BOOST_LOG_TRIVIAL(debug) << "  - Position: " << light.position.X << "/" << light.position.Y << "/" << light.position.Z;
            BOOST_LOG_TRIVIAL(debug) << "  - Length: " << light.length;
            BOOST_LOG_TRIVIAL(debug) << "  - Color: " << light.color.a / 255.0f << "/" << light.color.r / 255.0f << "/" << light.color.g / 255.0f << "/" << light.color.b / 255.0f;
            BOOST_LOG_TRIVIAL(debug) << "  - Specular Fade: " << light.specularFade;
            BOOST_LOG_TRIVIAL(debug) << "  - Specular Intensity: " << light.specularIntensity;
            BOOST_LOG_TRIVIAL(debug) << "  - Inner: " << light.r_inner;
            BOOST_LOG_TRIVIAL(debug) << "  - Outer: " << light.r_outer;
            BOOST_LOG_TRIVIAL(debug) << "  - Intensity: " << light.intensity;
        }

        for( const RoomStaticMesh& sm : this->staticMeshes )
        {
            auto idx = level.findStaticMeshIndexById(sm.meshId);
            BOOST_ASSERT(idx >= 0);
            BOOST_ASSERT(static_cast<size_t>(idx) < staticMeshes.size());
            auto subNode = std::make_shared<gameplay::Node>("");
            subNode->setDrawable(staticMeshes[idx]);
            subNode->setLocalMatrix(glm::translate(glm::mat4{1.0f}, (sm.position - position).toRenderSystem()) * glm::rotate(glm::mat4{1.0f}, util::auToRad(sm.rotation), glm::vec3{0,-1,0}));
            node->addChild(subNode);
        }
        node->setLocalMatrix(glm::translate(glm::mat4{1.0f}, position.toRenderSystem()));

        for( const Sprite& sprite : sprites )
        {
            BOOST_ASSERT(sprite.vertex < vertices.size());
            BOOST_ASSERT(sprite.texture < level.m_spriteTextures.size());

            const SpriteTexture& tex = level.m_spriteTextures[sprite.texture];

            auto spriteNode = std::make_shared<gameplay::Sprite>(game, textures[tex.texture], tex.right_side - tex.left_side + 1, tex.bottom_side - tex.top_side + 1, tex.buildSourceRectangle());
            spriteNode->setBlendMode(gameplay::Sprite::BLEND_ADDITIVE);

            auto n = std::make_shared<gameplay::Node>("");
            n->setDrawable(spriteNode);
            n->setLocalMatrix(glm::translate(glm::mat4{1.0f}, (vertices[sprite.vertex].position - core::TRCoordinates{0, tex.bottom_side / 2, 0}).toRenderSystem()));

            node->addChild(n);
        }

        // resultNode->addShadowVolumeSceneNode();

        return node;
    }