Page 6 of 12

Re: Diablo III .app

Posted: Sun Oct 16, 2011 10:26 am
by Monguron
This is a sample code in away3D:
package
{
import away3d.containers.View3D;
import away3d.debug.AwayStats;
import away3d.entities.Mesh;
import away3d.events.LoaderEvent;
import away3d.lights.PointLight;
import away3d.loaders.Loader3D;
import away3d.loaders.misc.AssetLoaderContext;
import away3d.loaders.parsers.OBJParser;
import away3d.materials.BitmapMaterial;
import away3d.materials.methods.BasicDiffuseMethod;
import away3d.materials.methods.BasicSpecularMethod;
import away3d.materials.methods.FresnelSpecularMethod;
import away3d.materials.methods.SubsurfaceScatteringDiffuseMethod;

import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.KeyboardEvent;

[SWF(width="1280", height="720", frameRate="60", backgroundColor="0x000000")]
public class LoaderOBJTest extends Sprite
{
private var _view : View3D;
private var _loader : Loader3D;

private var _light : PointLight;

[Embed(source="/../embeds/head/head.obj", mimeType="application/octet-stream")]
private var OBJData : Class;

[Embed(source="/../embeds/head/Images/Map-COL.jpg")]
private var Albedo : Class;

[Embed(source="/../embeds/head/Images/Map-spec.jpg")]
private var Specular : Class;

[Embed(source="/../embeds/head/Images/Infinite-Level_02_Tangent_NoSmoothUV.jpg")]
private var Normal : Class;

//signature variables
private var Signature : Sprite;

//signature swf
[Embed(source="/../embeds/signature_david_head.swf", symbol="Signature")]
private var SignatureSwf : Class;

private var _camController : HoverDragController;
private var _count : Number = 0;
private var _subsurfaceMethod : SubsurfaceScatteringDiffuseMethod;
private var _diffuseMethod : BasicDiffuseMethod;
private var _material : BitmapMaterial;
private var _fresnelMethod : FresnelSpecularMethod;
private var _specularMethod : BasicSpecularMethod;

public function LoaderOBJTest()
{
_view = new View3D();
_view.antiAlias = 4;
this.addChild(_view);

Signature = Sprite(new SignatureSwf());
Signature.y = stage.stageHeight - Signature.height;

addChild(Signature);

_light = new PointLight();
_light.x = 15000;
_light.z = 15000;
_light.color = 0xffddbb;
_view.scene.addChild(_light);
_camController = new HoverDragController(_view.camera, stage);
addChild(new AwayStats(_view));
initMesh();

addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, onStageResize);
}

private function onStageResize(event : Event) : void
{
_view.width = stage.stageWidth;
_view.height = stage.stageHeight;

Signature.y = stage.stageHeight - Signature.height;
}

private function initMesh() : void
{
Loader3D.enableParser(OBJParser);

_loader = new Loader3D();
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete);
_loader.parseData(OBJData, null, new AssetLoaderContext(false));
_loader.y = -50;
_view.scene.addChild(_loader);

_material = new BitmapMaterial(new Albedo().bitmapData);
_subsurfaceMethod = new SubsurfaceScatteringDiffuseMethod(2048, 2);
_diffuseMethod = new BasicDiffuseMethod();
_fresnelMethod = new FresnelSpecularMethod(true);
_specularMethod = new BasicSpecularMethod();
_material.normalMap = new Normal().bitmapData;
_material.specularMap = new Specular().bitmapData;
_material.lights = [ _light ];
_material.gloss = 10;
_material.specular = 3;
_material.ambientColor = 0x303040;
_material.ambient = 1;
_subsurfaceMethod.scatterColor = 0xff7733; //0xff9966;
_subsurfaceMethod.scattering = .05;
_subsurfaceMethod.translucency = 4;
_material.diffuseMethod = _subsurfaceMethod;
_material.specularMethod = _fresnelMethod;
}

