Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 2b5968f8c7e02ec9e04bd9ed159d6677f40b44f7 authored by Hung-Kuo Chu on 27 October 2019, 06:41:49 UTC, committed by GitHub on 27 October 2019, 06:41:49 UTC
Update README.md
1 parent 8c90648
  • Files
  • Changes
  • aad9c77
  • /
  • examples
  • /
  • 02_rotation.cpp
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:2b5968f8c7e02ec9e04bd9ed159d6677f40b44f7
directory badge
swh:1:dir:dff328e068346ece3b9c6d02be7067bc0eae6d09
content badge
swh:1:cnt:53cbd6e8f163080a79a39186efa5def53a88b706

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
02_rotation.cpp
// Example code for multiple render with different viewing angles.

#include <bwabstraction.hpp>
#include <opencv2/opencv.hpp>

// include glm for mvp computation.
#include <glm/vec3.hpp>
#include <glm/mat4x4.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/transform.hpp>

int main(void)
{
    bwabstraction::BWAbstraction bwa;
    bwabstraction::Result result;
    bwabstraction::Parameters param;
    param.verbose = true;

    // once a model is loaded, it can be rendered multiple times.
    if(!bwa.LoadModel("model/DualShock3.obj", param))
    {
        exit(1);
    }

    glm::mat4 mvp = 
        glm::perspective(30.0f, 4.0f / 3.0f, 0.1f, 3.0f) *
        glm::lookAt(glm::vec3(2.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
    glm::mat4 rotation = glm::rotate(30.0f, glm::vec3(0.0f, 0.0f, 1.0f));

    // render the model in a loop, updating param.mvpMatrix each time.
    for (int i = 0; i < 6; ++i)
    {
        mvp = mvp * rotation;
        memcpy(param.mvpMatrix, glm::value_ptr(mvp), sizeof(float) * 16);
        bwa.Render(&result, param);
        char filename[15];
        sprintf(filename, "bwaImage%d.png", i);
        cv::imwrite(filename, result.bwaImage);
    }

    #ifdef _MSC_VER
    system("PAUSE");
    #endif

    return 0;
}
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API