About Store Forum Documentation Contact



Post Reply 
Mesh Load
Author Message
kaito Offline
Member

Post: #1
Mesh Load
Hi, once more. smile

I am adding new pieces of the program, and compiling.

The code worked well, until I added the piece marked with //+++++++++++++++++++++++++++++++++++++++++++

After compiling, I could not see the mesh. (before that, yes).

I reinstalled esenthel, add LightDir, change the file,...

Had created a small terrain (mesh), and wanted to apply a mirror effect to join the two meshes, and create a continuous repetition.

I changed the mesh file, by other mesh included in the data folder of esenthel.

Code:
/******************************************************************************/
#include "stdafx.h"   // include precompiled header
#include "resource.h" // include resources (icon)
/******************************************************************************/

Flt incrementoX(0), incrementoZ(0), inc(0.2);

Mesh meshMalla1, meshMalla2;
Matrix matrixMalla1, matrixMalla2;

void InitPre() // init before engine inits
{
   // here you will have to setup initial engine settings
   // like application name, its options, screen resolution...

   App.name("Demo");            // application name
   App.icon=(Char*)IDI_ICON1;    // setup icon
   IOPath("../data/");
   PakAdd("../data/engine.pak"); // load engine data

   D.full(true).ambPower(1).hpRt(true).hwDepthBuffer(true);

}
/******************************************************************************/
Bool Init() // init after engine inits
{
   // here when engine will be ready you can load your game data
   // return false when error occured

    meshMalla1.load("obj/item/misc/barrel/0.mesh");
    matrixMalla1.pos.set(0,0,0);
    matrixMalla1.rotateX(1.5f);
    matrixMalla1.scale(Vec(3.5,2,3.2));


    // +++++++++++++++++++++++++++++++++++++
    meshMalla2.load("obj/item/misc/barrel/0.mesh");
    meshMalla2.mirrorY();
    matrixMalla2.pos.set(0,0,2);
    matrixMalla2.rotateX(1.5f);
    matrixMalla2.scale(Vec(3.5,2,3.2));
    // +++++++++++++++++++++++++++++++++++++


    //Water.set(*Gfxs("gfx/water/0.gfx"),*Gfxs("gfx/water/0.n.gfx"),Gfxs("gfx/fx/reflection.gfx"));
    //Water.plane(Water.plane()+ Vec(0,-5,0));
    //Water.wave_scale=0.05f;

    Sun &sun=Suns.New();
    sun.set(*Gfxs("gfx/sky/sun.gfx")); // set image
    sun.pos=!Vec(1,1,1);               // set custom position

    Sky.set();

    Cam.pitch=-1.57f; Cam.matrix.setPos(Vec(0,3,0));
    Cam.setAngle(Cam.matrix.pos,Cam.yaw,Cam.pitch,Cam.roll).updateVelocities().​set();

   return true;
}
/******************************************************************************/
void Shut() // shut at exit
{
   // this is called when the engine is about to exit
}
/******************************************************************************/
Bool Main() // main updating
{
   // here you have to process each frame update

    if(Kb.bp(KB_ESC))return false; // exit if escape on the keyboard pressed
    if ((Kb.br(KB_UP))) {incrementoZ+=inc;}
    if ((Kb.br(KB_DOWN))) {incrementoZ-=inc;}
    if (Kb.br(KB_LEFT)) {incrementoX-=inc;}
    if (Kb.br(KB_RIGHT)) {incrementoX+=inc;}
    if (Kb.br(KB_NPSUB)) {inc-=0.01f;}
    if (Kb.br(KB_NPADD)) {inc+=0.01f;}
    
    //matrixMalla2.pos.set(matrixMalla2.pos.x+incrementoX,matrixMalla2.pos.y,matrixMal​la2.pos.z+incrementoZ);

    //incrementoX=incrementoZ=0;    

    //Water.update(Vec2(0.2,0.2));

   return true;                   // continue
}
/******************************************************************************/
void Render()
{
   switch(Renderer())
   {

   case RM_SOLID : case RM_SOLID_M :  {

       meshMalla1.draw(matrixMalla1);
       meshMalla2.draw(matrixMalla2);

       break;
       }
   }
}


void Draw() // main drawing
{
   // here you have to tell engine what to draw on the screen

    Renderer(Render);

}
/******************************************************************************/

Regards
04-06-2009 10:31 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
Re: Mesh Load
Hello,

could you try calling Mesh::setRender after making any modifications to the Mesh?

Code:
meshMalla2.load("obj/item/misc/barrel/0.mesh");
meshMalla2.mirrorY();
meshMalla2.setRender();

also the matrix operations seem insufficient:
Code:
matrixMalla2.pos.set(0,0,2);
   matrixMalla2.rotateX(1.5f);
   matrixMalla2.scale(Vec(3.5,2,3.2));

matrixMalla2.pos.set(0,0,2); // here you set only matrix position, but the matrix orientation vectors are still zero
so when you apply rotation
matrixMalla2.rotateX(1.5f);
you're applying rotation on zero length orientation vectors.

please try something like this:
Code:
matrixMalla2.setScale(..)
              .rotateX(..)
              .move(..);
04-06-2009 10:47 PM
Find all posts by this user Quote this message in a reply
kaito Offline
Member

Post: #3
Re: Mesh Load
Solved, I've made the changes you've ordered.



Code:
meshMalla1.load("LocalData/Obj/Terreno1.mesh");
matrixMalla1.setScale(12)
                .rotateX(1.57f)
                .move(Vec(-0.5,-2.89,-1.486));

meshMalla2.load("LocalData/Obj/Terreno1.mesh");
meshMalla2.mirrorY()
               .setRender();
matrixMalla2.setScale(12)
                .rotateX(1.57f)
                .move(Vec(-0.5,-2.89,1));
04-07-2009 08:39 PM
Find all posts by this user Quote this message in a reply
Post Reply