private function onResourceComplete(event : LoaderEvent) : void
{
var mesh : Mesh;
for (var i : int = 0; i < _loader.numChildren; ++i) {
mesh = Mesh(_loader.getChildAt(i));
mesh.geometry.scale(100);
mesh.material = _material
}
}

private function onKeyUp(event : KeyboardEvent) : void
{
_material.diffuseMethod = _material.diffuseMethod == _diffuseMethod ? _subsurfaceMethod : _diffuseMethod;
// _material.specularMethod = _material.specularMethod == _specularMethod? _fresnelMethod : _specularMethod;
}

private function onEnterFrame(ev : Event) : void
{
_count += .003;
// _container.rotationY += .3;

_light.x = Math.sin(_count) * 150000;
_light.y = 1000;
_light.z = Math.cos(_count) * 150000;

_view.render();
}
}
}
It opens an OBJ file, puts the layers, shaders, textures onto it, and then rotates a light around the object continuously.

We even need no light to add to the file.

Insane: do you have any idea (as a programmer), how to write a code, that is able to open the diablo 3 objects and attach the textures to them. Also the mtl file is needed to be linked somehow, but I have no clue at all.

Re: Diablo III .app

Posted: Sun Oct 16, 2011 5:49 pm
by npd2006
Insane: do you have any idea (as a programmer), how to write a code, that is able to open the diablo 3 objects and attach the textures to them. Also the mtl file is needed to be linked somehow, but I have no clue at all.
Big problem of AWAY 3D is how to read directly from .app and .tex file.

Re: Diablo III .app

Posted: Sun Oct 16, 2011 6:13 pm
by InsaneXo
Monguron wrote:This is a sample code in away3D:
It opens an OBJ file, puts the layers, shaders, textures onto it, and then rotates a light around the object continuously.
We even need no light to add to the file.
Insane: do you have any idea (as a programmer), how to write a code, that is able to open the diablo 3 objects and attach the textures to them. Also the mtl file is needed to be linked somehow, but I have no clue at all.
Nothing stops you from texturing it manualy and then feed to away3d.
Or you can write a .dll that reads/converts data from .app and than returns output to away3D core.
Problem is, no one knows SNOs for texture references, or hows its linked to .tex

Re: Diablo III .app

Posted: Mon Oct 17, 2011 12:13 pm
by Monguron
We don't have to read from .app files

We do everything as we did:

convert the .app --> we get the .obj (with proper vertexnormals), the .mtl and the .tex files
we convert the .tex to .jpg for example, and then the engine loads them.

I just don't know how to link the .jpg to the .mtl and the .obj in the program. And I didn't receive any answer in the away3D forum.
http://away3d.com/forum/viewthread/1029/

(so far I could only load an .obj without texture)


another thread regarding the topic:
http://away3d.com/forum/viewthread/978/

Re: Diablo III .app

Posted: Mon Oct 17, 2011 3:09 pm
by npd2006
We don't have to read from .app files
If you just want to read .obj and .jpg, don't wasting time for research diablo 3 data. Because it's general filetype, all 3D graphic software and engine can read it. They are not concern with diablo 3.

Re: Diablo III .app

Posted: Mon Oct 17, 2011 8:23 pm
by Monguron
If you just want to read .obj and .jpg, don't wasting time for research diablo 3 data. Because it's general filetype, all 3D graphic software and engine can read it. They are not concern with diablo 3.
I don't really get what you mean.

If the engine cannot read the .dds, then it must be converted to a general format (e.g. jpg, png, etc...)

Re: Diablo III .app

Posted: Tue Oct 18, 2011 3:41 am
by npd2006
If the engine cannot read the .dds, then it must be converted to a general format (e.g. jpg, png, etc...)
We should find a way to solve that problem, if there is no way to do that, we need a better engine.
I don't really get what you mean.
_ filetype .obj and .jpg, .dds are very regular, every 3D software can read it, example: maya, 3ds max, lightwave, blender,....
_ filetype .app and .tex are very special, because they only exist in diablo 3
_ The reason we need a converter is no software can read directly diablo 3 files. That's why we need a converter to convert diablo 3 filetype to regular filetype.

Re: Diablo III .app

