.obj vs .blend pros and cons

When would you use .blend over.obj especially to load models? Which one, if either , would allow me to manipulate meshes dynamically on the fly?

[quote=“Relentless_Inchworm, post:1, topic:35302”]
would allow me to manipulate meshes dynamically on the fly?
[/quote] in JME or Blender ? … because you cant do that in JME with any format

I was thinking in JME. So once loaded there isn’t a way to access the mesh for the model? What about something like ogre?

Hi

Obj format does not support skeleton animation. so for animation purpose we should use other formats.

You can rig your model in blender (weight paint your model with armature in blender) then in JME by transforming the armature you can modify mesh dynamically thought.

The other way you can manipulate mesh this time with no need to rig (I mean you can do this even for obj format) is by manipulating mesh data in JME. For each mesh the data saved in an array called VertexBuffer which maintains the (X,Y,Z) position of every vertex of mesh.
for more info read here : Dynamic Mesh

Hey guys please correct me if i explained something wrong .
Thanks

well… yes you can… you have to edit the meshes’ buffers.
@Relentless_Inchworm the input format makes no difference in this regard though. Once the loadde model in in JME it is stored in memory with a JME internal structure that is pretty basic.

Ok so are meshes stored in the vertex buffer or somewhere else?

[Edit] ok after re-reading the link that @Ali_RS gave I think I understand which buffers we are referring to.

@nehon would you mind elaborating on what internal structures you are referring to?

http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:mesh

…i don’t know which exporter for OBJ you using, so maybe its different for you…one i use is limited to 8:3 format, and that mess up material names, longer than 8 characters, which may be troublesome if first 8 characters in original name are same, so you end up with wrongly or partially textured geometry…

I actually don’t use an importer as far as I know. I just take the model and reference it’s location directly. Here is the code (sorry if its a mess)


package game;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

import com.jme3.asset.AssetManager;
import com.jme3.asset.TextureKey;
import com.jme3.bullet.collision.shapes.CompoundCollisionShape;
import com.jme3.bullet.util.CollisionShapeFactory;
import com.jme3.material.Material;
import com.jme3.math.Matrix3f;
import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.texture.Texture;

public class CarBuilder extends Node {
	
	Racer r;
	
	HashMap<Integer, MyVC> carList;
	List<AI> AIlist;
	
	CarBuilder() {
		carList = new HashMap<>();
	}
	
	public void addPlayer(int id,Racer racer, ExtendedVT car, Vector3f start, Matrix3f rot, boolean AI) {
		if (carList.containsKey(id)) {
			try {
				throw new Exception("A car already has that Id");
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
		if (r == null) {
			r = racer;
			r.getRootNode().attachChild(this);
		}
		
		AssetManager am = racer.getAssetManager();
		Node carmodel = (Node) am.loadModel(car.carModel);
		
		TextureKey key = new TextureKey("Textures/Sky/Bright/BrightSky.dds", true);
        key.setGenerateMips(true);
        key.setAsCube(true);
        final Texture tex = am.loadTexture(key);
        
        for (Geometry g: H.getGeomList(carmodel)) 
            
            
            g.setMaterial(m);
        }
        
		//create a compound shape and attach CollisionShape for the car body at 0,1,0
		//this shifts the effective center of mass of the BoxCollisionShape to 0,-1,0
		CompoundCollisionShape compoundShape = new CompoundCollisionShape();
		compoundShape.addChildShape(CollisionShapeFactory.createDynamicMeshShape(carmodel), new Vector3f(0,0,0));

		
		Node carNode = new Node(id+"");
		MyVC player = new MyVC(compoundShape, car, carNode, rally);
		
		carNode.addControl(player);
		carNode.attachChild(carmodel);
		
		if (AI) { //laggy
			carNode.setShadowMode(ShadowMode.Off);
		} else {
			carNode.setShadowMode(ShadowMode.CastAndReceive);
		}

		this.attachChild(carNode);
		this.attachChild(player.skidNode);
		player.setPhysicsLocation(start);
		player.setPhysicsRotation(rot);
		
		r.getPhysicsSpace().add(player);
		
		carList.put(id, player);
		
		if (AI) {
			if (this.AIlist == null){
				this.AIlist = new LinkedList<AI>();
			}
			AI a = new AI(rally, player);
			this.AIlist.add(a);
			player.giveAI(a);
		}
	}
	
	public void update(float tpf) {
		if (carList.isEmpty()) 
			return;
		
		for (Integer i : carList.keySet()) {
			carList.get(i).myUpdate(tpf);
		}
		
		for (AI a: AIlist) {
			a.update(tpf);
		}
		
		if (r.dynamicWorld) {
			r.worldB.update(carList.get(0).getPhysicsLocation());
		}
			
		if (r.ifDebug) {
			
		}
	}
	
	public MyPhysicsVehicle get(int a) {
		return carList.get(a);
	}
}

This an older version of the game but the loading process is the same. There is no model passed from extendedVT only a string representing the path to the model.

[Edit] Fixed the code blocks. Apparently my phone has no idea what a back tick is.

No, you should format your post properly. See the giant thread right at the top of the latest posts screen that shows you how.

Yes, but what is the value of car.carModel? What does it end with? “.obj”, “.j3o”… probably “.j3o”… in which case somehow it went from its original format to .j3o.

At this point carmodel is a string referencing either a .blend or a .obj file and it works with both.

Unless you’ve messed with your plugins, that’s not going to work when you deploy your game.

If you are using the standard build scripts then JME won’t even bundle those assets. The blender loader and the obj loader are slow and unstable and its best to convert your models to j3o to ship with your game. Else, you will have a lot to do to bypass JME’s pushing you in that direction.

It works when running the code in NetBeans but this was never supposed to be a long term solution. Ive been working on incorporating .je3mo but with no internet where im developing its been slow. I have right clicked on .blend files before and told it convert but nothing happened so my setup may be messed up here. I just got the alpha 2 of 3.1 so maybe a fresh install will help.