My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
opegngl_engine_beginners_guide  
Howto start using the opengl engine
Updated Dec 28, 2010 by beheer.l...@gmail.com

Introduction

if you want to use the engine first download the jogl 2.0 library

code example

for lack of time a code snippet from a simple example loading .obj

import MrL0co.Renderer;
import MrL0co.MainControl;
import MrL0co.Model;
import MrL0co.Vector;
import javax.media.opengl.GL2;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * Write a description of class Head here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Head implements MainControl
{
    HashMap<String,Model> modelList;
    boolean modelListChanged;
    
    float armRot;
    
    /**
     * Constructor for objects of class Head
     */
    public Head()
    {
        modelList = new HashMap<String,Model>();
        modelListChanged = false;
        armRot = 40.0f;
    }
    
    public static void main(String[] args)
    {
        Head head = new Head();
        Renderer renderer = new Renderer(head,"3D ENGINE TEST: scott pelgrim",640,480,false,false);
    }
    
    public final void start()
    {
        while(true)
        {
            
        }
    }

    public void initGL(GL2 gl)
    {
        Model model = new Model();
        model.loadOBJ("head.obj");
        model.setPos(new Vector(0.0f,0.0f,-5.0f));
        modelList.put("head",model);
        
        model = new Model();
        model.loadOBJ("arm.obj");
        model.setPos(new Vector(-0.9f,0.7f,-5.0f));
        modelList.put("armR",model);
        
        model = new Model();
        model.loadOBJ("torso.obj");
        model.setPos(new Vector(0.0f,0.0f,-5.0f));
        modelList.put("torso",model);
        
        model = new Model();
        model.loadOBJ("arm.obj");
        model.setPos(new Vector(0.9f,0.7f,-5.0f));
        model.setScale(new Vector(-1.0f,1.0f,1.0f));
        model.setRot(-40.0f, new Vector(1.0f,0.0f,0.0f));
        modelList.put("armL",model);
        
        model = new Model();
        model.loadOBJ("leg.obj");
        model.setPos(new Vector(-0.39f,-1.0f,-5.0f));
        modelList.put("legR",model);
        
        model = new Model();
        model.loadOBJ("leg.obj");
        model.setPos(new Vector(0.39f,-1.0f,-5.0f));
        model.setScale(new Vector(-1.0f,1.0f,1.0f));
        modelList.put("legL",model);
        
        modelListChanged = true;
    }

    public void updateGL(GL2 gl)
    {
    }

    public ArrayList<Model> updateModelList(ArrayList<Model> modelList)
    {
        Model model = this.modelList.get("armL");
        model.setRot(armRot, new Vector(1.0f,0.0f,0.0f));
        armRot -= 0.5f;
        if(modelListChanged)
        {
            modelListChanged = false;
            return new ArrayList<Model>(this.modelList.values());
        }
        return modelList;
    }

    public Vector[] getCamPos()
    {
        Vector[] camPos = new Vector[3];
        camPos[0] = new Vector(0.0f,0.0f,0.0f);
        camPos[1] = new Vector(0.0f,0.0f,-5.0f);
        camPos[2] = new Vector(0.0f,1.0f,0.0f);
        return camPos;
    }

}
Powered by Google Project Hosting