public void Load(GraphicsDevice device, string dataPath) { string filepath = string.Format("{0}model/{1}", dataPath, Filename); RsmModel = new RsmModel(filepath); RsmModel.CalculateMeshes(device); }
public void Draw(GraphicsDevice device, BasicEffect effect, Matrix view, Matrix projection, Matrix world) { RsmModel.Draw(device, effect, view, projection, world); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); _aspectRatio = _graphics.GraphicsDevice.Viewport.Width / (float)_graphics.GraphicsDevice.Viewport.Height; _testRsm = new RsmFormat("Content/random_test_model.rsm"); _testRsm.CalculateMeshes(GraphicsDevice); _testRsm.LoadTextures(GraphicsDevice, "C:/Games/ragnarok-full-data/data/"); //_testRsw = new RswFormat("Content/prontera.rsw"); //_testRsw.Load(GraphicsDevice, "C:/Games/RO/data/"); _modelEffect = new BasicEffect(GraphicsDevice); _modelEffect.TextureEnabled = true; var _vertexShader = @" attribute vec3 aPosition; attribute vec3 aVertexNormal; attribute vec2 aTextureCoord; attribute float aAlpha; varying vec2 vTextureCoord; varying float vLightWeighting; varying float vAlpha; uniform mat4 uModelViewMat; uniform mat4 uProjectionMat; uniform vec3 uLightDirection; uniform mat3 uNormalMat; void main(void) { gl_Position = uProjectionMat * uModelViewMat * vec4( aPosition, 1.0); vTextureCoord = aTextureCoord; vAlpha = aAlpha; vec4 lDirection = uModelViewMat * vec4( uLightDirection, 0.0); vec3 dirVector = normalize(lDirection.xyz); float dotProduct = dot( uNormalMat * aVertexNormal, dirVector ); vLightWeighting = max( dotProduct, 0.5 ); }"; var _fragmentShader = @" varying vec2 vTextureCoord; varying float vLightWeighting; varying float vAlpha; uniform sampler2D uDiffuse; uniform bool uFogUse; uniform float uFogNear; uniform float uFogFar; uniform vec3 uFogColor; uniform vec3 uLightAmbient; uniform vec3 uLightDiffuse; uniform float uLightOpacity; void main(void) { vec4 texture = texture2D( uDiffuse, vTextureCoord.st ); if ( texture.a == 0.0 ) discard; vec3 Ambient = uLightAmbient * uLightOpacity; vec3 Diffuse = uLightDiffuse * vLightWeighting; vec4 LightColor = vec4( Ambient + Diffuse, 1.0); gl_FragColor = texture * clamp(LightColor, 0.0, 1.0); gl_FragColor.a *= vAlpha; if ( uFogUse ) { float depth = gl_FragCoord.z / gl_FragCoord.w; float fogFactor = smoothstep( uFogNear, uFogFar, depth ); gl_FragColor = mix( gl_FragColor, vec4( uFogColor, gl_FragColor.w ), fogFactor ); } }"; }
public void Load(GraphicsDevice device, string dataPath) { string filepath = string.Format("{0}model/{1}", dataPath, Filename); RsmModel = new RsmModel(filepath); RsmModel.CalculateMeshes(device); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); _aspectRatio = _graphics.GraphicsDevice.Viewport.Width / (float)_graphics.GraphicsDevice.Viewport.Height; _testRsm = new RsmFormat("Content/random_test_model.rsm"); _testRsm.CalculateMeshes(GraphicsDevice); _testRsm.LoadTextures(GraphicsDevice, "C:/Games/ragnarok-full-data/data/"); //_testRsw = new RswFormat("Content/prontera.rsw"); //_testRsw.Load(GraphicsDevice, "C:/Games/RO/data/"); _modelEffect = new BasicEffect(GraphicsDevice); _modelEffect.TextureEnabled = true; var _vertexShader = @" attribute vec3 aPosition; attribute vec3 aVertexNormal; attribute vec2 aTextureCoord; attribute float aAlpha; varying vec2 vTextureCoord; varying float vLightWeighting; varying float vAlpha; uniform mat4 uModelViewMat; uniform mat4 uProjectionMat; uniform vec3 uLightDirection; uniform mat3 uNormalMat; void main(void) { gl_Position = uProjectionMat * uModelViewMat * vec4( aPosition, 1.0); vTextureCoord = aTextureCoord; vAlpha = aAlpha; vec4 lDirection = uModelViewMat * vec4( uLightDirection, 0.0); vec3 dirVector = normalize(lDirection.xyz); float dotProduct = dot( uNormalMat * aVertexNormal, dirVector ); vLightWeighting = max( dotProduct, 0.5 ); }"; var _fragmentShader = @" varying vec2 vTextureCoord; varying float vLightWeighting; varying float vAlpha; uniform sampler2D uDiffuse; uniform bool uFogUse; uniform float uFogNear; uniform float uFogFar; uniform vec3 uFogColor; uniform vec3 uLightAmbient; uniform vec3 uLightDiffuse; uniform float uLightOpacity; void main(void) { vec4 texture = texture2D( uDiffuse, vTextureCoord.st ); if ( texture.a == 0.0 ) discard; vec3 Ambient = uLightAmbient * uLightOpacity; vec3 Diffuse = uLightDiffuse * vLightWeighting; vec4 LightColor = vec4( Ambient + Diffuse, 1.0); gl_FragColor = texture * clamp(LightColor, 0.0, 1.0); gl_FragColor.a *= vAlpha; if ( uFogUse ) { float depth = gl_FragCoord.z / gl_FragCoord.w; float fogFactor = smoothstep( uFogNear, uFogFar, depth ); gl_FragColor = mix( gl_FragColor, vec4( uFogColor, gl_FragColor.w ), fogFactor ); } }"; }