view dmscene.h @ 107:2b30217a3c39 default tip

Fix verbose build echos.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 29 Feb 2024 21:48:47 +0200
parents 9ee0edff3940
children
line wrap: on
line source

//
// GLDragon - OpenGL PLY model viewer / simple benchmark
// -- Scene file handling
// Programmed and designed by Matti 'ccr' Hämäläinen <ccr@tnsp.org>
// (C) Copyright 2019-2020 Tecnic Software productions (TNSP)
//
// See file "COPYING" for license information.
//
#ifndef DMSCENE_H
#define DMSCENE_H 1

#include "dmutil.h"
#include <cstdint>


/* Structures and classes
 */
struct DMVector3
{
    float x, y, z;
};


union DMVector4
{
    struct { float x, y, z, w; } p;
    struct { float r, g, b, a; } c;
    float values[4];
};


struct DMMaterial
{
    DMVector4 ambient, diffuse, specular;
    int shininess;
};


struct DMModel
{
    int nvertices, nfaces;
    std::vector<DMVector3> vertices, normals;
    std::vector<unsigned int> faces;

    DMMaterial material;
    DMVector3 translate, scale, rotate;
    bool translateSet, scaleSet, rotateSet;

    unsigned int id_prog;

    std::string
        modelFile,
        fragShaderFile, vertShaderFile,
        fragShaderStr, vertShaderStr;

    DMModel()
    {
        nfaces = nvertices = 0;

        translate.x = translate.y = translate.z = 0;
        rotate.x = rotate.y = rotate.z = 0;
        scale.x = scale.y = scale.z = 0;
        translateSet = rotateSet = scaleSet = false;

        material.diffuse.c.r = material.diffuse.p.z = 0.56471f;
        material.diffuse.c.g = 0.5f;
        material.diffuse.c.a = 1.0f;

        material.specular.c.r = material.specular.c.g = material.specular.c.b = 0.8f;
        material.specular.c.a = 1.0f;

        material.shininess = 96;
    }
};


struct DMLight
{
    DMMaterial color;
    DMVector4 position, pointAt;

    DMLight()
    {
        color.ambient.c.r  = color.ambient.c.g  = color.ambient.p.z  = 0.2f; color.ambient.c.a  = 1.0f;
        color.diffuse.c.r  = color.diffuse.c.g  = color.diffuse.p.z  = 0.8f; color.diffuse.c.a  = 1.0f;
        color.specular.c.r = color.specular.c.g = color.specular.p.z = 0.5f; color.specular.c.a = 1.0f;

        position.p.x = 10.0f;
        position.p.y = 10.0f;
        position.p.z =  0.0f;
        position.p.w =  0.0f;
    }
};


struct DMCamera
{
    DMVector4 position, pointAt;
};


struct DMSimpleScene
{
    DMCamera camera;
    std::vector<DMLight> lights;
    std::vector<DMModel> models;

    bool loadInfo(const std::string &filename);
};

#endif