Skip to content

|Need| Camera movements #6

@WithSJ

Description

@WithSJ

CAMERA movements mean we need to add rotations, transformation, or maybe scaling.

if we have this all we can place the camera according to user
below code just for testing camera

#include <iostream>
#include <chrono>

#include "Engine/renderengine.h"

using namespace std::chrono;

int main(int argc, char const *argv[])
{
    /* code */
    // Eclectus Testing 1.0
    auto start = high_resolution_clock::now();

    short int WIDTH = 320;
    short int HEIGHT = 200;
    
    

    Color col = Color::from_hex("#0000ff");
    Material* material1 = new Material(col);
    Sphere obj1(Vector(-0.75, -0.1, 2.25),0.6,material1);

    Color col3 = Color::from_hex("#803880");
    Material* material3 = new Material(col3);
    Sphere obj3(Vector(0.75, -0.1, 1) ,0.6,material3);

    // Ground
    Color wh = Color::from_hex("#ffffff");
    Color bk = Color::from_hex("#000000");
    Material* mat = new CheckerMaterial(wh,bk);

    Color Gcol = Color::from_hex("#00ff00");
    Material material2(Gcol);
    Sphere obj2(Vector(0,10000,100),10000,mat);
    
    
    Sphere Objects[] = {obj1,obj2,obj3};    
    
    Color light_col(255,255,255);
    Light point_light(Vector(1.5, -0.5, -10),light_col);
    
    Color light_col2 = Color::from_hex("#E6E6E6");
    Light point_light2(Vector(-0.5, -10.5, 0),light_col2);

    Light Lights[] = {point_light,point_light2};

    float x=0,y=0,z=-1;
    char key;
    while(1)
    {
        Vector Camera(x, y, z);
    
        Scene scene(Camera,Objects,3,Lights,2,WIDTH,HEIGHT);

        RenderEngine engine;

        Image img =  engine.render(scene);

        img.write_ppm("Eclectus_test.ppm");

        auto stop = high_resolution_clock::now();
        auto duration = duration_cast<microseconds>(stop - start);
        float d = float(duration.count())/1000000.0;
        std::cout<<"\n#Time takes in microseconds: "<< duration.count();
        std::cout<<"\n#Time takes in seconds: "<< d<<std::endl;

        key = getchar();
        if(key == 'w')
            z += 0.5;
        if(key == 's')
            z -= 0.5;
        if(key == 'a')
            x -= 0.5;
        if(key == 'd')
            x += 0.5;
        
    }
    
    
    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions