About Store Forum Documentation Contact



Post Reply 
Image::Draw3D
Author Message
Panerox Offline
Member

Post: #1
Image::Draw3D
how and where (in which rendering mode) to use the methods Image:: Draw3D? anybody can tell and/or give an example. the method is very strange to work or i dont have enough information. and one more question... how to use Billboards in EE? grin
03-01-2010 02:27 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Image::Draw3D
the holographic image tutorial (and object clouds tutorial) uses draw3D method

the other method (billboard one) can be called either in RM_BLEND mode or outside the Rendering function (in Draw)
I'll update the comment on that method.
03-01-2010 02:45 PM
Find all posts by this user Quote this message in a reply
Panerox Offline
Member

Post: #3
RE: Image::Draw3D
i still have problems displaying billboards. i still do not understand how to use the mode when displaying images. ill try to explain what is happening.
i changed the example code "06 - Pathfind.cpp".
here is an example:
Code:
/******************************************************************************/
#include "stdafx.h"
#include "../../../../../data/enum/_enums.h"
/******************************************************************************/

Image* testImg;

struct StaticObj : Game::Static
{
     virtual void create(Game::ObjParams &obj)
     {
         Game::Static::create(obj);  
     }
     virtual UInt drawPrepare()
     {
         //first way
/*
         UInt modes = IndexToFlag(RM_SOLID);
         Game::Static::drawPrepare();
         return modes;
*/

         //second way
         UInt modes = 0;
         Game::Static::drawPrepare();
         return modes;
     }
     virtual void drawSolid()
     {
            drawTest();
     }
     virtual void drawTest()
     {
         if(Frustum(mesh->box, matrixScaled()))
         {
             testImg->draw3D(Color(255, 255, 255, 255), 1.0, 0, pos() + Vec(0,1.0,0));
         }
     }
};

Game::ObjMemx<Game::Chr   > Chrs   ;
Game::ObjMemx<StaticObj> Statics;

Decal decal; // decal pointing character destination target
/******************************************************************************/
void InitPre()
{
   App.name("Pathfind");
   App.flag=APP_ALLOW_SINGLE_PASS|APP_FULL_TOGGLE;
   IOPath("../data");
   Paks.add("engine.pak");

   D.full(false).sync(true).hpRt(true);

   ViewportFull.range=50;
   Cam.dist = 10;
   Cam.yaw  =-PI_4;
   Cam.pitch=-PI_3;
}
/******************************************************************************/
Bool Init()
{
   Physics.create();
   Sky    .atmospheric();
   Sun.image=Images("gfx/sky/sun.gfx"); Sun.light_color=1-D.ambColor();

   testImg = Images("gfx/test.gfx");

   decal.terrain_only=true;
   decal.color.set(1,1,0,1);
   decal.material(Materials("Decal/star.mtrl"));

   Game::World.init      (                  )
              .setObjType(Chrs   ,OBJ_PLAYER)
              .setObjType(Statics,OBJ_STATIC)
              .New       ("world/path.world")
              .update    (Cam.at            );

   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Update()
{
   if(Kb.bp(KB_ESC))return false;

   Game::World.update(Cam.at);

   // move player
   if(Ms.bp(0) && Chrs.elms()) // on LMB pressed
   {
       // convert screen mouse position to world position and direction
      Vec     pos,dir ; ScreenToPosDir(Ms.pos,pos,dir);
      PhysHit phys_hit;
      if(Physics.ray(pos,dir*ViewportActive.range,&phys_hit)) // if ray-test hit something
      {
         Chrs[0].actionMoveTo(phys_hit.plane.pos); // order character to move to that location

         decal.matrix.setPosDir(phys_hit.plane.pos,Vec(0,1,0));
      }
   }

   // rotate camera
   if(Ms.b(1))
   {
      Cam.yaw  -=Ms.dir_d.x;
      Cam.pitch+=Ms.dir_d.y;
   }
   if(Chrs.elms())Cam.setSpherical(Chrs[0].pos(),Cam.yaw,Cam.pitch,0,Cam.dist*ScaleFactor(Ms.wheel()*-0.2)).
       updateVelocities().set();

   // rotate decal around its z axis
   decal.matrix.orn.rotateZVec(Time.d());

   return true;
}
/******************************************************************************/
void Render()
{
   Game::World.draw();
  
   switch(Renderer())
   {
      case RM_BLEND:
      {
         if(Chrs.elms())
            if(Chrs[0].action==Game::ACTION_MOVE_TO)decal.drawStatic();
      }break;
   }
}
void Draw()
{
   Renderer(Render);

   //Where to call a method Image3D????????
   FREP(Statics.elms())
   {
       StaticObj& obj = Statics[i];
       obj.drawTest();
   }



   // show blocked places
   if(Kb.b(KB_SPACE)) // if space pressed
      if(Chrs.elms()) // if at least one character is available
   {
      Vec   pos     =Chrs[0].pos(); // get character position
      VecI2 area_pos=Game::World.worldToAreaPos(pos); // convert from world position to area coordinates
      if(Game::AreaPath *path=Game::World.pathGet(area_pos)) // if found paths at given coordinates
      {
         D.clearZ (); // clear Z Buffer
         SetMatrix(); // reset drawing matrix

         Vec world_pos=Game::World.areaToWorldPos(area_pos).x0y();  // convert 2D Area Coordinates to 3D World Position
         Flt cell_size=(1.0f/Game::World.pathRes())*Game::World.areaSize(); // get size of a single path cell

         VI.color(ColorAlpha(RED,0.5f)); // set drawing color to transparent RED
         REPD(y,Game::World.pathRes())
         REPD(x,Game::World.pathRes())if(!path->walkable(x,y)) // if current cell isn't walkable
         {
            Vec pos=world_pos+Vec(x,0,y)*cell_size; // get world position of a single path cell

            VI.quad(pos+Vec(        0,0,cell_size), // draw a quad which extends 'pos' to right and forward by 'cell_size'
                    pos+Vec(cell_size,0,cell_size),
                    pos+Vec(cell_size,0,        0),
                    pos+Vec(        0,0,        0));
         }
         VI.end();
      }
   }

   // informations
   D.text(0,0.9,"Press LMB to move player, RMB to rotate camera");
   D.text(0,0.8,"Press Space to show blocked places at character position");
}
/******************************************************************************/
and i changed the Access (in Default) for all rock objects in the path.world.
Billboards are not displayed correctly when the player moves. see screenshots.
in my game they were not displayed correctly when i start to use mesh-> drawBlend () for some objects. what am i doing wrong? Where and how to properly call the Image:: draw3D ()?


Attached File(s) Image(s)
       
(This post was last modified: 03-04-2010 01:14 PM by Panerox.)
03-04-2010 01:13 PM
Find all posts by this user Quote this message in a reply
Panerox Offline
Member

Post: #4
RE: Image::Draw3D
maybe i need to do something with the matrix (set matrix or something else)?
03-04-2010 02:31 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Image::Draw3D
try calling SetMatrix() before drawing billboards
03-04-2010 02:46 PM
Find all posts by this user Quote this message in a reply
Panerox Offline
Member

Post: #6
RE: Image::Draw3D
yessmile before calling the method need to set the matrix (MatrixIdentity).
About this i forgot. i think you can make a small tutorial.
03-04-2010 02:51 PM
Find all posts by this user Quote this message in a reply
Post Reply