few questions

Hi, I have a few random questions as I am going thow this trying to learn python, panda3d and a simple run game.

One, what is a shader? I seen a few people talk about them, and how they can be used from rain->snow, water->heat O.o;? How would you go about using one for like a river?

Two, how would you go about making a see thow window or glass? Do you use shaders like above?

Three, is there a faster way to place NPC, models, then to just saying out everytime? Or Atless less messy when calling models?:

#Load the first environment model town.x 
town1 = loader.loadModel("town/a") 
town1.reparentTo(render) 
town1.setScale(0.25,0.25,0.25) 
town1.setPos(0,0,0)

#Load grass
town1_grass1 = loader.loadModel("town/grass2.x") 
town1_grass1.reparentTo(render) 
town1_grass1.setScale(0.005,0.005,0.005) 
town1_grass1.setPos(3500,-10000,-60) #(3500,-10000,-60)

#Load the panda actor 
self.pandaActor = Actor.Actor("models/panda-model",{"walk":"models/panda-walk4"}) 
self.pandaActor.setScale(0.05,0.05,0.05) 
self.pandaActor.reparentTo(render) 
self.pandaActor.loop("walk")
self.pandaActor.setPos(0,0,-25) #(0,-7000,0)

Four, trying to make this code follow the panda model, I can get it to follow, but the camera a little to over the top. What should I change to make it just above the panda looking down at it?

    def move(self, task):

        elapsed = task.time - self.prevtime

	base.camera.lookAt(self.pandaActor)
        camright = base.camera.getNetTransform().getMat().getRow3(0)
	camright.normalize()
        if (self.keyMap["left"]!=0): 
	    self.pandaActor.setH(self.pandaActor.getH() - elapsed*300)
        if (self.keyMap["right"]!=0): 
	    self.pandaActor.setH(self.pandaActor.getH() + elapsed*300)
        if (self.keyMap["forward"]!=0):
	    forwardup = self.pandaActor.getNetTransform().getMat().getRow3(1)
            forwardup.setZ(0)
            forwardup.normalize()	
	    self.pandaActor.setPos(self.pandaActor.getPos() - forwardup*(elapsed*500))
        if (self.keyMap["back"]!=0):
	    backward = self.pandaActor.getNetTransform().getMat().getRow3(0)
            backward.setZ(0)
            backward.normalize()
	    self.pandaActor.setPos(self.pandaActor.getPos() + backward*(elapsed*500))


        camvec = self.pandaActor.getPos() - base.camera.getPos()
        camvec.setZ(0)
        camdist = camvec.length()
        camvec.normalize()
        if (camdist > 20.0):
            base.camera.setPos(base.camera.getPos() + camvec*(camdist-10))
            camdist = 20.0
        if (camdist < 10.0):
            base.camera.setPos(base.camera.getPos() - camvec*(5-camdist))
            camdist = 10.0

        self.prevtime = task.time 
        return Task.cont

Befor you tell me to look at the Roaming-Ralph tut, I did…

Five, UDP & TCP can send strings over the net and network. How do you go about sending a file like a picture or a sound file?

shaders is just a program that runs on every vertex of your model or every pixel of your texture. Shaders are responsible for computing correct vector positions and get correct colors from the image and stretch them over the vertexes it computed. You are using “shades” right now just the default ones which mimic the pre-shader pipe line. Before the program to compute all that was in hardware now you can upload that program to the GPU. The shader program must be very simple in order to run very fast.

example of a simple shader:

//Cg
//
//Cg profile arbvp1 arbfp1

void vshader(float4 vtx_position : POSITION,
             float4 vtx_color : COLOR,
             in uniform float4x4 mat_modelproj, 
             out float4 l_position : POSITION,
             out float4 l_color : COLOR)
{
  l_position=mul(mat_modelproj, vtx_position);
  l_color = vtx_color;
}

void fshader(float4 l_color: COLOR,
             in uniform float4 k_glow,
             in uniform float4 k_team,
             out float4 o_color: COLOR0)
{
    o_color = l_color;
}

example of a complex shader:

//Cg
//
//Cg profile arbvp1 arbfp1

void vshader(
     in uniform float4x4 mat_modelproj, 
     in uniform float4x4 inv_modelview,            
    
     in float4 vtx_position  : POSITION,
     in float3 vtx_normal    : NORMAL,
     in float2 vtx_texcoord0 : TEXCOORD0,
     in float3 vtx_tangent0  : TANGENT,
     in float3 vtx_binormal0 : BINORMAL,
     
     out float4 l_position  : POSITION,  // needed for the gfx card       
     
     out float4 l_vertPos   : TEXCOORD6,
     out float3 l_normal    : TEXCOORD1,
     out float2 l_uv        : TEXCOORD2,
     out float3 l_tangent   : TEXCOORD3,
     out float3 l_binormal  : TEXCOORD4,
     out float3 l_eyeVec    : TEXCOORD5
     )
{
    l_position=mul(mat_modelproj, vtx_position);
    l_uv=vtx_texcoord0;
    l_eyeVec = mul(inv_modelview,float4(0., 0., 0., 1.)) - l_position;
    l_vertPos = vtx_position;
    l_normal = vtx_normal;
    l_uv = vtx_texcoord0;
    l_tangent  = vtx_tangent0;
    l_binormal = vtx_binormal0;
}


#define Delta 500