Posted: Tue Oct 18, 2011 5:55 am
by deltaone
get http://oasis.xentax.com/index.php?content=downloads and write plugin for it - easy ...
as alternative make temp dir => convert model in temp dir => show as yo wish

P.S. In D3 resources i found trDun_Torch.app WHERE its texture ? I search in mpq with Total Commander through wcx plugin keyword "torch" and no .tex found for this model ...

Re: Diablo III .app

Posted: Tue Oct 18, 2011 6:34 am
by npd2006
get http://oasis.xentax.com/index.php?content=downloads and write plugin for it - easy ...
as alternative make temp dir => convert model in temp dir => show as yo wish
I'll check it. Did you write any plugin by using it?
P.S. In D3 resources i found trDun_Torch.app WHERE its texture ? I search in mpq with Total Commander through wcx plugin keyword "torch" and no .tex found for this model ...
texture is in texture.mpq

Re: Diablo III .app

Posted: Tue Oct 18, 2011 7:48 am
by InsaneXo
Monguron wrote: Insane: do you have any idea (as a programmer), how to write a code, that is able to open the diablo 3 objects and attach the textures to them. Also the mtl file is needed to be linked somehow, but I have no clue at all.
Ofcourse i do, trivial task, either OpenGL/D3D or even more simplier in Away/Papervision :)
I wonder, how you going to link .mtl file if its not exist ? :) (as a hint)
You are after using this application for "commercial", e.g. using it out personal website, am i right ?

Re: Diablo III .app

Posted: Tue Oct 18, 2011 11:05 am
by deltaone
get http://oasis.xentax.com/index.php?content=downloads and write plugin for it - easy ...
as alternative make temp dir => convert model in temp dir => show as yo wish
I'll check it. Did you write any plugin by using it?
No, program archive come with plugins sources (pluginsource.zip) as example look on quakemd2
strcpy_s(infOut->pluginDesc, 512, "Quake II MD2 format handler, by Dick.");

P.S. In D3 resources i found trDun_Torch.app WHERE its texture ? I search in mpq with Total Commander through wcx plugin keyword "torch" and no .tex found for this model ...
texture is in texture.mpq
please say filename for this model from texture.mpq i can't find it ...

Re: Diablo III .app

Posted: Tue Oct 18, 2011 12:26 pm
by Monguron
Ofcourse i do, trivial task, either OpenGL/D3D or even more simplier in Away/Papervision :)
For a 3d programmer it might be trivial :) ... so you can extend/change the code I wrote in a previous post to load for example the adria.obj + the two textures into the flash framework (in away3D) ;)
I wonder, how you going to link .mtl file if its not exist ? :) (as a hint)
I saw a .mtl file in my folder, perhaps it was made after I exported the model from Blender. I don't remember.
You are after using this application for "commercial", e.g. using it out personal website, am i right ?
Yes, I would use the flash in a website.

Re: Diablo III .app

Posted: Tue Oct 18, 2011 12:32 pm
by Monguron
npd2006 wrote:
If the engine cannot read the .dds, then it must be converted to a general format (e.g. jpg, png, etc...)
We should find a way to solve that problem, if there is no way to do that, we need a better engine.
I don't really get what you mean.
_ filetype .obj and .jpg, .dds are very regular, every 3D software can read it, example: maya, 3ds max, lightwave, blender,....
_ filetype .app and .tex are very special, because they only exist in diablo 3
_ The reason we need a converter is no software can read directly diablo 3 files. That's why we need a converter to convert diablo 3 filetype to regular filetype.
I don't really see a chance to have an all-in-one program, that can convert the .app files internally and then load them.
So I'm quite sure we will need to convert the apps manually with the converter, and then we can load the .obj files in the "model viewer".

Re: Diablo III .app

Posted: Tue Oct 18, 2011 9:20 pm
by deltaone
fixed version

comare .obj with script output, almost identical ...

Re: Diablo III .app

Posted: Wed Oct 19, 2011 5:15 am
by npd2006
fixed version

comare .obj with script output, almost identical ...
Please post the source code here.