Jump to content



Photo
- - - - -

3D Engine For Fx-9860Gii

3d engine graphics fx-9860gii fx-9750gii calculator casio c++

  • Please log in to reply
1 reply to this topic

#1 Viliami

Viliami

    Casio Addict

  • Moderator
  • PipPipPip
  • 98 posts
  • Gender:Male
  • Location:New Zealand
  • Interests:C++ - OpenGL,SDL
    Python - Pygame
    Java - SFML
    C - Casio SDK

  • Calculators:
    FX-9750 GII upgraded to FX-9860 GII

Posted 03 July 2016 - 08:29 AM

This is what I have been working on lately, download the source code from my github: https://github.com/V...3d-engine-casio

the matrix and vector classes in mathlib.cpp is a direct port of the euclid.py python library.

 

 demo.gif

 

To use this in your programs you will need to first download all of the source code from my github and since I made it in C++, you will have to put extern "C" around the main function and any other C code.

e.g

extern "C"{
    int AddIn_main(int isAppli, unsigned short OptionNum)
    {
        main();

        return 1;
    }
}

You will also need to put the extern C braces around any function from the fxlib library as that library was made in C.

Then include the engine.h file and you're ready to go.

#include "engine.h"

The 3d engine is object oriented so here is how to set it up:

Engine eng = Engine(); //create the engine class
Camera cam = Camera(); //create the camera class
Mesh meshes[20];       //create an array that will store all the meshes
Mesh mesh; //creating an example mesh

//here are the vertices and faces for a 3d cube
mesh.vertices[0] = Vector3(-1, 1, 1); 
mesh.vertices[1] = Vector3(1, 1, 1); 
mesh.vertices[2] = Vector3(-1,-1,1);
mesh.vertices[3] = Vector3(1,-1,1);
mesh.vertices[4] = Vector3(-1, 1, -1);
mesh.vertices[5] = Vector3(1,1,-1);
mesh.vertices[6] = Vector3(1,-1,-1);
mesh.vertices[7] = Vector3(-1,-1,-1);
    
mesh.faces[0] = Face(0, 1, 2);
mesh.faces[1] = Face(1, 2, 3);
mesh.faces[2] = Face(1, 3, 6);
mesh.faces[3] = Face(1, 5, 6);
mesh.faces[4] = Face(0, 1, 4);
mesh.faces[5] = Face(1, 4, 5);

mesh.faces[6] = Face(2, 3, 7);
mesh.faces[7] = Face(3, 6, 7);
mesh.faces[8] = Face(0, 2, 7);
mesh.faces[9] = Face(0, 4, 7);
mesh.faces[10]= Face(4, 5, 6);
mesh.faces[11]= Face(4, 6, 7);

meshes[0] = mesh; //add the mesh to the meshes array

while(true){
   eng.clear(); //clear the screen

   meshes.rotation.x += 0.02; 
   meshes.rotation.y += 0.02; //rotate cube around x and y axis
   meshes[0] = mesh;          //update the mesh in the meshes array

   eng.render(cam, meshes); //render all of the meshes from the cameras point of view

   eng.present(); //display the pixels
}


That is a simple demo program for making a rotating cube as shown above.

 

This is still a work in progress, I will continue to add a lot more things soon such as:

-rasterization

-different render modes

-loading .obj files and other 3d formats

-adding grayscale

 

and I will also be making some games using this, starting off with a simple game like bloxorz


Edited by Viliami, 03 July 2016 - 08:32 AM.

  • frankmar98 likes this

#2 frankmar98

frankmar98

    Casio Freak

  • Moderator
  • PipPipPipPip
  • 127 posts
  • Gender:Male
  • Location:Spain
  • Interests:Science, programming

  • Calculators:
    CFX-9970G
    Graph 90+E (fx-GC50)
    fx-9860G SD
    Classpad 300
    HP Prime
    TI-84+ CE-T
    x2 TI-83+
    TI-81
    fx-4800p, fx-3650PII
    fx-991SPX, fx-991ES PLUS, fx-100W

Posted 04 July 2016 - 07:54 AM

Cool, now it works in my fx-9750GII SH4-A upgraded.

 

Now, I have an idea about the power of the fx-9750GII using compiled SH3 code instead of Casio Basic. I think I can use this to make a 3D gun simulator (3D parabolic movement), impossible in Casio Basic. I've already made one in Casio Basic, but it is in 2D.

 

I'm also enjoying the vanhoa's 3D graph adding, is better than the 3D addin for the HP Prime


  • Viliami likes this





Also tagged with one or more of these keywords: 3d, engine, graphics, fx-9860gii, fx-9750gii, calculator, casio, c++

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users