void fshader(
    // from vshader
     in  float4 l_vertPos   : TEXCOORD6,
     in  float3 l_normal    : TEXCOORD1,
     in  float2 l_uv        : TEXCOORD2,
     in  float3 l_tangent   : TEXCOORD3,
     in  float3 l_binormal  : TEXCOORD4,
     in  float3 l_eyeVec    : TEXCOORD5,
    // texture units
     in uniform sampler2D tex_0 : TEXUNIT0,
     in uniform sampler2D tex_1 : TEXUNIT1,  
    // from inputs       
     in uniform float4 k_glow,
     in uniform float4 k_team,
    // from lighting
     
     in uniform float4 mspos_sun    : c7,
     in uniform float4 k_sunDef     : c8,
     in uniform float4 mspos_light1 : c9,
     in uniform float4 k_light1Def  : c10,
     in uniform float4 mspos_light2 : c11,
     in uniform float4 k_light2Def  : c12,
     in uniform float4 mspos_light3 : c13,
     in uniform float4 k_light3Def  : c14,
     
    // out put color to the screen
    out float4 o_color : COLOR
    )
{
    // load our texture stages
    float4 texRgba=tex2D(tex_0, l_uv);
    float4 texBstg=tex2D(tex_1, l_uv);
    float4 hullColor = (1-texBstg.g)*texRgba + k_team*texBstg.g  ;
    float3 halfVec = normalize( l_eyeVec + l_normal );
    
    o_color = float4(0,0,0,0);
    
    float spec = texBstg.y;
                     
    // diffinitons
    float3 lightvec;
    float  distance;
    float  attenuate;
    float3 conv_lightvec;
    float slant;
    float ndotl;
    float ndoth;
    float4 out_color;
    
     // sun light
    lightvec = normalize((float3)mspos_sun - l_vertPos);
    conv_lightvec.x = dot(l_tangent,   lightvec);
    conv_lightvec.y = -dot(l_binormal, lightvec);
    conv_lightvec.z = dot(l_normal,     lightvec);
    slant = tex2D(tex_1,  l_uv+float2(conv_lightvec.x,conv_lightvec.y)/Delta ).x  -  tex2D(tex_1,  l_uv).x;
    l_normal += .1*normalize(float3(conv_lightvec.x,conv_lightvec.y,slant));
    l_normal = normalize(l_normal);
    out_color =  hullColor*k_sunDef*k_sunDef.a ;
    ndotl = max( saturate(dot( lightvec, l_normal )), 0.0 ); 
    ndoth = (ndotl > 0.0) ? pow(max( dot( halfVec, l_normal ), 0.0 ), 128.) : 0.0;  
    o_color += ndotl*out_color + ndoth*out_color*spec;     
    
    
    lightvec = ((float3)mspos_light1 - l_vertPos);
    distance = k_light1Def.w/length(lightvec);
    attenuate = saturate(30.0 / (15.0 + distance));
    lightvec = normalize(lightvec);
    ndotl = max( dot( lightvec, l_normal ), 0.0 ); 
    ndoth = (ndotl > 0.0) ? pow(max( dot( halfVec, l_normal ), 0.0 ), 128.) : 0.0;  
    out_color = hullColor*attenuate*k_light1Def*k_light1Def.a;
    o_color += ndotl*out_color + ndoth*out_color*spec;

    lightvec = ((float3)mspos_light2 - l_vertPos);
    distance = k_light2Def.w/length(lightvec);
    attenuate = saturate(30.0 / (15.0 + distance));
    lightvec = normalize(lightvec);
    ndotl = max( dot( lightvec, l_normal ), 0.0 ); 
    ndoth = (ndotl > 0.0) ? pow(max( dot( halfVec, l_normal ), 0.0 ), 128.) : 0.0;  
    out_color = hullColor*attenuate*k_light2Def*k_light2Def.a;
    o_color += ndotl*out_color + ndoth*out_color*spec;

/*
    lightvec = ((float3)mspos_light3 - l_vertPos);
    distance = k_light3Def.w/length(lightvec);
    attenuate = saturate(30.0 / (15.0 + distance));
    lightvec = normalize(lightvec);
    ndotl = max( dot( lightvec, l_normal ), 0.0 ); 
    ndoth = (ndotl > 0.0) ? pow(max( dot( halfVec, l_normal ), 0.0 ), 128.) : 0.0;  
    out_color = hullColor*attenuate*k_light3Def*k_light3Def.a;
    o_color += ndotl*out_color + ndoth*out_color*spec;
*/    
    
    o_color += o_color*slant*3;     
    
    // compute correct glow 
    if ( k_glow.w > 0.1 )
        o_color = texBstg.w*hullColor;
    else if ( texBstg.w > 0.1 )
        o_color = o_color + texBstg.w*hullColor;
    o_color.a = texRgba.a;
     
    //o_color = float4(l_normal,1);
    //o_color = float4(l_uv,0,1);
    //o_color = float4(l_tangent,1);
    //o_color = float4(l_binormal,1);
     
}

So you must use the shader to draw any thing even if you dont load it your self the card loads it for you. Without shader nothing can be drawn so you must use it to make a river or any thing else.

Normlay you put NPC in a call and create the class which created every thing else you tell it.

You are on your own with camera code there is many camera samples on the forum and the code you have is too complicated.

You pack the strings before you send them over the net. I recommend struct module. You give it format and arguments it gives you a string back . Then you can extract the args if you know the format. Some people use Pickle to do this but pickle is a big security risk (i can take over your machine by sending the right string) there is other pickle like modules around which are secure - one of them i wrote.

Alright, thanks, that helps me out alot more. As for the camera, the code right x.x; just dont know to set the numbers right XD lol. Oh well I guess i’ll play around al ittle more with the numbers, thanks again ^^