Jump to content

DarthRaff

Members
  • Posts

    152
  • Joined

  • Last visited

Posts posted by DarthRaff

  1. Thank you very much for your answers.

     

    Not tryed copy the files because i thought that if it's a new version framewerk.cpp and framewerk.h don't will work. but i will try.

     

    Yes i found the page and i'm try the appropriate changes but i have an error.

     

    Here is the code:

    //#include "framewerk.h"
    #include "engine.h"
    #include <math.h>
    #include <string>
    #include <vector>
    #include "monsterfuncs.h"
    //#include <iostream>
    #include <sstream>
    
    using namespace std;
    string nametext;
    string picname;
    int countimage=0;
    
    #pragma warning(disable:4996)
    
    int state;
    float fb;
    float fe;
    
    int animtex;
    
    TController player;
    TMesh mirillasprite;
    TMaterial mirillamat[2];
    TTexture mirillatex;
    TMesh telaranya1;
    
    TTexture electrictex[5];
    TTexture electrictexdot[5];
    TMaterial electricmat;
    //TTexture electrictex;
    //TTexture electrictexdot;
    
    string StringToInt(int number)
    {
    stringstream ss;//create a stringstream
    ss << number;//add number to the stream
    return ss.str();//return a string with the contents of the stream
    //return (str)ss.c_str();
    }
    
    
    class Monster
    {
    public:
    TController monstercont;
    TMesh monsterent;
    TVec3 monsterpos;
    TVec3 monsterrot;
    int monsterstate;
    float mstartframe;
    float mendframe;
    //TMaterial monstermat;
    };
    vector<Monster> monsterarray;
    vector<Monster>::iterator monsteriter;
    
    void LoadTextureSeq(string name,int num)
    {
    string tn;
    string tndot;
    int n=0;
    for(n=0;n!=num;n++)
    {
    	tn="objs/monsters/DK1/";
    	tn+=name;
    	tn+=StringToInt(n+1);
    	tn+=".dds";
    	electrictex[n]=LoadTexture((str)tn.c_str());
    	tndot="objs/monsters/DK1/";
    	tndot+=name;
    	tndot+=StringToInt(n+1);
    	tndot+="dot3";
    	tndot+=".dds";
    	electrictexdot[n]=LoadTexture((str)tndot.c_str());
    }
    }
    
    void UpdateTexture(int num)
    {
    animtex++;
    if(animtex > num-1)
    {
    	animtex=0;
    }
    SetMaterialTexture(electricmat,electrictex[animtex],0);
    SetMaterialTexture(electricmat,electrictexdot[animtex],1);
    }
    
    void UpdateMonsters()
    {
    for(monsteriter=monsterarray.begin();monsteriter!=monsterarray.end();monsteriter++)
    {
    	SlowPointEnt((*monsteriter).monstercont,player,.5);
    	//PointEntity((*monsteriter).monstercont,player,3,0.5f,.0f);
    	(*monsteriter).monsterrot=EntityRotation((*monsteriter).monstercont);
    	UpdateController((*monsteriter).monstercont,(*monsteriter).monsterrot.Y,0.0f,0.0f,0.0f,500);
    	RotateEntity((*monsteriter).monsterent,(*monsteriter).monsterrot);
    	PositionEntity((*monsteriter).monsterent,Vec3((*monsteriter).monsterpos.X,(*monsteriter).monsterpos.Y-1.02,(*monsteriter).monsterpos.Z));
    	if(KeyHit(KEY_UP))
    	{
    		if((*monsteriter).monsterstate <3)
    		{
    			monsteriter->monsterstate++;
    		}
    		else
    		{
    			monsteriter->monsterstate=0;
    		}
    	}
    	if(KeyHit(KEY_DOWN))
    	{
    		if((*monsteriter).monsterstate >0)
    		{
    			monsteriter->monsterstate--;
    		}
    		else
    		{
    			monsteriter->monsterstate=3;
    		}
    	}
    	switch ((*monsteriter).monsterstate)
    	{
    		case 1:
    			monsteriter->mstartframe=41.0f;
    			monsteriter->mendframe=85.0f;
    			break;
    		case 2:
    			monsteriter->mstartframe=90.0f;
    			monsteriter->mendframe=117.0f;
    			break;
    		case 3:
    			monsteriter->mstartframe=149.0f;
    			monsteriter->mendframe=184.0f;
    			break;
    		default:
    			monsteriter->mstartframe=1.0f;
    			monsteriter->mendframe=40.0f;
    			break;
    	}
    	AnimeEntitySeq((*monsteriter).monsterent,(*monsteriter).mstartframe,(*monsteriter).mendframe,3.0f,100.0f);
    	//PaintEntity((*monsteriter).monsterent,electricmat);
    }
    }
    
    float IntToFloat1(int n)
    {
      return(float(float(n)/float(255.0)));
    }
    
    TVec4 StringToVec4(string s, int noconv=0)
    {
      flt a[4], cf=0;
      int p=0, q=0, i=0, ci=0;
      string c;
      if(s.length()>0)
      {
         while(p<=(signed)s.length())
         {
            q=p+1;
            p=(s+" ").find(" ",q)+1;
            c=s.substr(q-1,p-q);
            if((c.find(".")!=-1)|(noconv))
            {
               sscanf(c.c_str(),"%f",&cf);
               a[i]=cf;
            }
            else
            {
               sscanf(c.c_str(),"%d",&ci);
               a[i]=IntToFloat1(ci);
            }
            i++;
         }
      }
      return(Vec4(a[0],a[1],a[2],a[3]));
    }
    
    void ProcessSceneObjects(TEntity scene)
    {
    TEntity ent;
    TModel entmesh;
    TVec3 entpos;
    string s="";
    string cname;
    string cname2;
    TVec4 color;
    int intensity;
    //TMaterial doormat;
    
    for (int i = 1; i <= CountChildren(scene); i++)
    {
    
    	ent = GetChild(scene,i);
    	cname=GetEntityKey(ent,"classname","");
    
    	if(cname=="room")
    	{
    		EntityType(ent,2);
    	}
    
    	if(cname=="playerstart")
    	{
    		PositionEntity(player,EntityPosition(ent));
    	}
    
    }
    }
    
    int main( int argn, char* argv[] )
    {
    int screenx=1280, screeny=960, camx=screenx/2, camy=screeny/2;
    
    Initialize() ;
    
    //Create a graphics context
    Graphics(screenx,screeny);
    
       TFramework framework=CreateFramework(); 
       TLayer layer = GetFrameworkLayer(0); 
       TCamera cam=GetLayerCamera(layer); 
       PositionEntity(cam,Vec3(0,0,0));
    TListener listener=GetFrameworkListener();
    EntityParent(listener,cam);
    
       //Set Lua variable 
       BP L=GetLuaState(); 
       lua_pushobject(L,framework); 
       lua_setglobal(L,"fw"); 
       lua_pop(L,1); 
    
       // Setup Initial Post Processing FX 
       SetGodRays(1); 
       SetHDR(0); 
       SetSSAO(1); 
       SetBloom(0); 
       SetAntialias(1); 
       SetStats(2);
    
    // Setup Collisions
    Collisions(1, 1, 1);
    Collisions(1, 2, 1);
    Collisions(1, 3, 1);
    Collisions(2, 2, 1);
    Collisions(2, 3, 1);
    Collisions(3, 3, 1);
    
    Monster m;
    	m.monstercont=CreateController(2.7f,0.9f,0.25f,45);
    
    	//GetFrameworkLayer(1);
    	m.monsterent=LoadMesh("objs/monsters/DK1/Material4/dk1.gmf");
    	//GetFrameworkLayer(0);
    
    	m.monsterrot=Vec3(0.0f,0.0f,0.0f);
    	m.monsterpos=Vec3(0.0f,1.5f,-2.0f);
    	m.monsterstate=0;
    	RotateEntity(m.monstercont,m.monsterrot);
    	RotateEntity(m.monsterent,m.monsterrot);
    	PositionEntity(m.monstercont,m.monsterpos);
    	PositionEntity(m.monsterent,m.monsterpos);
    
    	EntityType(m.monstercont,2);
    	SetBodyMass(m.monstercont,80.0f);
    
    	//electricmat=LoadMaterial("objs/monsters/DK1/electric1.mat");
    	//PaintEntity(m.monsterent,electricmat);
    
    	monsterarray.push_back(m);
    
    int sequence=1;
    float framebegin;
    float frameend;
    float frame;
    
    ////Load Texture Seq
    //LoadTextureSeq("electric",5);
    
    //Create a physics body
    TBody body=CreateBodyBox();
    SetBodyMass(body,10.0f);
    TMesh mesh=CreateCube();
    EntityParent(mesh,body);
    PositionEntity(body,Vec3(-6,5,0));
    EntityType(body,2);
    TMaterial meshmat=LoadMaterial("objs/Pruebas/a1.mat");
    PaintEntity(mesh,meshmat);
    
    //Create another physics body
    TModel oildrum=LoadModel("scene/oildrum.gmf");
    PositionEntity(oildrum,Vec3(6,5,0));
    EntityType(oildrum,2);
    SetBodyMass(oildrum,10.0f);
    
    
    player=CreateController(1.84f,0.50f,0.5f,45);
    //player=CreateController(1.84f,0.50f,0.5f,45);
    EntityType(player,1);
    //SetBodyDamping(player,.5f,.5f);
    SetBodyMass(player,60.0f);
    //SetWorldGravity(Vec3(0,-9.8f,0));
    float move=0.0;
    float strafe=0.0;
    bool crouch=0;
    float cameraheight=1.74f;
    TVec3 camrotation=Vec3(0);
    TVec3 playerpos;
    float mx=0;
    float my=0;
    HideMouse();
    //MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2);
    MoveMouse(camx,camy);
    
    PositionEntity(player,Vec3(0.0f,3.0f,-3.0f));
    
    GetFrameworkLayer(1);
    
    mirillasprite=LoadMesh("Sprites/simplesprite1.gmf",GetLayerCamera(layer));
    mirillamat[0]=LoadMaterial("Sprites/white.mat");
    mirillamat[1]=LoadMaterial("Sprites/green.mat");
    mirillatex=mirillamat[0];
    PaintEntity(mirillasprite,mirillatex);
    PositionEntity(mirillasprite,Vec3(0,0,0.15));
    ScaleEntity(mirillasprite,Vec3(.08f,.08f,1.0f));
    
    telaranya1=LoadMesh("Sprites/simplesprite2.gmf");
    ScaleEntity(telaranya1,Vec3(2.0f,2.0f,1.0f));
    PositionEntity(telaranya1,Vec3(3.0f,1.5f,.0f));
    RotateEntity(telaranya1,Vec3(.0f,45.0f,.0f));
    
    GetFrameworkLayer(0);
    
    LoadScene("scene/prueba5.sbx");
    
    int debphy=0;
    
    //Main loop
    // Game loop
    while( !KeyHit(KEY_ESCAPE) && !AppTerminate() )
    {
    	if( !AppSuspended() ) // We are not in focus!
    	{
    
    		if(KeyHit(KEY_P)){debphy=1-debphy;DebugPhysics(debphy);}
    
    		move=(KeyDown(KEY_W)-KeyDown(KEY_S));
    		strafe=(KeyDown(KEY_D)-KeyDown(KEY_A));
    
    		//Jumping
    		float jump=0.0;
    		if (KeyHit(KEY_SPACE)) {
    			if (!ControllerAirborne(player)) {
    				jump=4.0;
    			}
    		}
    		//Run
    		if (KeyDown(KEY_LSHIFT)||KeyDown(KEY_RSHIFT)) {
    			if (!ControllerAirborne(player)) {
    				move/=2.0;
    				strafe/=2.0;
    			}
    		}
    		//crouch
    		if (KeyHit(KEY_C)){
    			//if (ControllerCrouched(player)){
    			if (crouch==1){
    				crouch=0;                        
    				cameraheight=1.74f;
    			}
    			else{
    				crouch=1;                        
    				cameraheight=0.80f;
    			}
    		}
    
    		playerpos=EntityPosition(player);
    		//Camera looking
    		mx=Curve(MouseX()-GraphicsWidth()/2,mx,6);
    		my=Curve(MouseY()-GraphicsHeight()/2,my,6);
    		MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2);
    		camrotation.X=camrotation.X+my/5.0;
    		if (camrotation.X < -90){ camrotation.X = -90;}
    		if (camrotation.X > 90){ camrotation.X = 90;}
    		camrotation.Y=camrotation.Y-mx/5.0;
    		RotateEntity(cam,camrotation);
    
    		////Set controller input
    		UpdateController(player,camrotation.Y,move*3.0,strafe*3.0,jump,500,1,crouch);
    		PositionEntity(cam,Vec3(playerpos.X,playerpos.Y+cameraheight,playerpos.Z));
    		TVec3 camerapos=EntityPosition(cam);
    		TVec3 poscont=EntityPosition(player);
    
    
    		if(MouseDown(2))
    		{
    			mirillatex=mirillamat[1];
    		}
    		else
    		{
    			mirillatex=mirillamat[0];
    		}
    
    		GetFrameworkLayer(1);			
    
    		PaintEntity(mirillasprite,mirillatex);
    
    		GetFrameworkLayer(0);
    
    		UpdateAppTime();
    		UpdateWorld(AppSpeed()) ;
    
    		PositionEntity(cam,camerapos);
    
    		//UpdateTexture(5);
    		UpdateMonsters();
    
    
    		UpdateFramework();
    		RenderFramework();
    
    		if(KeyHit(KEY_F1)) // Press F1 to save a screenshot
    		{
    			countimage+=1;
    			picname="Pics/ScreenShoot_";
    			picname+=StringToInt(countimage);
    			picname+=".jpg";
    			char fn[32] = {0};
    			_snprintf(fn, 31, (str)picname.c_str(), GetTickCount());
    			SaveBuffer(BackBuffer(), fn, 100);
    		}
    
    		// Send to screen
    		Flip(0) ;
    	}
    }
    
    //// Done
    ////exitapp:
    FreeFramework(framework);
    return Terminate() ;
    }

     

    and the error (it's not an error but it appears in the engine text):

     

    Leadwerks Engine 2.40

    Initializing Renderer...

    OpenGL Version: 3.0.0

    GLSL Version: 1.30 NVIDIA via Cg compiler

    Render device: GeForce 9800 GT/PCI/SSE2

    Vendor: NVIDIA Corporation

    DrawBuffers2 supported: 1

    32 texture units supported.

    GPU instancing supported: 1

    Max batch size: 64

    Shader model 4.0 supported: 1

    Conditional render supported: 0

    Error: Shader file "abstract::query.vert" not found.

     

    i don't know what is that file because i never had that error before. Thank you

  2. Well, when i compile the program it can't find any framewerk asociated word and can't find the include. I know that framework is similar but, for example, in framewerk you can do as easy as:

        leadwerks::Framewerk fw;
    fw.Create();
    // Setup Global Objects
    SetGlobalObject ("world_main", fw.GetMain ().GetWorld ());
    SetGlobalObject ("world_transparency", fw.GetTransparency ().GetWorld ());
    SetGlobalObject ("world_background", fw.GetBackground ().GetWorld ());
    SetGlobalObject ("camera_main", fw.GetMain ().GetCamera ());
    SetGlobalObject ("camera_transparency", fw.GetTransparency ().GetCamera ());
    SetGlobalObject ("camera_background", fw.GetBackground ().GetCamera ());
    TListener listener= CreateListener(fw.GetMain ().GetCamera ());
    SetGlobalObject("listener", listener);
    // Setup Initial Post Processing FX 
    fw.GetRenderer().SetGodRays(1);
    fw.GetRenderer().SetHDR(0);
    fw.GetRenderer().SetSSAO(1);
    fw.GetRenderer().SetBloom(0);
    fw.GetRenderer().SetAntialias(1);
    fw.GetRenderer().SetReflectionRenderComponents(ENTITY_RENDERABLE);

     

    and in framework it's similar but i can't find, for example, how to set up the post processing fx, and so

  3. Hello,

     

    i'm making a function to load a number of textures to make an animated one.

     

    void LoadTextureSeq(string name,int num)
    {
    TTexture tex[4];
    string path="objs/monsters/DK1/";
    string tn;
    int n;
    for(n=1;n!=num;n++)
    {
    	tn=path;
    	tn+=name;
    	tn+=n;
    	tn+=".dds";
    	tex[n-1]=LoadTexture(tn);
    
    }
    }
    .
    .
    .
    LoadTextureSeq("electric",5);

     

    this gives me that error:

     

    error C2664: 'LoadTexture' : cannot convert parameter 1 from 'std::string' to 'str'

     

    Please, what am i doing wrong ? thank you.

  4. Hello,

     

    can someone, please, tell me how to put an animated alpha texture in an animated model? i have the idea of some kind of electric creature as an enemy and need animated electricity texture on it (a not animated texture would seem more a vascular system than electric :) ) thank you in advance.

  5. Hi,

    yes i now that unwrap save ms3d, the problem is that, if the model have more poligons than ms3d suports, then it gives an error and not save the model. It's weird because the milkshape 3d program save the model no matter the number of poligons have even is limited.

     

    But thank you very much for your answer ;) .

  6. Hello,

     

    I'm modelling all my models in milkshape 3D because is the most easy to use app i ever seen but it's limited to about 8600 polys, and my mansion hall (well, the half of the hall) is about 8800 so i have to cut it in parts because unwrap 3D doesn't save it in .ms3d. So i think i have to change to another modeling program but all of them ( 3dstudio, blender,..) are difficult to use and , i think, you have to start allways with a primitive and not with vertexes. So where can i find a good blender tutorial explaining all steps from start to ending of modeling something or what other modeling program do you know, please? thank you very much

     

    P.D.: i tried 3dsmax but is boring difficult and "absurd" for me, and i find blender a little difficult too (at least in the begining).

  7. Hello,

     

    First sorry if it is allready answered but, how can i use a specular texture instead of the alpha channel of the dot3 texture?

    i tried adding the texture in number 2 in material editor but allways takes the dot3 alpha channel. Have i to change something in the shaders pack or anything else? thank you.

  8. Hi,

     

    I use this to point an entity to another:

     

    void SlowPointEnt(TEntity ent1,TEntity ent2,float speed)
    {
    TVec3 ent1pos=EntityPosition(ent1);
    TVec3 ent1rot=EntityRotation(ent1,0);
    TVec3 ent2pos=EntityPosition(ent2);
    float dx=0.0;
    float dy=0.0;
    float dz=0.0;
    float rz=0.0;
    //float speed=1.0;
    dx=ent1pos.X-ent2pos.X; 
    dy=ent1pos.Y-ent2pos.Y; 
    dz=ent1pos.Z-ent2pos.Z;
    rz=ent1rot.Z;
    return AlignToVector(ent1,Vec3(dx,rz,dz),3,speed);
    }

  9. Hello,

     

    I tried to post files and when i try to load the file it says me "Error you aren't permited to upload this kind of file". Can someone tell me why i can't post files of any type, please? is something that i have to configure in my profile ore something like that? thank you.

  10. hi,

     

    i'm trying to post you an alpha image that i made to try with Pixel Perfect suggestion but it give me "Error you aren't permited to upload this kind of file" and i don't know why. Anyway when you save your image, look, in image options, if the Pre Modulate Color checkbox is checked and check it if not. Of course the Generate Mip Maps radio button must be checked too as Marleys Ghost says (and flattenimage and all you did before). Then try Pixel Perfect suggestion. I'd like to post you an image but i can't.

     

    P.D.: for the 17% try make a shader with alpha test "configuration" and the white part of the alpha channel of the image must be 17% opacity i think, but not sure.

  11. Hello,

     

    well, sorry if i tell something that you allready know, but you have to create an alpha chanel of your image and then FlattenImage. I tell you it because i see in your image the transparent background and when you flatten the image it turns a white background so i assume you not done that. then save it as dds with alphamap and in the "properties" of the dds saving use, in the Image Options, Color Map instead of normal map. (you can create the normal map too but is necessary a color map). sorry again if you know that.

×
×
  • Create New...