Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OneLua
06-30-2015, 12:24 PM (This post was last modified: 07-12-2015 01:28 PM by jkpwed.)
Post: #9
RE: OneLua
@Haseeb Their is anther version in c/c++ but, it's not a windows version called AMGLib Plus by Andres Margar, more info at wololo.net. For programing in the psp use OneLua IDE by David Nunez Aguilera as showed in this video I can't find the link (psp.scenebeta.com & wololo.net). I was unable to unload 3D stuff on both ONELua v3 (well without textures but the frame rate was 2) and AMGLib Plus (this looks amazing but I can't add that much 3D stuff like SSBB stage and DOA5 Christie maybe do to textures idk).

Main.c (so sorry for the messy code)
Note: Mostly all of the code was copy past and unloading 3D objects did not go so well (also c/c++ is new to me do not try this on the PSP).
Code:
/*
* AMGlib Template
* Powered by Andresmargar
* from SCENEBETA
*/
// Includes AMG
#include <AMG/AMGLib.h>
#include <dirent.h> //C:\pspsdk\psp\sdk\Examples\Multimedia\MP3Player\Source
#include <pspsdk.h>


//google:psp 3d homebrew library

// Module info
AMG_MODULE_INFO("AMG_Model Mod", 0, 1, 1);

float M = 1;
float INFINITE = 1;

int pspDveMgrCheckVideoOut();
int pspDveMgrSetVideoOut(int, int, int, int, int, int, int);
    int    U = 0;
    int    MODE = 0x1D2;
    int    AMG_W = 480;
    int    AMG_H = 272;
int TV_Cable = 0;

void TV_OUT(){

    //esta ya esta cargada
    pspSdkLoadStartModule("dvemgr.prx", PSP_MEMORY_PARTITION_KERNEL);
    
    //Detecta PSP y firmware AQUI ...
    //..
    //..
    //if PSP no es slim, sal de la funcion.
    //O si vuelves de TV a LCD
    
    //Detectar cable
    /*
    # LCD OUT
    # 0, 0x000, 480, 272, 1, 15, 0
    # Composite OUT / Progressive
    # 2, 0x1D2, 720, 503, 1, 15, 0
    # Composite OUT / Interlace
    # 2, 0x1D1, 720, 503, 1, 15, 0
    # Component OUT / Progressive
    # 0, 0x1D2, 720, 480, 1, 15, 0
    # Component OUT / Interlace
    # 0, 0x1D1, 720, 503, 1, 15, 0
    */    
    TV_Cable = pspDveMgrCheckVideoOut();
    
    if (TV_Cable == 0) {}  ///"no hay cable"
    if (TV_Cable == 1){ //SDTV
        U = 2,
        MODE = 0x1D2;
        AMG_W = 720;
        AMG_H = 503;
    }    
    if (TV_Cable == 2){ //HDTV
        U = 0,
        MODE = 0x1D2;
        AMG_W = 720;
        AMG_H = 480;
    }        

    pspDveMgrSetVideoOut(U, MODE, AMG_W, AMG_H, 1, 15, 0);
}

char text[256];
//Main()
int main(int argc, char **argv){
    
    // Init PS
    AMG_SetupCallbacks();        // Inicializa los callbacks
    
    TV_OUT();
  
    //GU_PSM_5650 GU_PSM_5551 GU_PSM_4444 GU_PSM_8888
  
    AMG_Init3D(GU_PSM_8888| AMG_DOUBLEBUFFER | AMG_SCREEN_DIMENSIONS(AMG_W,AMG_H));// Inicializa el motor 3D
    AMG_InitMultimedia();
    AMG_InitAudio();
    
    AMG_InitTimeSystem();
    AMG_SetCpuSpeed(333);
    AMG_InitMatrixSystem(36.0f);// Perspectiva
    //AMG_SetPerspectiveFOV(fov) AMG_InitMatrixSystem(fov)
    AMG_SetAntialias(1);
    
    AMG_MP3 *fairy;
    
    //fairy = AMG_LoadMP3("Test.mp3");
    fairy = NULL;
    
    //AMG_LinkMP3(fairy);
    AMG_SetLoopMP3(fairy, 1);
    //fairy->Play = 1;
    AMG_PlayMP3(fairy);
    fairy->Play = 1;
    
    AMG.ClearColor = 0;                            //black bg
    //AMG_EnableFog(10.0f, -10.0f, 0xFFFFFFFF);
    
    //AMG_AllocateSharedTexture(256, 256, GU_PSM_8888);
    
    // Load Models (Planet model contains a lot of models inside, it was exported using Blender
    // Carga la fuente de texto
    
    /*
    AMG_Texture *font = AMG_LoadTexture("Files/font.png", AMG_TEX_RAM);
    AMG_DeleteColor(font, GU_RGBA(0, 0, 0, 0xFF));                        // Make the black colour transparent
    AMG_Create2dObject(font, GU_PSM_5551, 1);
    AMG_SwizzleTexture(font);
    */
    
    // Carga el modelo 3D    // Load the 3D model

    
    
    AMG.TextureQuality = GU_PSM_8888;    // Set Texture Quality GU_PSM_4444, GU_PSM_5650 or GU_PSM_5551
    AMG.TextureDest = AMG_TEX_RAM;
    AMG.TextureSwizzle = 1;
    
    
    AMG_Model *tie_fighter = AMG_LoadModel("Files/Tie-Fighter.obj");
    //AMG_Model *tie_fighter = AMG_LoadModel("Temple/Temple4.obj");
    
    //AMG_Texture *cri_body_base = AMG_LoadTexture("Files/cri_body_base.png", AMG_TEX_VRAM);
    
    //AMG_Model *tie_fighter = AMG_LoadModelA("Temple/Temple4.obj", 1);
    
    
    //AMG_Model *tie_fighter = NULL;
    

    //AMG_TransferTextureVram(GU_PSM_8888);
    //AMG_Model *tie_fighter = NULL;
    //tie_fighter->CelShading = 1;        // Activa CelShading    // Enable Cel-Shading (enable light before using this)
    //tie_fighter->Object[0].Lighting = 0;
    
    //AMG_AllocateSharedTexture(512, 512, GU_PSM_8888); //Couldn't allocate 1024kb in VRAM
    
    //AMG_Texture *Material__25 = AMG_LoadTexture("Files/DLC_CRI_102_02_base.png", AMG_TEX_VRAM);
    //AMG_Create2dObject(Material__25, GU_PSM_5551, 1);
    
    //AMG_UnloadTexture(Material__25);
    
    //AMG_Texture *Material__26 = AMG_LoadTexture("Files/DLC_CRI_102_01_base.png", AMG_TEX_VRAM);
    //AMG_Create2dObject(Material__26, GU_PSM_5551, 1);
    
    //AMG_Texture *Material__30 = AMG_LoadTexture("Files/cri_face_base.png", AMG_TEX_VRAM);
    //AMG_Create2dObject(Material__30, GU_PSM_5551, 1);
    
    //AMG_Texture *Material__35 = AMG_LoadTexture("Files/cri_body_base.png", AMG_TEX_VRAM);
    //AMG_Create2dObject(Material__35, GU_PSM_5551, 1);
    //map_Kd = cri_body_base.png;
    
    /*
    tie_fighter->Object[0].Pos.x = 0.0f;        // Posicionamos el modelo        // Set model position
    tie_fighter->Object[0].Pos.y = 7.0f;
    tie_fighter->Object[0].Pos.z = 4.0f;
    tie_fighter->Object[0].Scale.x = 0.8f;        // Configuramos la escala        // Set model scale
    tie_fighter->Object[0].Scale.y = 0.8f;
    tie_fighter->Object[0].Scale.z = 0.8f;
    */
    tie_fighter->Object[0].Pos.z = -250.0f;        // Set model position
    
    //AMG_Texture *black = AMG_LoadTexture("Files/black.png", AMG_TEX_RAM);    // Carga el lienzo en RAM        // Load it in RAM
    //AMG_Create2dObject(black, GU_PSM_8888, AMG_TEX_RAM);                            // Conviértelo en un sprite 2D    // Create 2D Object
    //black->X = (480 / 2);                                                    // Centramos el lienzo en el eje X...        // Center in X
    //black->Y = (272 / 2);
    
    //Light type
    AMG_Light[0].Type = GU_DIRECTIONAL;
    //Light parameters
    AMG_Light[0].Diffuse = GU_RGBA(250, 250, 250, 0x0F);
    AMG_Light[0].Ambient = GU_RGBA(90, 90, 110, 0x0F);
    AMG_Light[0].Specular = GU_RGBA(50, 50, 50, 0x0F);
    
    //Light position (direction vector)
    AMG_Light[0].Pos.x = 4.0f;
    AMG_Light[0].Pos.y = 4.0f;
    AMG_Light[0].Pos.z = 4.0f;
    
    //set a camera
    AMG_Camera *camera = AMG_InitCamera();
    camera->Pos.z = 20.0f;
    //camera->Pos.y = 0.0f;
    //camera->Pos.x = 0.0f;
    //camera->Rot.x = AMG_Deg2Rad(0.0f);
    //camera->Eye.x = 0.0f;
    //camera->Up.y = 1.0f;
    
    // Variables adicionales    // Additional stuff
    float alpha = 1.0f;            // Variable para controlar la transparencia del modelo    // Variable used to control model alpha-component
    float angle = 0.0f;            // El ángulo de rotación de la luz    // Light rotation angle
    
    //int M = 1;
    
    /*
    pspDebugScreenInit();
    //pspDebugScreenSetXY(40, 40);
    pspDebugScreenPrintf("HelloWorld!!");
    */

    while(!AMG.Exit){
                
        // Start 3d drawing
        AMG_Begin3D();    
        
        AMG_ReadButtons();
        
        AMG_SetCamera(camera);
        
        //AMG_LookAt(&camera->Pos.z, &camera->Eye.x, &camera->Up.y);
        //AMG_LookAt(&tie_fighter->Object[0].Pos.z, &tie_fighter->Object[0].Pos.x, &camera->Up.y);
        //AMG_LookAt(&tie_fighter->Object[0].Pos.z, &tie_fighter->Object[0].Pos.x, &tie_fighter->Object[0].Pos.y);
        
        // Activa la luz 0        // Enable light 0
        AMG_EnableLight(0);
        AMG_Light[0].Pos.x = AMG_Cos(angle) * 6.0f;
        AMG_Light[0].Pos.y = AMG_Sin(angle) * 6.0f;
        angle += AMG_Deg2Rad(1.0f);
        
        // Rotacion del modelo 3D    // 3D model rotation
        
        //if(AMG_Button.Held &PSP_CTRL_CROSS) tie_fighter->Object[0].Pos.z += AMG_Deg2Rad(1.0f); //kbd.Z
        //if(AMG_Button.Held &PSP_CTRL_CIRCLE) tie_fighter->Object[0].Pos.z -= AMG_Deg2Rad(1.0f); //kbd.X

        if(AMG_Button.Down &PSP_CTRL_START) M++;
        if(M > 10) M = 1;
        else if(M < 0) M = 1;
        
        //Move        
        //c++ case
        //http://www.cplusplus.com/doc/tutorial/control/
        
        if (M == 1) {
        //cout << "x is 1";
        //camera->Pos.z = 20.0f
        if(AMG_Button.Held &PSP_CTRL_UP) camera->Pos.y -= AMG_Deg2Rad(1.0f);
        if(AMG_Button.Held &PSP_CTRL_DOWN) camera->Pos.y += AMG_Deg2Rad(1.0f);
        if(AMG_Button.Held &PSP_CTRL_RIGHT) camera->Pos.x += AMG_Deg2Rad(1.0f);
        if(AMG_Button.Held &PSP_CTRL_LEFT) camera->Pos.x -= AMG_Deg2Rad(1.0f);
        if(AMG_Button.Held &PSP_CTRL_TRIANGLE) camera->Pos.z += AMG_Deg2Rad(1.0f); //kbd.S
        if(AMG_Button.Held &PSP_CTRL_SQUARE) camera->Pos.z -= AMG_Deg2Rad(1.0f);
        }
        else if (M == 2) {
        //cout << "x is 2";
        tie_fighter->Object[0].Pos.z -= AMG_Deg2Rad(1.0f);
        }
        else if (M == 3) {
        //cout << "x is 3";
        //tie_fighter->Object[0].Pos.z += AMG_Deg2Rad(1.0f);
        }
        else if (M == 4) {
        //cout << "x is 4";
        tie_fighter->Object[0].Pos.z += AMG_Deg2Rad(1.0f);
        }
        else {
        //cout << "value of x unknown";
        if(AMG_Button.Held &PSP_CTRL_UP) tie_fighter->Object[0].Rot.x -= AMG_Deg2Rad(1.0f);
        if(AMG_Button.Held &PSP_CTRL_DOWN) tie_fighter->Object[0].Rot.x += AMG_Deg2Rad(1.0f);
        if(AMG_Button.Held &PSP_CTRL_RIGHT) tie_fighter->Object[0].Rot.y += AMG_Deg2Rad(1.0f);
        if(AMG_Button.Held &PSP_CTRL_LEFT) tie_fighter->Object[0].Rot.y -= AMG_Deg2Rad(1.0f);    
        if(AMG_Button.Held &PSP_CTRL_TRIANGLE) tie_fighter->Object[0].Pos.z += AMG_Deg2Rad(1.0f); //kbd.S
        if(AMG_Button.Held &PSP_CTRL_SQUARE) tie_fighter->Object[0].Pos.z -= AMG_Deg2Rad(1.0f);  //kbd.A
        tie_fighter->Object[0].Pos.y -= AMG_Deg2Rad(((float)AMG_Button.JoyY / 64.0f));
        tie_fighter->Object[0].Pos.x += AMG_Deg2Rad(((float)AMG_Button.JoyX / 64.0f));
        }
        
        /*
        switch (M) {
            case 1:
                //cout << "x is 1";
                break;
            case 2:
                //cout << "x is 2";
                tie_fighter->Object[0].Pos.z -= AMG_Deg2Rad(1.0f);
                break;
            case 3:
                //cout << "x is 3";
                tie_fighter->Object[0].Pos.z += AMG_Deg2Rad(1.0f);
                break;
            default:
                //cout << "value of x unknown";
                break;
        }
        */
        
        //use useful variable for cam
        //cam->Eye.x +=
        
        if(AMG_Button.Held &PSP_CTRL_SELECT) tie_fighter->Object[0].Pos.z -= AMG_Deg2Rad(1.0f);
        
        //if(AMG_Button.Down &PSP_CTRL_CROSS) AMG_Screenshot("Photo.png");

        // Cambiamos el Alpha    // Time to change alpha-component
        if(AMG_Button.Held &PSP_CTRL_RTRIGGER) alpha += 0.05f;
        else if(AMG_Button.Held &PSP_CTRL_LTRIGGER) alpha -= 0.05f;
        if(alpha > 1.0f) alpha = 1.0f;
        else if(alpha < 0.0f) alpha = 0.0f;
        tie_fighter->Object[0].Group[0].Diffuse = GU_COLOR(1.0f, 1.0f, 1.0f, alpha);
        
        INFINITE++;
        if (INFINITE == 1000) {
        //if (INFINITE >= 1000 &INFINITE <= 2000) {

        //AMG_Model *tie_fighter = AMG_LoadModel("Files/Tie-Fighter.obj");

        //AMG_Update3D();    
        }
        else if (INFINITE == 2000) {
        //AMG_Model *tie_fighter = AMG_LoadModel("Temple/Temple4.obj");
        
        AMG_UnloadModel(tie_fighter);
        //AMG_UpdateMP3(fairy);
        //AMG_Update3D();    
        //AMG_UpdateAudio();
        //AMG_UpdateTime();
        //AMG_Finish3D();
        }
        else if (INFINITE == 3000) {
        //else if (INFINITE >= 3000 &INFINITE <= 4000) {
        //tie_fighter == NULL;
        //AMG_UnloadModel(tie_fighter);
        //AMG_UnloadTexture(tie_fighter);
        //AMG_UpdateMatrices();
        //AMG_Update3D();
        //AMG_UpdateTime();
        
        //AMG_Model *tie_fighter = AMG_LoadModel("Files/Tie-Fighter.obj");
        
        //AMG_UnloadTexture((tie_fighter)AMG.Lightmap);
        //free(amg_vram.block);
        
        //AMG_UnloadModelT(tie_fighter);
        
        //AMG_UnloadObject(tie_fighter);
        //AMG_UnloadTexture(tie_fighter);
        //AMG_UnloadModel(tie_fighter);
        
        //tie_fighter == NULL;
        //AMG_DestroyMatrixSystem();
        //AMG_Update3D();    
        //AMG_UpdateTime();
        
        //free(amg_scrfade); amg_scrfade = NULL;
        //AMG_UnloadTexture((AMG_Texture*)AMG.Lightmap);
        //AMG_DestroyMatrixSystem();
        
        //return NULL;
        //tie_fighter == NULL;
        //sceKernelDcacheWritebackAll(); // flush cache so that no stray data remains
        //AMG_UnloadModel(tie_fighter);
        
        //AMG_UnloadModel(AMG_Model *model);
        //AMG_UnloadObject(AMG_Object *model);
        
        //AMG_UnloadObject(tie_fighter); //????
        }
        else if (INFINITE == 4000) {
        //else if (INFINITE >= 4000 &INFINITE <= 5000) {
        //AMG.TextureQuality = GU_PSM_8888;    // Set Texture Quality GU_PSM_4444, GU_PSM_5650 or GU_PSM_5551
        //AMG.TextureDest = AMG_TEX_VRAM;
        //AMG.TextureSwizzle = 1;
        
        //AMG_Model *tie_fighter = AMG_LoadModel("Files/Tie-Fighter.obj");
        //AMG_EnableLight(0);
        
        //AMG_DrawSprite(black);
        //AMG_RenderModel(tie_fighter);
        
        //AMG_DisableLight(0);
        //AMG_Update3D();    
        }
        else {
        //cout << "value of x unknown";
        }
        
        AMG_EnableLight(0);
        
        //AMG_DrawSprite(black);
        AMG_RenderModel(tie_fighter);
        
        AMG_DisableLight(0);
        
        //bones:C:\pspsdk\psp\sdk\samples\gu\morphskin

        AMG_OrthoMode(1);    // Modo 2D
        /*
        sprintf(text, "FPS: %d", AMG.FPS);
        AMG_Printf(font, 0, 0, 0xFFFFFFFF, text);
        
        sprintf(text, "M: %f", M);
        AMG_Printf(font, 0, 10, 0xFFFFFFFF, text);
        
        //sprintf(text, "CABLE: %u", pspDveMgrCheckVideoOut());
        //AMG_Printf(font, 0, 30, 0xFFFFFFFF, text);
        
        //sprintf(text, "POS Z: %f", tie_fighter->Object[0].Pos.z);

        sprintf(text, "INFINITE: %f", INFINITE);
        AMG_Printf(font, 0, 50, 0xFFFFFFFF, text);
        
        if (M == 1) {
        sprintf(text, "Cam POS x: %.2f y: %.2f z: %.2f", camera->Pos.x, camera->Pos.y, camera->Pos.z);
        AMG_Printf(font, 0, 20, 0xFFFFFFFF, text);
        }
        else if (M == 2) {
        sprintf(text, "Auto Cri POS Z: %.2f", tie_fighter->Object[0].Pos.z);
        AMG_Printf(font, 0, 20, 0xFFFFFFFF, text);
        }
        else if (M == 3) {
        sprintf(text, "Locked");
        AMG_Printf(font, 0, 20, 0xFFFFFFFF, text);
        }
        else if (M == 4) {
        sprintf(text, "Auto Cri POS Z: %.2f", tie_fighter->Object[0].Pos.z);
        AMG_Printf(font, 0, 20, 0xFFFFFFFF, text);
        }
        else {
        sprintf(text, "Cri POS x: %.2f y: %.2f z: %.2f", tie_fighter->Object[0].Pos.x, tie_fighter->Object[0].Pos.y, tie_fighter->Object[0].Pos.z);
        AMG_Printf(font, 0, 20, 0xFFFFFFFF, text);
        sprintf(text, "Cri ROT x: %.2f y: %.2f z: %.2f", tie_fighter->Object[0].Rot.x, tie_fighter->Object[0].Rot.y, tie_fighter->Object[0].Rot.z);
        AMG_Printf(font, 0, 30, 0xFFFFFFFF, text);
        }
        //wrong
        //sprintf(text, "AMG_GetVramSize: %.2f", AMG_GetVramSize(10, 10, GU_PSM_8888));
        //AMG_Printf(font, 0, 40, 0xFFFFFFFF, text);
        
        //std::cout << "File already exists" << std::endl;
        
        */
        
        //f = fopen("log.txt", "wb");
        //fprintf(f, "Cri POS x: %.2f y: %.2f z: %.2f\n", tie_fighter->Object[0].Pos.x, tie_fighter->Object[0].Pos.y, tie_fighter->Object[0].Pos.z);
        //fclose(f); f = NULL;
        
        
        AMG_OrthoMode(0);    // Fin del modo 2D    
        
        //AMG_UpdateMatrices();
        AMG_UpdateMP3(fairy);
        AMG_Update3D();    
        AMG_UpdateAudio();
        AMG_UpdateTime();    // Actualiza el tiempo    // Update time
        
        //AMG_ReadButtons();
        // Capturas de pantalla
        if(AMG_Button.Down &PSP_CTRL_CIRCLE) AMG_Screenshot("Photo2.png");
    }
    
    // End
    AMG_UnloadMP3(fairy); // I think this is correct it was missing
    AMG_UnloadModel(tie_fighter);    // Elimina el modelo 3D            // Unload the 3D model
    //AMG_UnloadTexture(black);
    //AMG_UnloadTexture(font);
    AMG_Finish3D();                //
    return AMG_ReturnXMB();        //
}


Attached File(s) Thumbnail(s)
       

ASRock Fatal1ty Z97 Killer | Intel i7-4790k @ 4.0GHz | 2x4GB DDR3 1600MHz | EVGA GTX 1070 | Windows 10 Pro x64
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
OneLua - jkpwed - 09-21-2014, 01:56 PM
RE: ONElua v2 - jkpwed - 10-11-2014, 08:29 PM
RE: ONElua v2 - jkpwed - 10-14-2014, 06:40 PM
RE: ONElua v2 - jkpwed - 10-21-2014, 07:36 PM
RE: OneLua - jkpwed - 02-15-2015, 12:07 PM
RE: OneLua - jkpwed - 06-23-2015, 12:00 AM
RE: OneLua - jkpwed - 06-25-2015, 08:33 PM
RE: OneLua - Haseeb - 06-29-2015, 12:44 PM
RE: OneLua - jkpwed - 06-30-2015 12:24 PM
RE: OneLua - Haseeb - 06-30-2015, 01:54 PM
RE: OneLua - jkpwed - 06-30-2015, 02:49 PM
RE: OneLua - jkpwed - 07-12-2015, 01:19 PM
RE: OneLua - jkpwed - 07-23-2015, 01:39 PM

Forum Jump: