« Return to Thread: ShadedMaterials not working with Collada model

Re: ShadedMaterials not working with Collada model

by andysk8er :: Rate this Message:

Reply to Author | View in Thread

Hi Dan,

Why don't you try to simplify things in your code first. Simply create a simple flatshadedmaterial, add it to the materials list and do your replaceMaterialByName. See if you can get that working. Then, go back and add in your textures, shaders, etc...

I guess I'm not really sure why you are declaring your materials as Classes. Why not just create MovieAssetMaterials using the linkage name in the library? Anyway, if you strip all of that stuff out of your code and simply use a flatshaded material, you can see if that works. If so, you can begin adding your materials back in until it breaks.

-Andy


DanSearle wrote:
Hi list,

If I understand SVN right I'm on revision 918.

I'm using the free version of Google SketchUp (v6.4.112) to make DAE
files (using that hack to get the DAE from the KMZ it outputs), but I
can't get the ShadedMaterials to work with it.

Here's a demo I've made:
http://www.danwashere.com/dev/papervision/shadedtextures_and_collada_problem/DanWasHereWorld.html
(Mouse Up/Down to move in and out, Mouse Left/Right to move the light
source)

The paddling pool is meant to be shaded - the cube uses the same shaded
materials as the pool to prove that the materials themselves are ok.

Is it maybe that the DAE created in this way isn't compatible with
ShadedMaterials? Here's a link to the DAE file:
http://www.danwashere.com/dev/papervision/shadedtextures_and_collada_problem/paddling%20pond.dae

Or in case it's a code problem, here's the relevant code, or you can
also get the AS file here:
http://www.danwashere.com/dev/papervision/shadedtextures_and_collada_problem/DanWasHereWorld.as

(Note that I have the textures in the FLA library)

        public function DanWasHereWorld($mc:MovieClip) {
           
            mc = $mc;
           
            viewport = new Viewport3D(800, 600, true, true, true, true);
            mc.addChild(viewport);
           
            camera = new Camera3D(standardViewCameraFOV, 10, 5000, true);
            camera.x = standardViewCameraX;
            camera.y = standardViewCameraY;
            camera.z = standardViewCameraZ;
            camera.zoom = standardViewCameraZoom;
           
            renderer = new BasicRenderEngine();
            mc.addChild(viewport);

            scene = new Scene3D();
           
            light = new PointLight3D();
            scene.addChild(light);
            light.x = 0;
            light.y = 400;
            light.z = -100;
            light.showLight = true;
           
            var textureBottomRing:Class =
ApplicationDomain.currentDomain.getDefinition("Texture_bottomring") as
Class;
            var textureMidRing:Class =
ApplicationDomain.currentDomain.getDefinition("Texture_midring") as Class;
            var textureTopRing:Class =
ApplicationDomain.currentDomain.getDefinition("Texture_topring") as Class;
            var textureWater:Class =
ApplicationDomain.currentDomain.getDefinition("Texture_water") as Class;
            var textureExtra1:Class =
ApplicationDomain.currentDomain.getDefinition("Texture_extra_1") as Class;
            var textureExtra2:Class =
ApplicationDomain.currentDomain.getDefinition("Texture_extra_2") as Class;
           
            // Not in a logical order here because that's how they came
out in the Collada DAE file.
            mcTexture0 = new textureWater();
            mcTexture1 = new textureBottomRing();
            mcTexture2 = new textureTopRing();
            mcTexture3 = new textureMidRing();
           
            // Two extra textures to show the text cube.
            mcTexture4 = new textureExtra1();
            mcTexture5 = new textureExtra2();
           
            movieMaterial0 = new MovieMaterial(mcTexture0, false, true,
false);
            movieMaterial1 = new MovieMaterial(mcTexture1, false, false,
false);
            movieMaterial2 = new MovieMaterial(mcTexture2, false, false,
false);
            movieMaterial3 = new MovieMaterial(mcTexture3, false, false,
false);
            movieMaterial4 = new MovieMaterial(mcTexture4, false, false,
false);
            movieMaterial5 = new MovieMaterial(mcTexture5, false, false,
false);
           
            movieMaterial0.precise = true;
           
            movieMaterial0.doubleSided = false;
            movieMaterial1.doubleSided = false;
            movieMaterial2.doubleSided = false;
            movieMaterial3.doubleSided = false;
            movieMaterial4.doubleSided = false;
            movieMaterial5.doubleSided = false;
           
                       
            shadedMaterial0 = new ShadedMaterial(movieMaterial0, new
FlatShader(light, 0xFFFFFF, 0x555555));
            shadedMaterial1 = new ShadedMaterial(movieMaterial1, new
FlatShader(light, 0xFFFFFF, 0x555555));
            shadedMaterial2 = new ShadedMaterial(movieMaterial2, new
FlatShader(light, 0xFFFFFF, 0x555555));
            shadedMaterial3 = new ShadedMaterial(movieMaterial3, new
FlatShader(light, 0xFFFFFF, 0x555555));
            shadedMaterial4 = new ShadedMaterial(movieMaterial4, new
FlatShader(light, 0xFFFFFF, 0x555555));
            shadedMaterial5 = new ShadedMaterial(movieMaterial5, new
FlatShader(light, 0xFFFFFF, 0x555555));
           
           
            var mat:MaterialsList = new MaterialsList();
           
            mat.addMaterial(movieMaterial0,         "material0");
            mat.addMaterial(movieMaterial1,         "material1");
            mat.addMaterial(movieMaterial2,             "material2");
            mat.addMaterial(movieMaterial3,             "material3");
            mat.addMaterial(movieMaterial4,             "material4");
            mat.addMaterial(movieMaterial5,             "material5");
           
            island = new Collada("paddling pond.dae", mat, 0.0005);
            scene.addChild(island);
            island.x = -200;
            island.y = 0;
            island.z = 200;
           
            island.replaceMaterialByName(shadedMaterial0, "material0");
            island.replaceMaterialByName(shadedMaterial1, "material1");
            island.replaceMaterialByName(shadedMaterial2, "material2");
            island.replaceMaterialByName(shadedMaterial3, "material3");
           
            //island.rotationY = -180 + Math.random() * 360;
           
            camera.target = island;
           
            // Set up the cube.
            var matCube:MaterialsList = new MaterialsList();          
            matCube.addMaterial(shadedMaterial0,         "front");
            matCube.addMaterial(shadedMaterial1,         "back");
            matCube.addMaterial(shadedMaterial2,             "right");
            matCube.addMaterial(shadedMaterial3,             "left");
            matCube.addMaterial(shadedMaterial4,             "top");
            matCube.addMaterial(shadedMaterial5,             "bottom");

            testCube = new Cube(matCube, 100, 100, 100, 6, 6, 6);        
   
            scene.addChild(testCube);
            testCube.x = 0;
            testCube.y = 150;
            testCube.z = 50;

           
            mc.stage.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
        }



I'd love an explanation of how to do this if someone can help?

Many thanks,
Dan



_______________________________________________
Papervision3D mailing list
Papervision3D@osflash.org
http://osflash.org/mailman/listinfo/papervision3d_osflash.org
===============================================
Check out my blog for Flash, AS3, and web development stuff:
http://www.wastedpotential.com

 « Return to Thread: ShadedMaterials not working with Collada model